Debian Codegraph @

build_tools/make_version

raw
1 #!/bin/sh
2
3 if [ -f ${1}/.version ]; then
4 cat ${1}/.version
5 elif [ -f ${1}/.svnrevision ]; then
6 echo SVN-`cat ${1}/.svnbranch`-r`cat ${1}/.svnrevision`
7 elif [ -d ${1}/.svn ]; then
8 PARTS=`LANG=C svn info ${1} | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/${2}/:: | sed -e 's:/: :g'`
9 BRANCH=0
10 TEAM=0
11
12 REV=`svnversion -c ${1} | cut -d: -f2`
13
14 if [ "${PARTS}" = "trunk" ]
15 then
16 echo SVN-'trunk'-r${REV}
17 exit 0
18 fi
19
20 for PART in $PARTS
21 do
22 if [ ${BRANCH} != 0 ]
23 then
24 RESULT="${RESULT}-${PART}"
25 break
26 fi
27
28 if [ ${TEAM} != 0 ]
29 then
30 RESULT="${RESULT}-${PART}"
31 continue
32 fi
33
34 if [ "${PART}" = "branches" ]
35 then
36 BRANCH=1
37 RESULT="branch"
38 continue
39 fi
40
41 if [ "${PART}" = "tags" ]
42 then
43 BRANCH=1
44 RESULT="tag"
45 continue
46 fi
47
48 if [ "${PART}" = "team" ]
49 then
50 TEAM=1
51 continue
52 fi
53 done
54
55 echo SVN-${RESULT##-}-r${REV}
56 elif [ -d ${1}/.git ]; then
57 # If the first log commit messages indicates that this is checked into
58 # subversion, we'll just use the SVN- form of the revision.
59 MODIFIED=""
60 SVN_REV=`git log --pretty=full -1 | grep -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
61 if [ -z "$SVN_REV" ]; then
62 VERSION=`git describe --tags --dirty=M 2> /dev/null | sed -e "s/^v\([0-9]\)/\1/"`
63 if [ $? -ne 0 ]; then
64 if [ "`git ls-files -m | wc -l`" != "0" ]; then
65 MODIFIED="M"
66 fi
67 # Some older versions of git do not support all the above
68 # options.
69 VERSION=GIT-`git rev-parse --short --verify HEAD`${MODIFIED}
70 fi
71 VERSION=${VERSION##*/} # Remove leading slashes: upsteram/2.10.2
72 VERSION=${VERSION#[1-9]%} # Remove 1% from tag (tag from Debian epoch)
73 echo ${VERSION}
74 else
75 PARTS=`LANG=C git log --pretty=full | grep -F "git-svn-id:" | head -1 | awk '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`
76 BRANCH=0
77 TEAM=0
78
79 if [ "`git ls-files -m | wc -l`" != "0" ]; then
80 MODIFIED="M"
81 fi
82
83 if [ "${PARTS}" = "trunk" ]; then
84 echo SVN-'trunk'-r${SVN_REV}${MODIFIED}
85 exit 0
86 fi
87
88 for PART in $PARTS
89 do
90 if [ ${BRANCH} != 0 ]; then
91 RESULT="${RESULT}-${PART}"
92 break
93 fi
94
95 if [ ${TEAM} != 0 ]; then
96 RESULT="${RESULT}-${PART}"
97 continue
98 fi
99
100 if [ "${PART}" = "branches" ]; then
101 BRANCH=1
102 RESULT="branch"
103 continue
104 fi
105
106 if [ "${PART}" = "tags" ]; then
107 BRANCH=1
108 RESULT="tag"
109 continue
110 fi
111
112 if [ "${PART}" = "team" ]; then
113 TEAM=1
114 continue
115 fi
116 done
117
118 echo SVN-${RESULT##-}-r${SVN_REV}${MODIFIED}
119 fi
120 else
121 # Use the directory information in the absence of any other version
122 # information
123 pwd -P
124 fi