Also fixes a bug: we assumed that `debian/changelog' existed if we had a
Git version to check.
###--------------------------------------------------------------------------
### Main program.
###--------------------------------------------------------------------------
### 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
## 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
## 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
## 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
echo "$version"
exit 0
fi
fi
## If we're Debianized, then the Debian changelog ought to know.
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
## Otherwise we're screwed.
echo UNKNOWN