awesome/build-utils/package-version
Hans Ulrich Niedermann eadebdd35d 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>
2008-01-15 08:21:43 +01:00

22 lines
712 B
Bash
Executable file

#!/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