2005-12-27 14:40:17 -08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
GVF=GIT-VERSION-FILE
|
2013-01-02 10:44:12 -08:00
|
|
|
DEF_VER=v1.8.1.GIT
|
2005-12-27 14:40:17 -08:00
|
|
|
|
2006-08-08 13:11:16 -07:00
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2007-02-14 11: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-02 14:38:44 -08:00
|
|
|
then
|
2006-01-26 17:39:27 +01:00
|
|
|
VN=$(cat version) || VN="$DEF_VER"
|
2008-02-20 23:13:16 +01:00
|
|
|
elif test -d .git -o -f .git &&
|
2012-05-01 21:18:44 -07:00
|
|
|
VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
|
2007-02-14 11:33:04 -08:00
|
|
|
case "$VN" in
|
|
|
|
*$LF*) (exit 1) ;;
|
2008-02-16 22:44:31 -08:00
|
|
|
v[0-9]*)
|
2008-08-08 13:31:27 -07:00
|
|
|
git update-index -q --refresh
|
2008-06-28 19:13:29 +02:00
|
|
|
test -z "$(git diff-index --name-only HEAD --)" ||
|
2008-02-23 11:31:04 -08:00
|
|
|
VN="$VN-dirty" ;;
|
2007-02-14 11:33:04 -08:00
|
|
|
esac
|
|
|
|
then
|
|
|
|
VN=$(echo "$VN" | sed -e 's/-/./g');
|
2006-03-02 14:38:44 -08:00
|
|
|
else
|
|
|
|
VN="$DEF_VER"
|
2006-01-26 17:39:27 +01:00
|
|
|
fi
|
2006-01-09 18:07:01 -08:00
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
2006-01-09 14:25:10 -08:00
|
|
|
|
2005-12-27 14: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
|
|
|
|
}
|
|
|
|
|
|
|
|
|