commit bb814ad264afb49b9c13eceeecd61b09155d09ba
parent e68f481c6e8f1d7a0f6d8649a2d12aec24be6a32
Author: Florian Dold <florian@dold.me>
Date: Fri, 5 Jun 2026 14:58:50 +0200
packaging-ng: support dev tags, generate debian changelog
Diffstat:
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/packaging/ng/buildscripts/generic b/packaging/ng/buildscripts/generic
@@ -2,12 +2,19 @@
# This file is in the public domain.
# Helper script to build the latest DEB packages in the container.
+# Supported tag syntax variants:
+# v$maj.$min$.$patch => release version
+# v$maj.$min$.$patch-dev.$n => dev version
+# deb-v$maj.$min$.$patch-$revision => release version with debian revision
+# Debian revisions of dev versions are *not* supported
+
import os
import sys
import subprocess
import glob
import shutil
import shlex
+from email.utils import formatdate
def run_cmd(cmd, shell=False, cwd=None, env=None):
"""Helper to run commands and exit on failure (mimicking set -e)."""
@@ -25,7 +32,26 @@ def get_output(cmd, shell=False, cwd=None):
"""Helper to get command output as string."""
return subprocess.check_output(cmd, shell=shell, cwd=cwd, text=True).strip()
-def make_version(deb_version, build_codename):
+def get_tag_debver(tag):
+ """Get a debian version string from a git tag"""
+ if tag.startswith("v"):
+ devsuff = "-dev."
+ d = tag.find(devsuff)
+ if d < 0:
+ return tag[1:]
+ else:
+ return tag[1:d] + "dev~" + tag[d + len(devsuff)]
+ if tag.startswith("deb-v"):
+ tag = tag[5:]
+ if "-" in tag:
+ a, b = tag.split("-")
+ return a + ":" + b
+ return tag
+ raise Error("unexpected tag format")
+
+
+
+def make_codename_version(deb_version, build_codename):
if "-" in deb_version:
# We already have a dash, thus a debian version.
# Append out build_codename to that.
@@ -84,9 +110,7 @@ def main():
build_pkg_path = os.path.join("/build", PACKAGE, DEBIANPATH)
os.chdir(build_pkg_path)
- # Get current version
- DEB_VERSION = get_output(["dpkg-parsechangelog", "-S", "Version"])
- print(f"Current version of {PACKAGE}/{DEBIANPATH} is {DEB_VERSION}")
+ DEB_VERSION = get_tag_debver(TAG)
# 3. Bootstrap and Install Deps
os.chdir(os.path.join("/build", PACKAGE))
@@ -124,22 +148,22 @@ def main():
# Because 1.2.3~trixie <= 1.2.3, version requirements in dependencies would
# not work.
- out_deb_version = make_version(DEB_VERSION, CODENAME)
+ out_deb_version = make_codename_version(DEB_VERSION, CODENAME)
print(f"Building {PACKAGE} as version {out_deb_version}", file=sys.stderr)
- # Add distro/codename specific version trailer
- if CODENAME:
- env_vars = {
- "DEBEMAIL": "deb@taler.net",
- "NAME": "Taler Packaging Team"
- }
- run_cmd([
- "dch", "-b",
- "--distribution", "unstable",
- "--newversion", out_deb_version,
- f"Build for {CODENAME}"
- ], env=env_vars)
+ debian_date = formatdate(localtime=True)
+
+ changelog = f"""\
+{PACKAGE} ({DEB_VERSION}) unstable; urgency=low
+
+ * Release {DEB_VERSION}.
+
+ -- Taler Packaging Team <deb@taler.net> {debian_date}
+"""
+
+ with open("debian/changelog", "w") as f:
+ f.write(changelog)
# 5. Build Package
run_cmd(["dpkg-buildpackage", "-rfakeroot", "-b", "-uc", "-us"])