Add version generation script, version stamp file

Use a single script to generate the version number from git. This script

  * strips the v from the start of the "git describe" output
  * changes all "-" occurences to "."
  * does NOT create a properly sortable version number from "2.1-rc2"
    type "git describe" output
  * does NOT generate a "proper" "1.2.3" type version number under any
    circumstances
  * will generate "2.1" in case the "git describe" output is "2.1"

These policy might need closer adaption to awesome's tagging habit
some time.

In dist tarballs, ship a "version-stamp" file with the package version
in it. If the "version-stamp" file is present (i.e. if it is a source
tree from a dist tarball), no git checks will be performed.

Concept from autoconf, but code written from scratch to match
awesome's requirements.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Hans Ulrich Niedermann 2008-01-14 11:31:59 +01:00 committed by Julien Danjou
parent aedfe8b665
commit eadebdd35d
4 changed files with 49 additions and 6 deletions

View File

@ -146,9 +146,12 @@ endif
dist-hook: git-version-check dist-hook: git-version-check
distcheck-hook: git-version-check distcheck-hook: git-version-check
# Note: We cannot run autogen.sh from here, because we would need some way to
# restart the whole dist process from the start and there is none.
EXTRA_DIST += build-utils/package-version
git-version-check: git-version-check:
git_ver=`{ test -d $(top_srcdir)/.git && git --git-dir=$(top_srcdir)/.git describe 2> /dev/null; } || echo devel`; \ git_ver=`$(top_srcdir)/build-utils/package-version $(top_srcdir) version-stamp`; \
if test "x$${git_ver}" = "x$(PACKAGE_VERSION)" -o "x$${git_ver}" = "xv${PACKAGE_VERSION}"; then :; else \ if test "x$${git_ver}" = "x$(PACKAGE_VERSION)"; then :; else \
echo "ERROR: The PACKAGE_VERSION and the 'git describe' version do not match:"; \ echo "ERROR: The PACKAGE_VERSION and the 'git describe' version do not match:"; \
echo " current git version: $${git_ver}"; \ echo " current git version: $${git_ver}"; \
echo " current package version: $(PACKAGE_VERSION)"; \ echo " current package version: $(PACKAGE_VERSION)"; \
@ -156,6 +159,12 @@ git-version-check:
exit 1; \ exit 1; \
fi fi
# Version stamp files can only exist in tarball source trees.
#
# So there is no need to generate them anywhere else or to clean them
# up anywhere.
dist-hook:
echo "$(PACKAGE_VERSION)" > "$(distdir)/version-stamp"
EXTRA_DIST += awesome.doxygen.in EXTRA_DIST += awesome.doxygen.in

View File

@ -7,13 +7,19 @@ srcdir=`dirname "$0"`
# sed program # sed program
SED=${SED-sed} SED=${SED-sed}
# Check whether the version needs to be updated from git infos # Check whether the version needs to be updated from VCS/version-stamp
if [ -d ".git" ] && [ -d "autom4te.cache" ]; then if [ -d ".git" ] && [ -d "autom4te.cache" ]; then
git_describe=`git describe 2>/dev/null || echo devel` git_describe=`./build-utils/package-version . version-stamp`
for f in autom4te.cache/output.*; do for f in autom4te.cache/output.*; do
[ -f "$f" ] || continue [ -f "$f" ] || continue
pkg_ver=`${SED} -n "s/^PACKAGE_VERSION='\(.*\)'\$/\1/p" "$f"` pkg_ver=`${SED} -n "s/^PACKAGE_VERSION='\(.*\)'\$/\1/p" "$f"`
[ "x$pkg_ver" = "x$git_describe" ] || rm -rf "autom4te.cache" if [ "x$pkg_ver" = "x$git_describe" ]
then :
else
echo "Cleaning out autom4te.cache (${pkg_ver} -> ${git_describe})"
rm -rf "autom4te.cache"
break
fi
done done
fi fi

22
build-utils/package-version Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# Syntax:
# $0 <path-to-top_srcdir> <version-stamp-file>
#
# <path-to-top_srcdir> may be relative
# <version-stamp-file> is relative to src/build topdir
top_srcdir="${1-.}"
test -d "$top_srcdir" || { \
echo "Could not change to top_srcdir '$1'" >&2; \
exit 1; \
}
version_stamp="${2-version-stamp}"
if test -f "$top_srcdir/$version_stamp"; then # dist source tree
cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012'
elif test -d "$top_srcdir/.git"; then # git source tree
git_describe=`${GIT-git} --git-dir="$top_srcdir/.git" describe 2>/dev/null || echo devel`
echo "$git_describe" | ${SED-sed} -e 's/^v//' -e 's/-/./g' | ${TR-tr} -d '\012'
else # ???
echo "devel" | ${TR-tr} -d '\012'
fi

View File

@ -5,7 +5,7 @@ AC_PREREQ(2.61)
dnl Each time you want an updated version number for your build, you need to dnl Each time you want an updated version number for your build, you need to
dnl (re-)run autoreconf. dnl (re-)run autoreconf.
AC_INIT([awesome window manager], AC_INIT([awesome window manager],
[m4_esyscmd([{ git describe 2>/dev/null || echo devel; } | tr -d '\n'])], [m4_esyscmd([./build-utils/package-version . version-stamp])],
[http://awesome.naquadah.org/bugs/], [http://awesome.naquadah.org/bugs/],
[awesome]) [awesome])
AC_CONFIG_AUX_DIR([auto-aux]) AC_CONFIG_AUX_DIR([auto-aux])
@ -19,6 +19,12 @@ AM_INIT_AUTOMAKE([-Wall -Werror 1.10 dist-bzip2 foreign filename-length-max=99 f
AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"]) AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"])
AC_MSG_CHECKING([package version according to autoconf])
AC_MSG_RESULT([${PACKAGE_VERSION}])
AC_MSG_CHECKING([package version according to version script])
version_script=`"${srcdir}/build-utils/package-version" "${srcdir}" version-stamp`
AC_MSG_RESULT([${version_script}])
# Checks for programs. # Checks for programs.
AC_PROG_SED AC_PROG_SED
AC_PROG_CC AC_PROG_CC