← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~smoser/cloud-init:tools/bddeb-per-release-suffix-in-version into cloud-init:master

 

Scott Moser has proposed merging ~smoser/cloud-init:tools/bddeb-per-release-suffix-in-version into cloud-init:master.

Commit message:
tools: Support adding a release suffix through packages/bddeb.

bddeb already supported passing in a '--release' and that would get into the
changelog line.

If you used bddeb to build packages for a PPA, and built multiple releases,
then you would get the same version for each release, and launchpad
would reject your upload.

The change here means we get a ~16.04.1 (for xenial) suffix on the dpkg
version.  If the distro-info-data package is not installed, or
the release is not known "UNRELEASED", then you get no suffix.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/344544

see commit message
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:tools/bddeb-per-release-suffix-in-version into cloud-init:master.
diff --git a/packages/bddeb b/packages/bddeb
index 4f2e2dd..0faeb51 100755
--- a/packages/bddeb
+++ b/packages/bddeb
@@ -28,6 +28,23 @@ if "avoid-pep8-E402-import-not-top-of-file":
 DEBUILD_ARGS = ["-S", "-d"]
 
 
+def get_release_suffix(release):
+    """Given ubuntu release (xenial), return a suffix for package (~16.04.1)"""
+    csv_path = "/usr/share/distro-info/ubuntu.csv"
+    rels = {}
+    # fields are version, codename, series, created, release, eol, eol-server
+    if os.path.exists(csv_path):
+        with open(csv_path, "r") as fp:
+            data = fp.read()
+        for line in data.splitlines():
+            fields = line.split(",")
+            # version has "16.04 LTS" or "16.10"
+            rels[fields[2]] = fields[0].split()[0]
+    if release in rels:
+        return "~%s.1" % rels[release]
+    return ""
+
+
 def run_helper(helper, args=None, strip=True):
     if args is None:
         args = []
@@ -148,7 +165,10 @@ def main():
     if args.verbose:
         capture = False
 
-    templ_data = {'debian_release': args.release}
+    templ_data = {
+        'debian_release': args.release,
+        'release_suffix': get_release_suffix(args.release)}
+
     with temp_utils.tempdir() as tdir:
 
         # output like 0.7.6-1022-g36e92d3
diff --git a/packages/debian/changelog.in b/packages/debian/changelog.in
index bdf8d56..930322f 100644
--- a/packages/debian/changelog.in
+++ b/packages/debian/changelog.in
@@ -1,5 +1,5 @@
 ## template:basic
-cloud-init (${version_long}-1~bddeb) ${debian_release}; urgency=low
+cloud-init (${version_long}-1~bddeb${release_suffix}) ${debian_release}; urgency=low
 
   * build
 

Follow ups