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.
This commit is contained in:
Lum 2026-06-28 13:20:17 +01:00
commit 69ec916c4e
5 changed files with 47 additions and 13 deletions

15
debian/rules vendored
View file

@ -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 \