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