X-Git-Url: https://git.distorted.org.uk/~mdw/cfd/blobdiff_plain/399c828727e81f39fc7c4139f68dd8044e0a2b04..refs/heads/master:/auto-version.in diff --git a/auto-version.in b/auto-version.in index d229a29..007da8b 100755 --- a/auto-version.in +++ b/auto-version.in @@ -1,7 +1,7 @@ #! /bin/sh ### -*-sh-*- ### -### Make autoconf-like substitutions in files +### Guess at the project's version number ### ### (c) 2008 Mark Wooding ### @@ -70,14 +70,22 @@ fi ###-------------------------------------------------------------------------- ### Main program. -## If this is a Git checkout then Git should be able to identify the version. -if [ -e .git ] && version=$(git describe --abbrev=4 2>/dev/null); then +## Get the Debian version, if there is one. +if [ -f debian/changelog ]; then + debver=$(sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog) +else + unset debver +fi - ## If the working tree is dirty, indicate with a `+'. - case "$(git diff-index --name-only HEAD)" in - "") ;; - *) version="$version+" ;; - esac +## If this is a Git checkout then Git should be able to identify the version. +## If there's also a Debian version, and that ends in a `~', then prefix the +## Git version with this. Note that `pkg-config' is not very good, and, in +## particular, doesn't support the convention that `~' sorts before anything +## else, even the empty string, despite claiming to implement the RPM +## version-comparison algorithm which specifies this behaviour, so one must +## be careful when choosing `~' prefixes. +if [ -e .git ] && version=$(git describe --abbrev=4 --dirty=+ 2>/dev/null); then + case ${debver-nil} in *~) version=$debver$version ;; esac echo "$version" exit 0 fi @@ -90,10 +98,9 @@ if [ -f RELEASE ]; then fi ## If we're Debianized, then the Debian changelog ought to know. -if [ -f debian/changelog ]; then - sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog - exit 0 -fi +case ${debver+t} in + t) echo "$debver"; exit 0 ;; +esac ## Otherwise we're screwed. echo UNKNOWN