Merged revisions 55869 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     if [ "${PARTS}" = "trunk" ]
14         then
15         echo SVN-'trunk'-r${REV}
16         exit 0
17     fi
18     
19     for PART in $PARTS
20       do
21       if [ ${TAG} != 0 ]
22           then
23           RESULT="${PART}"
24           break
25       fi
26       
27       if [ ${BRANCH} != 0 ]
28           then
29           RESULT="${RESULT}-${PART}"
30           break
31       fi
32       
33       if [ ${TEAM} != 0 ]
34           then
35           RESULT="${RESULT}-${PART}"
36           continue
37       fi
38       
39       if [ "${PART}" = "branches" ]
40           then
41           BRANCH=1
42           RESULT="branch"
43           continue
44       fi
45       
46       if [ "${PART}" = "tags" ]
47           then
48           TAG=1
49           continue
50       fi
51       
52       if [ "${PART}" = "team" ]
53           then
54           TEAM=1
55           continue
56       fi
57     done
58     
59     if [ ${TAG} != 0 ]
60         then
61         echo ${RESULT}
62         else
63         echo SVN-${RESULT##-}-r${REV}
64     fi
65 fi