On Sun, Nov 03, 20:12, Sebastian Ramacher wrote
> On 2024-11-03 17:45:16 +0100, Andre Noll wrote:
> > On Sat, Nov 02, 13:03, Sebastian Ramacher wrote
> > > new git version: 1.0.5-1+b1) sid; urgency=low, binary
> > > m4 -DGIT_VERSION=1.0.5-1+b1) sid; urgency=low, binary -DDATE="November
> > > 2024" lopsub-suite.5.m4 | gzip -fn9 > lopsub-suite.5.gz
> > > /bin/sh: 1: Syntax error: ")" unexpected
> > > make[1]: *** [Makefile:76: lopsub-suite.5.gz] Error 2
> >
> > This is caused by the weird trailing "+b1) of the version string. When
> > compiling without a git source tree the version string is extracted
> > from debian/changelog with
> >
> > sed -ne '1s/.*(\(.*\)-.*/\1/1; tx; d; :x; p' debian/changelog
>
> So that doesn't support binNMUs then. Instead of handling that with
> custom code, please check dpkg's /usr/share/dpkg/pkg-info.mk which does
> all of that and can handle binNMU versions.
Would something like the below work?
Best
Andre
---
diff --git a/debian/rules b/debian/rules
index 4f5f5ca..f31c6fe 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,6 +19,9 @@ DOCS_DIR := $(DESTDIR)/usr/share/doc/$(package)
DEVDOCS_DIR := $(DEVDIR)/usr/share/doc/$(devpackage)
TRIPLET := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+include /usr/share/dpkg/pkg-info.mk
+export DEB_VERSION
+
# activate the dh sequencer
%:
dh "$@"
@@ -26,7 +29,8 @@ TRIPLET := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
build-arch:
$(checkdir)
$(MAKE) $(shell DEB_BUILD_MAINT_OPTIONS=hardening=+all \
- dpkg-buildflags --export=cmdline)
+ dpkg-buildflags --export=cmdline) \
+ DEB_VERSION=$(DEB_VERSION)
build-indep:
build: build-indep build-arch
diff --git a/version-gen.sh b/version-gen.sh
index bdeeca2..3ec367f 100755
--- a/version-gen.sh
+++ b/version-gen.sh
@@ -2,7 +2,6 @@
version_file='version.c'
ver='unnamed_version'
-# First try git, then gitweb, then default.
if [ -e '.git' -o -e '../.git' ]; then
git_ver=$(git describe --abbrev=4 HEAD 2>/dev/null)
[ -z "$git_ver" ] && git_ver="$ver"
@@ -11,8 +10,8 @@ if [ -e '.git' -o -e '../.git' ]; then
# if there are differences (exit code 1), the working tree is dirty
git diff-index --quiet HEAD || git_ver=$git_ver-dirty
ver=$git_ver
-elif [ -f debian/changelog ]; then
- ver="$(sed -ne '1s/.*(\(.*\)-.*/\1/1; tx; d; :x; p' debian/changelog)"
+elif [ -n "$DEB_VERSION" ]; then
+ ver=$DEB_VERSION
elif [ "${PWD%%-*}" = 'lopsub-' ]; then
ver=${PWD##*/lopsub-}
fi
--
Max Planck Institute for Biology
Tel: (+49) 7071 601 829
Max-Planck-Ring 5, 72076 Tübingen, Germany
http://people.tuebingen.mpg.de/maan/