From 6f75e6e6f66faa7171249e655c7f382d51a1f7a8 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 3 May 2024 22:51:43 +0100 Subject: [PATCH] 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. --- auto-version.in | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/auto-version.in b/auto-version.in index 5e0e59d..59c75c0 100755 --- a/auto-version.in +++ b/auto-version.in @@ -70,6 +70,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 @@ -78,8 +85,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+t} in t) version=$debver$version ;; esac echo "$version" exit 0 fi @@ -92,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 -- 2.11.0