Commit | Line | Data |
---|---|---|
9b88fcef JH |
1 | #!/bin/sh |
2 | ||
3 | GVF=GIT-VERSION-FILE | |
e449f105 | 4 | DEF_VER=v1.5.6.GIT |
9b88fcef | 5 | |
c96c2909 JH |
6 | LF=' |
7 | ' | |
8 | ||
204d4092 JH |
9 | # First see if there is a version file (included in release tarballs), |
10 | # then try git-describe, then default. | |
11 | if test -f version | |
0b8b051c | 12 | then |
374dfaa2 | 13 | VN=$(cat version) || VN="$DEF_VER" |
c48799e5 | 14 | elif test -d .git -o -f .git && |
204d4092 JH |
15 | VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && |
16 | case "$VN" in | |
17 | *$LF*) (exit 1) ;; | |
e5fc9a0a | 18 | v[0-9]*) |
31e0b2ca JH |
19 | test -z "$(git diff-index --name-only HEAD)" || |
20 | VN="$VN-dirty" ;; | |
204d4092 JH |
21 | esac |
22 | then | |
23 | VN=$(echo "$VN" | sed -e 's/-/./g'); | |
0b8b051c JH |
24 | else |
25 | VN="$DEF_VER" | |
374dfaa2 | 26 | fi |
181129d2 PA |
27 | |
28 | VN=$(expr "$VN" : v*'\(.*\)') | |
eb858c60 | 29 | |
9b88fcef JH |
30 | if test -r $GVF |
31 | then | |
32 | VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) | |
33 | else | |
34 | VC=unset | |
35 | fi | |
36 | test "$VN" = "$VC" || { | |
37 | echo >&2 "GIT_VERSION = $VN" | |
38 | echo "GIT_VERSION = $VN" >$GVF | |
39 | } | |
40 | ||
41 |