scriptversion=2011-02-19.19; # UTC
# Copyright (C) 2007-2011 Free Software Foundation, Inc.
+# Copyright (C) 2011-2021 Karel Zak <kzak@redhat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# - from a git repository in which the "git describe" command below
# produces useful output (thus requiring at least one signed tag)
# - from a non-git-repo directory containing a .tarball-version file, which
-# presumes this script is invoked like "./git-version-gen .tarball-version".
+# presumes this script is invoked like "./git-version-gen [.tarball-version]".
-# In order to use intra-version strings in your project, you will need two
-# separate generated version string files:
+# In order to use intra-version strings in your project, you will need:
#
# .tarball-version - present only in a distribution tarball, and not in
# a checked-out repository. Created with contents that were learned at
# files to pick up a version string change; and leave it stale to
# minimize rebuild time after unrelated changes to configure sources.
#
+# NEWS - present everywhere. It's used only as a fallback solution for
+# 3rd-party tarballs generated by the unofficial way (e.g. GitHub).
+# The version string is read from the first line of the file, the expected
+# format is "project-name version: date".
+#
# It is probably wise to add these two files to .gitignore, so that you
# don't accidentally commit either generated file.
#
# echo $(VERSION) > $(distdir)/.tarball-version
case $# in
- 1|2) ;;
- *) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version" \
- '[TAG-NORMALIZATION-SED-SCRIPT]'
+ 0|1|2) ;;
+ *) echo 1>&2 "Usage: $0 [[\$srcdir/.tarball-version]" \
+ '[TAG-NORMALIZATION-SED-SCRIPT]]'
exit 1;;
esac
-tarball_version_file=$1
+tarball_version_file=${1:-".tarball-version"}
tag_sed_script="${2:-s/x/x/}"
nl='
'
esac
v_from_git=1
else
- v=UNKNOWN
+ if test -f NEWS
+ then
+ v=`sed '1s/.*[[:blank:]]\(.*\):.*/\1/; q;' NEWS`
+ else
+ v=UNKNOWN
+ fi
fi
v=`echo "$v" |sed 's/^v//'`