Package: cc65 Version: 2.16-1 Severity: wishlist Tags: patch The build embeds the git hash of the source checkout, if it finds one, into the version string. It makes sense for upstream to see from which commit it was built, not so much in package building where it's "Git N/A" if git wasn't used for maintaining the package.
The attached patch changes it to embed the Debian package version instead to look like: % bin/cc65 --version cc65 V2.16 - Debian 2.16-1 The embedded patch to src/Makefile and src/common/version.c should be upstreamable later since it doesn't change the behaviour if the new variable PKG_VERSION isn't defined during build. -- System Information: Debian Release: buster/sid APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'unstable'), (500, 'testing'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.13.0-1-amd64 (SMP w/8 CPU cores) Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages cc65 depends on: ii libc6 2.24-17 cc65 recommends no packages. cc65 suggests no packages. -- no debconf information
diff --git a/debian/patches/package-version b/debian/patches/package-version new file mode 100644 index 0000000..10a35be --- /dev/null +++ b/debian/patches/package-version @@ -0,0 +1,47 @@ +Description: Allow overriding git hash in version string with package version + When compiling cc65, it will place the git hash of the checked out commit in + the version string which isn't useful when building a distribution package + since there either won't be an upstream git hash if there is one at all. Make + it so that if the variable PKG_VERSION is defined when building, its contents + will be placed into the version string instead of the git hash. +Author: Andreas Bombe <a...@debian.org> +Last-Update: 2017-11-16 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: cc65work/src/Makefile +=================================================================== +--- cc65work.orig/src/Makefile 2017-11-16 01:54:30.795532327 +0100 ++++ cc65work/src/Makefile 2017-11-16 02:21:19.661770273 +0100 +@@ -62,11 +62,16 @@ + endif + endif + ++ifdef PKG_VERSION ++ $(info PKG_VERSION: $(PKG_VERSION)) ++ DEF_PKGVER := -DPKG_VERSION="$(PKG_VERSION)" ++endif ++ + CFLAGS += -MMD -MP -O -I common \ + -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ + -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \ + -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) \ +- -DGIT_SHA=$(GIT_SHA) ++ -DGIT_SHA=$(GIT_SHA) $(DEF_PKGVER) + + LDLIBS += -lm + +Index: cc65work/src/common/version.c +=================================================================== +--- cc65work.orig/src/common/version.c 2017-11-16 01:54:30.815532304 +0100 ++++ cc65work/src/common/version.c 2017-11-16 02:07:10.974699766 +0100 +@@ -61,7 +61,9 @@ + /* Returns the version number as a string in a static buffer */ + { + static char Buf[60]; +-#if defined(GIT_SHA) ++#if defined(PKG_VERSION) ++ xsnprintf (Buf, sizeof (Buf), "%u.%u - %s", VER_MAJOR, VER_MINOR, STRINGIZE (PKG_VERSION)); ++#elif defined(GIT_SHA) + xsnprintf (Buf, sizeof (Buf), "%u.%u - Git %s", VER_MAJOR, VER_MINOR, STRINGIZE (GIT_SHA)); + #else + xsnprintf (Buf, sizeof (Buf), "%u.%u", VER_MAJOR, VER_MINOR); diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..b124d3e --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +package-version diff --git a/debian/rules b/debian/rules index 33e2c66..e7dd4d7 100755 --- a/debian/rules +++ b/debian/rules @@ -4,8 +4,11 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 +include /usr/share/dpkg/pkg-info.mk +include /usr/share/dpkg/vendor.mk + override_dh_auto_build: - dh_auto_build -- prefix=/usr + dh_auto_build -- prefix=/usr PKG_VERSION="$(DEB_VENDOR) $(DEB_VERSION)" $(MAKE) -C doc html override_dh_auto_install: