1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#!/bin/sh
# determines the version of the sources
# usage: version <source directory>
#set -x
srcdir="$1"
# set version parts to defaults for CVS snapshot
major_version=`cat ${srcdir}/major_version`
DATE=`date +%Y%m%d`
#echo $major_version
#echo $minor_version
if test -d "${srcdir}/CVS"; then
# get the date/branch/version tag
rawtag=`cat ${srcdir}/CVS/Entries | grep major_version | sed -e "s,/major_version/.*/.*/.*/,,"`
#echo $rawtag
# determine the type of the tag
echo $rawtag | grep "^D" > /dev/null && tagtype=D
#echo $rawtag | grep "^Tb" > /dev/null && tagtype=Tb
echo $rawtag | grep "^Tv" > /dev/null && tagtype=Tv
#echo $tagtype
# extract the raw tag
tag=`echo $rawtag | sed -e "s,^$tagtype,,"`
#echo $tag
# date tag: make it a date dagged alpha release
if test "$tagtype" = D; then
DATE=`echo $tag | sed -e "s,\...\...\...\$,," | sed -e "s,\.,,g"`
minor_version=`cat ${srcdir}/minor_version | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
fi
# version tag: take whole version, replace _[number] with .[number]
if test "$tagtype" = Tv; then
major_version=`echo $tag | sed -e "s,_\([0-9]\),\.\\1,g"`
minor_version=""
DATE=""
fi
fi
if test -d "${srcdir}/.svn"; then
# get the inter-repository path by parsing the URL
URL=`svn info ${srcdir} | grep ^URL | sed -e 's,^URL: ,,'`
# uncomment the followint URLs to test various cases
# trunk
# URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/trunk/armagetronad
# branch 0.4
# URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/branches/0.4/armagetronad
# tag 0.2.8.2
# URL=https://svn.sourceforge.net/svnroot/armagetronad/armagetronad/tags/0.2.8.2/armagetronad
#echo URL=$URL
REPOPATH=`echo $URL | sed -e 's,/armagetronad$,,' -e 's,.*/armagetronad/,,'`
#echo REPOPATH=$REPOPATH
# is it a tag?
if echo $REPOPATH | grep '^tags/' > /dev/null; then
# echo Tag
major_version=`echo $REPOPATH | sed -e 's,^tags/,,'`
minor_version=""
DATE=""
else
# is it a branch?
if echo $REPOPATH | grep '^branches/' > /dev/null; then
# echo Branch
major_version=`echo $REPOPATH | sed -e 's,^branches/,,'`
fi
# trunk or branch
# make revision the alpha tag (activate later, not in 0.2.8 branch)
# REVISION=`svn info ${srcdir} | grep ^Revision | sed -e 's,^Revision: ,,'`
# echo REVISION=$REVISION
# minor_version=_alpha$REVISION
# DATE=""
fi
fi
# *TODO* once we get our superproject up on launchpad (and thus get saner branch nicks), use branch nicks for $major_version
# Check if bzr is installed, and if the path is versionned
bzr >/dev/null 2>&1
# But for now, ignore it
#if test $? -eq 0
if test 1 -eq 0
then
bzr diff ${srcdir} --quiet >/dev/null 2>&1
# Test for the return code of bzr diff (see bzr diff --help)
if test $? -eq 0
then
# If no change was made, use revision number
# but first check if it's tagged
revno=$(bzr revno ${srcdir})
tag=$(bzr tags | grep -P "^(.*?) +${revno}$" | awk '{ print $1 }')
if test $tag
then
# If it is tagged, use the tag
DATE=_$tag
else
# If not, use revision number
DATE=_r$(bzr revno ${srcdir})
fi
elif test $? -lt 3
then
# If a change was made, use revision number plus build date
DATE=_r$(bzr revno ${srcdir})_$DATE
# It returns 3 if it's not versionned, so forget it
fi
fi
if test -z "$minor_version"
then
test -z "$DATE" || minor_version=`cat ${srcdir}/minor_version | sed -e "s,DATE,$DATE," -e "s,YYYYMMDD,$DATE,"`
fi
echo $major_version$minor_version
|