forked from nevali/m4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-version.sh
More file actions
executable file
·84 lines (76 loc) · 2.25 KB
/
Copy pathget-version.sh
File metadata and controls
executable file
·84 lines (76 loc) · 2.25 KB
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
#! /bin/sh
## Copyright 2014 BBC.
##
## Copyright 2014 Mo McRoberts.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## To use this script, structure your AC_INIT as follows:
## AC_INIT([package-name],m4_esyscmd([/bin/sh m4/get-version.sh]),[bug-report],[tar-name],[url])
## Always use a .release file if present
if test -r .release ; then
version="`head -1 .release`"
if ! test x"$version" = x"" ; then
printf "%s" "$version"
exit 0
fi
fi
## If we are autobuilding, use the supplied version
if ! test x"$GIT_BUILD_VERSION" = x"" ; then
echo -n "$GIT_BUILD_VERSION"
exit 0
fi
version=""
suffix=""
dirty=""
now=`date +%y%m%d`
if `git rev-parse --git-dir >/dev/null 2>&1` ; then
HEAD=`git rev-parse HEAD 2>/dev/null | cut -c1-7`
[ x"$HEAD" = x"HEAD" ] && HEAD=""
if [ -z "$HEAD" ] ; then
suffix="~$now"
dirty=".dirty"
else
tags="`git describe --tags --exact-match $HEAD 2>/dev/null`"
vertag=""
if [ -n "$tags" ] ; then
for tag in $tags ; do
case "$tag" in
upstream/[0-9]*)
vertag="`echo $tag | sed -e 's!^upstream/!!' -e 's!-.*$!!'`"
;;
debian/[0-9]*)
vertag="`echo $tag | sed -e 's!^debian/!!' -e 's!-.*$!!'`"
;;
[0-9]*)
vertag="`echo $tag | sed -e 's!-.*$!!'`"
;;
r[0-9]*)
vertag="`echo $tag | sed -e 's!^r!!' -e 's!-.*$!!'`"
;;
v[0-9]*)
vertag="`echo $tag | sed -e 's!^v!!' -e 's!-.*$!!'`"
;;
esac
done
fi
git update-index --refresh -q >/dev/null
dirty=`git diff-index --name-only HEAD 2>/dev/null`
[ -n "$dirty" ] && dirty=".dirty"
[ -n "$vertag" ] && version="$vertag"
if [ -z "$vertag" ] || [ -n "$dirty" ] ; then
suffix="~$now.$HEAD"
fi
fi
fi
[ -z "$version" ] && version="0.0"
printf "%s%s%s" "$version" "$suffix" "$dirty"