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