From 7a7d6461dfa83ad58e63f1bdb48304deb99c23fe Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 1 Oct 2019 12:01:27 +0100 Subject: [PATCH] auto-version.in: Prefix Git version with mangled `x.y.z~' Debian version. The mangling is necessary to placate `pkg-config', which doesn't implement `rpmvercmp' properly. --- auto-version.in | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/auto-version.in b/auto-version.in index d229a29..5e0e59d 100755 --- a/auto-version.in +++ b/auto-version.in @@ -71,13 +71,15 @@ 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 - - ## If the working tree is dirty, indicate with a `+'. - case "$(git diff-index --name-only HEAD)" in - "") ;; - *) version="$version+" ;; - esac +## 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 + debver=$(sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog) + case $debver in *~) version=$debver$version ;; esac echo "$version" exit 0 fi -- 2.11.0