Debian Codegraph @

contrib/packaging/packagelib.sh

raw
1 # Extract version number into 4 parts, some of which may be empty:
2 #
3 # version: the numeric part of the most recent tag. Will always look like 1.3.
4 #
5 # type: if an rc build, "rc", otherwise empty
6 #
7 # distance: the distance from the nearest tag, or empty if built from a tag
8 #
9 # node: the node|short hg was built from, or empty if built from a tag
10 gethgversion() {
11 # allow passing the version from an environment variable
12 # in case of builds on an older platform that cannot build hg
13 if [ ! -z "$USELOCALHG" ]; then
14 HG="$(which hg)"
15 version=$($HG log -r . --template "{latesttag}")
16 distance=$($HG log -r . --template "{latesttagdistance}")
17 node=$($HG log -r . --template "{node|short}")
18 return
19 fi
20 if [ -z "${1+x}" ]; then
21 python="python3"
22 else
23 python="$1"
24 fi
25 export HGRCPATH=
26 export HGPLAIN=
27
28 make cleanbutpackages PYTHON=$python
29 make local PURE=--pure PYTHON=$python
30 HG="$PWD/hg"
31
32 $python "$HG" version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; }
33
34 hgversion=`LANGUAGE=C $python "$HG" version | sed -ne 's/.*(version \(.*\))$/\1/p'`
35
36 if echo $hgversion | grep + > /dev/null 2>&1 ; then
37 tmp=`echo $hgversion | cut -d+ -f 2`
38 hgversion=`echo $hgversion | cut -d+ -f 1`
39 distance=`echo $tmp | cut -d- -f 1`
40 node=`echo $tmp | cut -d- -f 2`
41 else
42 distance=''
43 node=''
44 fi
45 if echo $hgversion | grep -E -- '[0-9]\.[0-9](\.[0-9])?rc' > /dev/null 2>&1; then
46 version=`echo $hgversion | cut -d'r' -f1`
47 type="rc`echo $hgversion | cut -d'c' -f2-`"
48 else
49 version=$hgversion
50 type=''
51 fi
52 }