File: generate_svn_version.sh

package info (click to toggle)
boinc 7.14.2+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,132 kB
  • sloc: cpp: 163,589; php: 113,173; ansic: 49,284; pascal: 35,620; xml: 17,864; java: 13,521; python: 6,551; sh: 4,082; perl: 1,843; makefile: 1,796; objc: 1,543; sql: 959; csh: 126; lisp: 47
file content (65 lines) | stat: -rw-r--r-- 2,134 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash

HEADER="svn_version.h"
TMPFILE="$HEADER.tmp"

echo "#ifndef SVN_VERSION_H" > $TMPFILE
echo "#define SVN_VERSION_H" >> $TMPFILE
echo "" >> $TMPFILE

if [ -d "debian" ]; then
    CMD=""
elif [ -d .git/svn ]; then
    CMD="git svn info"
elif [ -d .git ]; then
    GIT_LOG=`git log -n1 --pretty="format:%H"`
    HOST=`hostname`
    BRANCH=`git branch | sed -n 's/^\* *//p'`
    remote=`git config --get branch.$BRANCH.remote 2>/dev/null`
    if [ "$?" != "0" ]; then
        remote="origin"
    fi
    URL=`git config --get remote.$remote.url`
    DATE=`git log -n1 --pretty="format:%ct"`
elif [ -d .svn ]; then
    CMD="svn info"
else
    CMD=""
fi

if [ "x$GIT_LOG" != "x" ]; then
    echo "#define SVN_VERSION \"$GIT_LOG [$URL] ($HOST:$PWD [$BRANCH])\"" >> $TMPFILE
    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
elif [ "x$CMD" != "x" ]; then
    LANG=C
    URL=`$CMD | awk '
                /^URL/ { url = $2; };
                /^Rev/ { rev = $2; };
                END { print "#define SVN_VERSION \"Repository: " url \
                            " Revision: " rev "\"" >> "'"$TMPFILE"'";
                      print "#define SVN_REPOSITORY \"" url "\"" >> "'"$TMPFILE"'";
                      print "#define SVN_REVISION " rev >> "'"$TMPFILE"'";
                      print url };'`
    echo $URL |
        sed 's%.*://%%;s/[^/]*@//;s/[^a-zA-Z0-9]/_/g;s/__*/_/g;
             y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;
             s/^/#define REPOSITORY_/;s/$/ 1/' >> $TMPFILE
else
    echo "#include \"version.h\"" >> $TMPFILE
    echo "#define SVN_VERSION BOINC_VERSION_STRING" >> $TMPFILE
fi

echo "" >> $TMPFILE
echo "#endif" >> $TMPFILE

if cmp "$HEADER" "$TMPFILE" >/dev/null 2>&1; then
	rm -f "$TMPFILE"
else
	mv "$TMPFILE" "$HEADER"
fi