2008-07-24 00:12:13 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# determine-version -- report a useful version for releases
|
|
|
|
#
|
|
|
|
# Copyright 2008, Aron Griffis <agriffis@n01se.net>
|
|
|
|
# Copyright 2008, Oracle
|
|
|
|
# Released under the GNU GPLv2
|
|
|
|
|
2015-05-20 21:12:44 +08:00
|
|
|
v="v4.0.1"
|
2008-07-24 00:12:13 +08:00
|
|
|
|
2014-12-04 20:26:46 +08:00
|
|
|
opt=$1
|
2013-06-03 20:31:41 +08:00
|
|
|
|
2008-08-21 08:11:22 +08:00
|
|
|
which git &> /dev/null
|
|
|
|
if [ $? == 0 -a -d .git ]; then
|
|
|
|
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
|
|
|
|
if tag=`git describe --tags 2>/dev/null`; then
|
|
|
|
v="$tag"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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
|
|
|
|
v="$v"-dirty
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-12-04 20:26:46 +08:00
|
|
|
if [ "$opt" = "--configure" ]; then
|
|
|
|
# Omit the trailing newline, so that m4_esyscmd can use the result directly.
|
2015-02-13 21:49:31 +08:00
|
|
|
echo -n "$v"
|
2014-12-09 22:58:11 +08:00
|
|
|
else
|
|
|
|
echo "$v"
|
2014-12-04 20:26:46 +08:00
|
|
|
fi
|
|
|
|
|
2014-12-09 22:58:11 +08:00
|
|
|
exit 0
|
2008-07-24 00:12:13 +08:00
|
|
|
|