#!/bin/sh
# Print a version string.
-scriptversion=2008-04-08.07
+scriptversion=2012-09-25.20
# Copyright (C) 2007-2008 Free Software Foundation
#
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
# It may be run two ways:
# echo $(VERSION) > $@-t && mv $@-t $@
# dist-hook:
# echo $(VERSION) > $(distdir)/.tarball-version
+# echo $(VERSION) > $(distdir)/.version
case $# in
1) ;;
tarball_version_file=$1
nl='
'
+v=
# First see if there is a tarball-only version file.
# then try "git describe", then default.
v=`cat $tarball_version_file` || exit 1
case $v in
*$nl*) v= ;; # reject multi-line output
- [0-9]*) ;;
+ [0-9]*)
+ echo "$v" | tr -d '\012'
+ exit 0
+ ;;
*) v= ;;
esac
test -z "$v" \
&& echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2
fi
+# This is presently used by the GNOME-OSTree build system; it
+# helps support the case where the meta-build system has already
+# determined the git revision, but we may not be able to run "git describe"
+# because we're inside a chroot.
+if test -n "$GIT_DESCRIBE_FOR_BUILD";
+then
+ v=$GIT_DESCRIBE_FOR_BUILD
+fi
+
if test -n "$v"
then
: # use $v
-elif test -d .git \
- && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
- || git describe --abbrev=4 HEAD 2>/dev/null` \
- && case $v in
- v[0-9]*) ;;
- *) (exit 1) ;;
- esac
+elif test -e .git \
+ && v=`git describe --abbrev=4 --match='v[0-9]*' HEAD 2>/dev/null` \
+ && [ -n "$v" ]
then
+ # If we are on a "dev" tag, we need to check that it is not the same
+ # reference as the a previous version tag (this only happens when we are
+ # working with a release tag).
+ # NB The below trick relies on the $v being an exact tag to work which
+ # will only work when HEAD == tag. When further commits have been made on top
+ # of the tag, the $v will be supplimented with the number of commits since
+ # that tag and the commit ref of the most recent commit and thus will
+ # fail the test below (as intended)
+ v2=`git describe --abbrev=4 --match='v[0-9]\.[0-9]' --contains $v 2>/dev/null | cut -d'^' -f1`
+ [ -n "$v2" ] && v=$v2
+
# Is this a new git that lists number of commits since the last
# tag or the previous older version that did not?
# Newer: v6.10-77-g0f8faeb
# v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
:
else
- v=UNKNOWN
+ echo 1>&2 "$0: Failed to determine git revision"
+ exit 1
fi
v=`echo "$v" |sed 's/^v//'`