2005-12-28 06:40:17 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
GVF=GIT-VERSION-FILE
|
2018-06-26 04:22:27 +08:00
|
|
|
DEF_VER=v2.18.GIT
|
2005-12-28 06:40:17 +08:00
|
|
|
|
2006-08-09 04:11:16 +08:00
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2007-02-15 03:33:04 +08:00
|
|
|
# First see if there is a version file (included in release tarballs),
|
|
|
|
# then try git-describe, then default.
|
|
|
|
if test -f version
|
2006-03-03 06:38:44 +08:00
|
|
|
then
|
2006-01-27 00:39:27 +08:00
|
|
|
VN=$(cat version) || VN="$DEF_VER"
|
2013-06-16 07:01:11 +08:00
|
|
|
elif test -d ${GIT_DIR:-.git} -o -f .git &&
|
2016-12-05 04:45:59 +08:00
|
|
|
VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
|
2007-02-15 03:33:04 +08:00
|
|
|
case "$VN" in
|
|
|
|
*$LF*) (exit 1) ;;
|
2008-02-17 14:44:31 +08:00
|
|
|
v[0-9]*)
|
2008-08-09 04:31:27 +08:00
|
|
|
git update-index -q --refresh
|
2008-06-29 01:13:29 +08:00
|
|
|
test -z "$(git diff-index --name-only HEAD --)" ||
|
2008-02-24 03:31:04 +08:00
|
|
|
VN="$VN-dirty" ;;
|
2007-02-15 03:33:04 +08:00
|
|
|
esac
|
|
|
|
then
|
|
|
|
VN=$(echo "$VN" | sed -e 's/-/./g');
|
2006-03-03 06:38:44 +08:00
|
|
|
else
|
|
|
|
VN="$DEF_VER"
|
2006-01-27 00:39:27 +08:00
|
|
|
fi
|
2006-01-10 10:07:01 +08:00
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
2006-01-10 06:25:10 +08:00
|
|
|
|
2005-12-28 06:40:17 +08:00
|
|
|
if test -r $GVF
|
|
|
|
then
|
|
|
|
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
|
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
|
|
|
test "$VN" = "$VC" || {
|
|
|
|
echo >&2 "GIT_VERSION = $VN"
|
|
|
|
echo "GIT_VERSION = $VN" >$GVF
|
|
|
|
}
|