Files: 63a83cf0416ab89720b15a4a649786812b630b79 / genver.sh
1450 bytesRaw
1 | |
2 | |
3 | if [ ${#} -eq 1 ] && [ "x$1" = "x-r" ]; then |
4 | # release text only |
5 | QUIET=1 |
6 | else |
7 | QUIET=0 |
8 | fi |
9 | |
10 | if ! `(git status | grep -q "On branch") 2> /dev/null`; then |
11 | # If we don't have git, we can't work out what |
12 | # version this is. It must have been downloaded as a |
13 | # zip file. |
14 | |
15 | # If downloaded from the release page, the directory |
16 | # has the version number. |
17 | release=`pwd | sed s/.*sslh-// | grep "[[:digit:]]"` |
18 | |
19 | if [ "x$release" = "x" ]; then |
20 | # If downloaded from the head, Github creates the |
21 | # zip file with all files dated from the last |
22 | # change: use the Makefile's modification time as a |
23 | # release number |
24 | release=head-`perl -MPOSIX -e 'print strftime "%Y-%m-%d",localtime((stat "Makefile")[9])'` |
25 | fi |
26 | fi |
27 | |
28 | if head=`git rev-parse --verify HEAD 2>/dev/null`; then |
29 | # generate the version info based on the tag |
30 | release=`(git describe --tags || git --describe || git describe --all --long) \ |
31 | 2>/dev/null | tr -d '\n'` |
32 | |
33 | # Are there uncommitted changes? |
34 | git update-index --refresh --unmerged > /dev/null |
35 | if git diff-index --name-only HEAD | grep -v "^scripts/package" \ |
36 | | read dummy; then |
37 | release="$release-dirty" |
38 | fi |
39 | fi |
40 | |
41 | |
42 | if [ $QUIET -ne 1 ]; then |
43 | printf "#ifndef VERSION_H \n" |
44 | printf "#define VERSION_H \n\n" |
45 | printf "#define VERSION \"$release\"\n" |
46 | printf "#endif\n" |
47 | else |
48 | printf "$release\n" |
49 | fi |
50 |
Built with git-ssb-web