Merged revisions 80302 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           if [ -z ${RESULT} ]
32             then
33             RESULT="${PART}"
34           else
35             RESULT="${RESULT}-${PART}"
36           fi
37           break
38       fi
39       
40       if [ ${TEAM} != 0 ]
41           then
42           if [ -z ${RESULT} ]
43             then
44             RESULT="${PART}"
45           else
46             RESULT="${RESULT}-${PART}"
47           fi
48           continue
49       fi
50       
51       if [ "${PART}" = "branches" ]
52           then
53           BRANCH=1
54           RESULT="branch"
55           continue
56       fi
57       
58       if [ "${PART}" = "tags" ]
59           then
60           TAG=1
61           continue
62       fi
63       
64       if [ "${PART}" = "team" ]
65           then
66           TEAM=1
67           continue
68       fi
69     done
70     
71     if [ ${TAG} != 0 ]
72         then
73         echo ${RESULT}
74         else
75         echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}
76     fi
77 fi