Merged revisions 65541 via svnmerge from
[asterisk/asterisk.git] / build_tools / make_version
1 #!/bin/sh
2
3 if [ -f ${1}/.version ]; then
4         cat ${1}/.version
5 elif [ -d .svn ]; then
6     PARTS=`LANG=C svn info ${1} | grep URL | awk '{print $2;}' | sed -e 's:^.*/svn/asterisk/::' | sed -e 's:/: :g'`
7     BRANCH=0
8     TEAM=0
9     TAG=0
10     
11     REV=`svnversion -c ${1} | cut -d: -f2`
12
13     BASE=`LANG=C svn pg svnmerge-integrated ${1} | cut -d: -f1`
14     
15     if [ "${PARTS}" = "trunk" ]
16         then
17         echo SVN-'trunk'-r${REV}
18         exit 0
19     fi
20     
21     for PART in $PARTS
22       do
23       if [ ${TAG} != 0 ]
24           then
25           RESULT="${PART}"
26           break
27       fi
28       
29       if [ ${BRANCH} != 0 ]
30           then
31           RESULT="${RESULT}-${PART}"
32           break
33       fi
34       
35       if [ ${TEAM} != 0 ]
36           then
37           RESULT="${RESULT}-${PART}"
38           continue
39       fi
40       
41       if [ "${PART}" = "branches" ]
42           then
43           BRANCH=1
44           RESULT="branch"
45           continue
46       fi
47       
48       if [ "${PART}" = "tags" ]
49           then
50           TAG=1
51           continue
52       fi
53       
54       if [ "${PART}" = "team" ]
55           then
56           TEAM=1
57           continue
58       fi
59     done
60     
61     if [ ${TAG} != 0 ]
62         then
63         echo ${RESULT}
64         else
65         echo SVN-${RESULT##-}-r${REV}${BASE:+-${BASE}}
66     fi
67 fi