2012-08-24 00:36:13 +00:00
|
|
|
#!/usr/bin/env bash
|
2009-09-17 17:56:59 +00:00
|
|
|
|
2009-09-18 19:26:34 +00:00
|
|
|
HEADER="svn_version.h"
|
|
|
|
TMPFILE="$HEADER.tmp"
|
|
|
|
|
|
|
|
echo "#ifndef SVN_VERSION_H" > $TMPFILE
|
|
|
|
echo "#define SVN_VERSION_H" >> $TMPFILE
|
|
|
|
echo "" >> $TMPFILE
|
2009-09-17 17:56:59 +00:00
|
|
|
|
2011-01-14 14:06:09 +00:00
|
|
|
if [ -d .git/svn ]; then
|
2009-09-17 17:56:59 +00:00
|
|
|
CMD="git svn info"
|
2011-01-14 14:06:09 +00:00
|
|
|
elif [ -d .git ]; then
|
|
|
|
GIT_LOG=`git log -n1 --pretty="format:%H"`
|
|
|
|
HOST=`hostname`
|
2011-03-10 14:47:01 +00:00
|
|
|
BRANCH=`git branch | sed -n 's/^\* *//p'`
|
2016-02-27 05:01:00 +00:00
|
|
|
remote=`git config --get branch.$BRANCH.remote 2>/dev/null`
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
remote="origin"
|
|
|
|
fi
|
2011-03-10 14:47:01 +00:00
|
|
|
URL=`git config --get remote.$remote.url`
|
|
|
|
DATE=`git log -n1 --pretty="format:%ct"`
|
2023-05-05 18:05:20 +00:00
|
|
|
SERVER_VERSION=`git describe --abbrev=0 --match server_release/*`
|
2009-09-17 17:56:59 +00:00
|
|
|
elif [ -d .svn ]; then
|
|
|
|
CMD="svn info"
|
|
|
|
else
|
|
|
|
CMD=""
|
|
|
|
fi
|
|
|
|
|
2011-01-14 14:06:09 +00:00
|
|
|
if [ "x$GIT_LOG" != "x" ]; then
|
2018-11-30 14:38:20 +00:00
|
|
|
echo "#define SVN_VERSION \"$GIT_LOG [$URL] ($HOST:$PWD [$BRANCH]) [Server-Release: $SERVER_VERSION]\"" >> $TMPFILE
|
2011-03-10 14:47:01 +00:00
|
|
|
echo "$GIT_LOG" | sed 's/^\(........\).*/#define GIT_REVISION 0x\1/' >> $TMPFILE
|
|
|
|
echo "#define GIT_DATE $DATE" >> $TMPFILE
|
|
|
|
test "x$URL" = "x" ||
|
|
|
|
echo "$URL" |
|
|
|
|
sed 's/.git$//;s%.*://%%;s/[^/]*@//;s/[^a-zA-Z0-9]/_/g;s/__*/_/g;
|
|
|
|
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;
|
|
|
|
s/^/#define REPOSITORY_/;s/$/ 1/' >> $TMPFILE
|
2011-01-14 14:06:09 +00:00
|
|
|
elif [ "x$CMD" != "x" ]; then
|
2016-02-27 05:01:00 +00:00
|
|
|
LANG=C
|
2012-08-24 00:36:13 +00:00
|
|
|
URL=`$CMD | awk '
|
|
|
|
/^URL/ { url = $2; };
|
2011-03-10 14:47:01 +00:00
|
|
|
/^Rev/ { rev = $2; };
|
2009-09-17 17:56:59 +00:00
|
|
|
END { print "#define SVN_VERSION \"Repository: " url \
|
2011-03-10 14:47:01 +00:00
|
|
|
" Revision: " rev "\"" >> "'"$TMPFILE"'";
|
|
|
|
print "#define SVN_REPOSITORY \"" url "\"" >> "'"$TMPFILE"'";
|
|
|
|
print "#define SVN_REVISION " rev >> "'"$TMPFILE"'";
|
2012-08-24 00:36:13 +00:00
|
|
|
print url };'`
|
2016-02-27 05:01:00 +00:00
|
|
|
echo $URL |
|
2012-08-24 00:36:13 +00:00
|
|
|
sed 's%.*://%%;s/[^/]*@//;s/[^a-zA-Z0-9]/_/g;s/__*/_/g;
|
|
|
|
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;
|
|
|
|
s/^/#define REPOSITORY_/;s/$/ 1/' >> $TMPFILE
|
2009-09-17 17:56:59 +00:00
|
|
|
else
|
2009-09-18 19:26:34 +00:00
|
|
|
echo "#include \"version.h\"" >> $TMPFILE
|
|
|
|
echo "#define SVN_VERSION BOINC_VERSION_STRING" >> $TMPFILE
|
2009-09-17 17:56:59 +00:00
|
|
|
fi
|
|
|
|
|
2009-09-18 19:26:34 +00:00
|
|
|
echo "" >> $TMPFILE
|
|
|
|
echo "#endif" >> $TMPFILE
|
|
|
|
|
|
|
|
if cmp "$HEADER" "$TMPFILE" >/dev/null 2>&1; then
|
|
|
|
rm -f "$TMPFILE"
|
|
|
|
else
|
|
|
|
mv "$TMPFILE" "$HEADER"
|
|
|
|
fi
|