In http://lists.digium.com/pipermail/asterisk-dev/2007-December/031145.html,
[asterisk-bristuff.git] / build_tools / make_version
blobc69560a9520de79fc7933ea011ea6e666a7cb91f
1 #!/bin/sh
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
11 REV=`svnversion -c ${1} | cut -d: -f2`
13 BASE=`LANG=C svn pg svnmerge-integrated ${1} | cut -d: -f1`
15 if [ "${PARTS}" = "trunk" ]
16 then
17 echo SVN-trunk-r${REV}
18 exit 0
21 for PART in $PARTS
23 if [ ${TAG} != 0 ]
24 then
25 RESULT="${PART}"
26 break
29 if [ ${BRANCH} != 0 ]
30 then
31 if [ -z ${RESULT} ]
32 then
33 RESULT="${PART}"
34 else
35 RESULT="${RESULT}-${PART}"
37 break
40 if [ ${TEAM} != 0 ]
41 then
42 if [ -z ${RESULT} ]
43 then
44 RESULT="${PART}"
45 else
46 RESULT="${RESULT}-${PART}"
48 continue
51 if [ "${PART}" = "branches" ]
52 then
53 BRANCH=1
54 RESULT="branch"
55 continue
58 if [ "${PART}" = "tags" ]
59 then
60 TAG=1
61 continue
64 if [ "${PART}" = "team" ]
65 then
66 TEAM=1
67 continue
69 done
71 if [ ${TAG} != 0 ]
72 then
73 echo ${RESULT}
74 else
75 echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}