From: Mark Wooding Date: Fri, 3 May 2024 21:51:43 +0000 (+0100) Subject: auto-version.in: Factor out Debian version checking. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/cfd/commitdiff_plain/03772523f0ce4a1f48a9b77be3bdf91cb3d8a01e?ds=sidebyside auto-version.in: Factor out Debian version checking. Also fixes a bug: we assumed that `debian/changelog' existed if we had a Git version to check. --- diff --git a/build/auto-version b/build/auto-version index 2b37944..aa9b1f6 100755 --- a/build/auto-version +++ b/build/auto-version @@ -65,6 +65,13 @@ fi ###-------------------------------------------------------------------------- ### Main program. +## 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 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 @@ -73,8 +80,7 @@ fi ## 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 + case ${debver-nil} in *~) version=$debver$version ;; esac echo "$version" exit 0 fi @@ -87,10 +93,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