Use the correct branch integrated property when generating the version string
[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     INTEGRATED=`LANG=C svn pg automerge-propname ${1}`
14     if [ -z "${INTEGRATED}" ] ; then
15         INTEGRATED=svnmerge-integrated
16     fi
17
18     BASE=`LANG=C svn pg ${INTEGRATED} ${1} | cut -d: -f1`
19
20     if [ "${PARTS}" = "trunk" ] ; then
21         echo SVN-trunk-r${REV}
22         exit 0
23     fi
24
25     for PART in $PARTS ; do
26       if [ ${TAG} != 0 ] ; then
27           if [ "${PART}" = "autotag_for_be" ] ; then
28               continue
29           fi
30           if [ "${PART}" = "autotag_for_sx00i" ] ; then
31               continue
32           fi
33           RESULT="${PART}"
34           break
35       fi
36
37       if [ ${BRANCH} != 0 ] ; then
38           if [ -z "${RESULT}" ] ; then
39             RESULT="${PART}"
40           else
41             RESULT="${RESULT}-${PART}"
42           fi
43           break
44       fi
45
46       if [ ${TEAM} != 0 ] ; then
47           if [ -z "${RESULT}" ] ; then
48             RESULT="${PART}"
49           else
50             RESULT="${RESULT}-${PART}"
51           fi
52           continue
53       fi
54
55       if [ "${PART}" = "branches" ] ; then
56           BRANCH=1
57           RESULT="branch"
58           continue
59       fi
60
61       if [ "${PART}" = "tags" ] ; then
62           TAG=1
63           continue
64       fi
65
66       if [ "${PART}" = "team" ] ; then
67           TEAM=1
68           continue
69       fi
70     done
71
72     if [ ${TAG} != 0 ] ; then
73         echo ${RESULT}
74     else
75         echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}
76     fi
77 else
78   echo "UNKNOWN__and_probably_unsupported"
79 fi