2014-02-24 11:52:58 -05:00
|
|
|
#! /bin/sh
|
2013-08-06 08:29:56 -04:00
|
|
|
|
2013-09-23 18:30:39 -04:00
|
|
|
if [ ${#} -eq 1 ] && [ "x$1" = "x-r" ]; then
|
2013-08-06 08:29:56 -04:00
|
|
|
# release text only
|
|
|
|
QUIET=1
|
|
|
|
else
|
|
|
|
QUIET=0
|
|
|
|
fi
|
|
|
|
|
2013-11-23 10:43:21 -05:00
|
|
|
if ! `(git status | grep -q "On branch") 2> /dev/null`; then
|
|
|
|
# If we don't have git, we can't work out what
|
|
|
|
# version this is. It must have been downloaded as a
|
2014-02-23 04:41:47 -05:00
|
|
|
# zip file.
|
|
|
|
|
|
|
|
# If downloaded from the release page, the directory
|
|
|
|
# has the version number.
|
|
|
|
release=`pwd | sed s/.*sslh-// | grep "[[:digit:]]"`
|
|
|
|
|
|
|
|
if [ "x$release" = "x" ]; then
|
|
|
|
# If downloaded from the head, Github creates the
|
|
|
|
# zip file with all files dated from the last
|
|
|
|
# change: use the Makefile's modification time as a
|
|
|
|
# release number
|
2014-11-22 09:44:52 -05:00
|
|
|
release=head-`perl -MPOSIX -e 'print strftime "%Y-%m-%d",localtime((stat "Makefile")[9])'`
|
2014-02-23 04:41:47 -05:00
|
|
|
fi
|
2013-11-23 10:43:21 -05:00
|
|
|
fi
|
2013-08-06 08:29:56 -04:00
|
|
|
|
2013-11-23 10:43:21 -05:00
|
|
|
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
|
2013-08-06 08:29:56 -04:00
|
|
|
# generate the version info based on the tag
|
2013-11-23 10:43:21 -05:00
|
|
|
release=`(git describe --tags || git --describe || git describe --all --long) \
|
|
|
|
2>/dev/null | tr -d '\n'`
|
2013-08-06 08:29:56 -04:00
|
|
|
|
|
|
|
# Are there uncommitted changes?
|
|
|
|
git update-index --refresh --unmerged > /dev/null
|
|
|
|
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
|
|
|
|
| read dummy; then
|
2013-11-23 10:43:21 -05:00
|
|
|
release="$release-dirty"
|
2013-08-06 08:29:56 -04:00
|
|
|
fi
|
2013-11-23 10:43:21 -05:00
|
|
|
fi
|
2013-08-06 08:29:56 -04:00
|
|
|
|
2013-11-23 10:43:21 -05:00
|
|
|
|
|
|
|
if [ $QUIET -ne 1 ]; then
|
|
|
|
printf "#ifndef _VERSION_H_ \n"
|
|
|
|
printf "#define _VERSION_H_ \n\n"
|
|
|
|
printf "#define VERSION \"$release\"\n"
|
|
|
|
printf "#endif\n"
|
|
|
|
else
|
|
|
|
printf "$release\n"
|
2013-08-06 08:29:56 -04:00
|
|
|
fi
|