Add feature modifier to versions produced from branches
[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     FEATURE=0
11
12     REV=`svnversion -c ${1} | cut -d: -f2`
13
14     INTEGRATED=`LANG=C svn pg automerge-propname ${1}`
15     if [ -z "${INTEGRATED}" ] ; then
16         INTEGRATED=svnmerge-integrated
17     fi
18
19     BASE=`LANG=C svn pg ${INTEGRATED} ${1} | cut -d: -f1`
20
21     if [ "${PARTS}" = "trunk" ] ; then
22         echo SVN-trunk-r${REV}
23         exit 0
24     fi
25
26     for PART in $PARTS ; do
27         if [ ${TAG} != 0 ] ; then
28             if [ "${PART}" = "autotag_for_be" ] ; then
29                 continue
30             fi
31             if [ "${PART}" = "autotag_for_sx00i" ] ; then
32                 continue
33             fi
34             RESULT="${PART}"
35             break
36         fi
37
38         if [ ${BRANCH} != 0 ] ; then
39             if [ -z "${RESULT}" ] ; then
40                 RESULT="${PART}"
41             else
42                 RESULT="${RESULT}-${PART}"
43             fi
44             if [ ${FEATURE} != 0 ] ; then
45                 RESULT="${RESULT}-${FEATURE_NAME}"
46             fi
47             break
48         fi
49
50         if [ ${TEAM} != 0 ] ; then
51             if [ -z "${RESULT}" ] ; then
52                 RESULT="${PART}"
53             else
54                 RESULT="${RESULT}-${PART}"
55             fi
56             continue
57         fi
58
59         if [ "${PART}" = "certified" ] ; then
60             FEATURE=1
61             FEATURE_NAME="cert"
62             continue
63         fi
64
65         if [ "${PART}" = "branches" ] ; then
66             BRANCH=1
67             RESULT="branch"
68             continue
69         fi
70
71         if [ "${PART}" = "tags" ] ; then
72             TAG=1
73             continue
74         fi
75
76         if [ "${PART}" = "team" ] ; then
77             TEAM=1
78             continue
79         fi
80     done
81
82     if [ ${TAG} != 0 ] ; then
83         echo ${RESULT}
84     else
85         echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}
86     fi
87 else
88     echo "UNKNOWN__and_probably_unsupported"
89 fi