-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·102 lines (88 loc) · 2.33 KB
/
version.sh
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
#!/bin/sh
ROCKS_VERSION=`cat /etc/rocks-release 2>/dev/null | awk '{print $3}'`
DESC_CMD="git describe --match 'v${ROCKS_VERSION}' 2>/dev/null | sed \"s/v\([0-9\.]*\)-*\([0-9]*\)-*\([0-9a-z]*\)/\1 \2 \3/\""
DESC=`eval ${DESC_CMD}`
#DESC=`git describe --match 'v*' 2>/dev/null | sed "s/v\([0-9\.]*\)-*\([0-9]*\)-*\([0-9a-z]*\)/\1 \2 \3/"`
if [ ! -d "./.git" ] && [ -z "${DESC}" ]
then
# Try to support using the tagged downloads
DESC=`pwd | grep -oe 'geo-roll-.\+' | sed 's/geo-roll-//g'`
LOCAL_REV="-github_archive"
fi
VERSION=`echo ${DESC} | awk '{ print $1 }' | tr "." " "`
COMMIT=`echo ${DESC} | awk '{ print $2 }'`
HASH=`echo ${DESC} | awk '{ print $3}'`
VERSION_MAJ=`echo ${VERSION} | awk '{ print $1 }'`
if [ -z "${VERSION_MAJ}" ]; then
VERSION_MAJ="0"
fi
VERSION_MIN=`echo ${VERSION} | awk '{ print $2 }'`
if [ -z "${VERSION_MIN}" ]; then
VERSION_MIN="0"
fi
VERSION_DOT=`echo ${VERSION} | awk '{ print $3 }'`
if [ -n "${VERSION_DOT}" ]; then
VERSION_DOT="."${VERSION_DOT}
fi
VERSION_REV=${COMMIT}
if [ -z "${VERSION_REV}" ]; then
VERSION_REV="0"
fi
VERSION_HASH=${HASH}
if [ -z "${VERSION_HASH}" ]; then
VERSION_HASH="g"
fi
#Allow local revision identifiers
#mimicing backports this is "-<identifier>"
if [ -e localversion ]; then
LOCAL_REV=$(cat localversion)
if [ -n "${LOCAL_REV}" ];
then
LOCAL_REV="-${LOCAL_REV}"
fi
fi
while getopts "avmndrh" opt; do
case $opt in
a)
# Major.Minor-Release.Hash
echo "${VERSION_MAJ}.${VERSION_MIN}${VERSION_DOT}-${VERSION_REV}.${VERSION_HASH}"
exit 0
;;
v)
# Major.Minor.Dot Version
echo "${VERSION_MAJ}.${VERSION_MIN}${VERSION_DOT}"
exit 0
;;
m)
# Major Version
echo "${VERSION_MAJ}"
exit 0
;;
n)
# Minor Version
echo "${VERSION_MIN}"
exit 0
;;
d)
# Dot Version
echo `echo ${VERSION_DOT} | cut -d. -f2`
exit 0
;;
r)
# Revision Version
echo "${VERSION_REV}"
exit 0
;;
h)
# Revision Hash
echo "${VERSION_REV}.${VERSION_HASH}"
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
VERSION="${VERSION_MAJ}.${VERSION_MIN}.${VERSION_REV}${LOCAL_REV}"
echo $VERSION