From 69ec916c4e6cb2f49186d45823decb276ec16ffc Mon Sep 17 00:00:00 2001 From: Lum Date: Sun, 28 Jun 2026 13:20:17 +0100 Subject: [PATCH] packaging: derive Debian version from POSTIT_GIT_TAG via a changelog template The .deb was hardcoded to 1.0.0-1 in debian/changelog regardless of POSTIT_GIT_TAG, so 'make POSTIT_GIT_TAG=1.0.1-rc01' produced a postit_1.0.0-1_amd64.deb (wrong name) and the trailing mv into POSTIT_OUT_DIR silently fell back to the same wrong-name glob. Move the version into a @VERSION@-bearing debian/changelog.in template and render debian/changelog from it in the Makefile, before dpkg-buildpackage runs (it reads debian/changelog during dpkg-source --before-build, before any rule fires). debian/changelog is .gitignored; the template is the source of truth. debian/rules re-renders the changelog as a safety net for direct dpkg-buildpackage invocations and adds it to override_dh_auto_clean so partial builds leave no stale rendered file behind. --- .gitignore | 6 ++++++ Makefile | 15 ++++++++++++++- debian/changelog | 11 ----------- debian/changelog.in | 13 +++++++++++++ debian/rules | 15 ++++++++++++++- 5 files changed, 47 insertions(+), 13 deletions(-) delete mode 100644 debian/changelog create mode 100644 debian/changelog.in diff --git a/.gitignore b/.gitignore index aa3f2b1..7b7222f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,12 @@ debian/debhelper-build-stamp debian/postit.debhelper.log debian/postit.substvars +# Generated from debian/changelog.in at the start of every build +# (see debian/rules and the Makefile). Versioned template is +# changelog.in; the rendered file is not tracked because it changes +# with POSTIT_GIT_TAG on every build. +debian/changelog + # Staging tree for dh_install debian/tmp/ diff --git a/Makefile b/Makefile index 55a5366..2e3a50e 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,23 @@ POSTIT_OUT_DIR ?= $(CURDIR)/.. .PHONY: deb clean source deb: + @echo " POSTIT_GIT_TAG=$(POSTIT_GIT_TAG) POSTIT_RUNTIME=$(POSTIT_RUNTIME) POSTIT_GIT_URL=$(POSTIT_GIT_URL)" + # Render debian/changelog from debian/changelog.in so the package + # version follows the upstream tag, not the version pinned in the + # repo. dpkg-buildpackage reads debian/changelog before any rule + # runs (in dpkg-source --before-build), so the template must be + # expanded in the Makefile, not in debian/rules. Without this + # step the .deb always comes out as the version hardcoded in + # debian/changelog.in, regardless of POSTIT_GIT_TAG. + sed 's/@VERSION@/$(POSTIT_GIT_TAG)/g' debian/changelog.in > debian/changelog POSTIT_GIT_URL=$(POSTIT_GIT_URL) POSTIT_GIT_TAG=$(POSTIT_GIT_TAG) POSTIT_RUNTIME=$(POSTIT_RUNTIME) \ dpkg-buildpackage -us -uc -b - mv ../postit_*$(POSTIT_GIT_TAG)*.deb $(POSTIT_OUT_DIR)/ 2>/dev/null || \ + # Move the produced .deb(s) into $POSTIT_OUT_DIR. The version + # segment we match against is the rendered changelog version + # (e.g. 1.0.1-rc01-1), not the bare tag. + mv ../postit_*$(POSTIT_GIT_TAG)-1*.deb $(POSTIT_OUT_DIR)/ 2>/dev/null || \ mv ../postit_*.deb $(POSTIT_OUT_DIR)/ || true + @echo " ✓ artifacts moved to $(POSTIT_OUT_DIR)" clean: rm -rf build debian/postit diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 2152a9d..0000000 --- a/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -postit (1.0.0-1) trixie; urgency=medium - - * Initial release. - * Built from the pazof/yavsc repository at the tag 1.0.0. - * Packages PostIt.Desktop (Avalonia 12) as a Debian package - named `postit`, exposing the command `postit` on PATH. - * Registers the postit:// URI scheme as an XDG MIME handler so - that xdg-open postit://... launches the freshly installed - client. - - -- Paul Schneider Sat, 28 Jun 2026 00:01:00 +0100 diff --git a/debian/changelog.in b/debian/changelog.in new file mode 100644 index 0000000..502538d --- /dev/null +++ b/debian/changelog.in @@ -0,0 +1,13 @@ +postit (@VERSION@-1) trixie; urgency=medium + + * Built from pazof/yavsc at tag @VERSION@. + * Packaged as a Debian binary package named `postit`, exposing the + `postit` command on PATH. Registers the postit:// URI scheme as + an XDG MIME handler so xdg-open postit://... launches the freshly + installed client. + * The Debian revision (`-1`) is fixed: postit-debian tracks the + packaging itself, the upstream semantic version is whatever tag + we point POSTIT_GIT_TAG at. Bump the template (or its rendered + form) only when the packaging actually changes. + + -- Paul Schneider Sat, 28 Jun 2026 00:01:00 +0100 diff --git a/debian/rules b/debian/rules index 0232fe1..4fe821a 100755 --- a/debian/rules +++ b/debian/rules @@ -39,9 +39,22 @@ ICON_SIZES := 16 32 48 64 128 256 dh $@ override_dh_auto_clean: - rm -rf $(POSTIT_BUILD_DIR) $(POSTIT_TMP) + rm -rf $(POSTIT_BUILD_DIR) $(POSTIT_TMP) $(CURDIR)/debian/changelog override_dh_auto_build: + # The rendered changelog (debian/changelog) is generated from + # debian/changelog.in by the Makefile *before* dpkg-buildpackage + # runs, because dpkg-buildpackage reads debian/changelog before + # any rule (in dpkg-source --before-build) and would fail with + # "changelog missing" if it were not present. If somebody invokes + # dpkg-buildpackage directly without going through the Makefile + # (rare, but cheap to guard against), render the changelog on + # the fly from the current POSTIT_GIT_TAG so the package still + # builds and ships the right version. + if [ ! -f $(CURDIR)/debian/changelog ] && [ -f $(CURDIR)/debian/changelog.in ]; then \ + sed 's/@VERSION@/$(POSTIT_GIT_TAG)/g' \ + $(CURDIR)/debian/changelog.in > $(CURDIR)/debian/changelog; \ + fi # 1. Fetch the upstream source. mkdir -p $(POSTIT_BUILD_DIR) if [ -d $(POSTIT_SRC_DIR) ]; then \