Skip to content

Commit f8299f2

Browse files
committed
deb: fix version to allow for distro upgrades
The existing version format for our packages use `distro-codename` in the version. Unfortunately, `codename` cannot be used to compare versions, which means that when a user upgrades their distro to a new version, the package won't be updated until a new release happens. This patch changes the format of the version to include `VERSION_ID`, which is numeric, and can be used in version comparison. While we're making changes, this also adds an extra `pkgRevision` number in the version, which can allow us to do a new build/release of a package in between upstream releases. This version is not yet configurable (which can be changed in future). Resulting packages are now formatted as; - name of the package (e.g., "docker-ce") - version (e.g., "22.10.6~beta.0") - "-0" (mostly "best practice", and allows updating for specific situations) - distro (e.g., "ubuntu") - VERSION_ID (e.g. "22.04" or "11") this must be "sortable" to make sure that packages are upgraded when upgrading to a newer distro version ("codename" cannot be used for this, as they're not sorted) - pkgRevision (usually "0", see above) - SUITE ("codename"), e.g. "jammy" or "bullseye". This is mostly for convenience, because some places refer to distro versions by codename, others by version. we prefix the codename with a tilde (~), which effectively excludes it from version comparison. Note that while the `${EPOCH}${EPOCH_SEP}` is part of the version, it is not included in the package's *filename*. Examples: docker-ce_22.10.6~beta.0-0~debian.11.0~bullseye_amd64.deb docker-ce_22.10.6~beta.0-0~ubuntu.22.04.0~jammy_amd64.deb Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ba44734 commit f8299f2

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

deb/build-deb

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,40 @@ debSource="$(awk -F ': ' '$1 == "Source" { print $2; exit }' debian/control)"
4343
debMaintainer="$(awk -F ': ' '$1 == "Maintainer" { print $2; exit }' debian/control)"
4444
debDate="$(date --rfc-2822)"
4545

46+
versionID="$(. /etc/os-release && echo "$VERSION_ID")"
47+
48+
# Include an extra `.0` in the version, in case we ever would have to re-build an
49+
# already published release with a packaging-only change.
50+
pkgRevision=0
51+
52+
# Generate changelog. The version/name of the generated packages are based on this.
53+
#
54+
# Resulting packages are formatted as;
55+
#
56+
# - name of the package (e.g., "docker-ce")
57+
# - version (e.g., "22.10.6~beta.0")
58+
# - "-0" (mostly "best practice", and allows updating for specific situations)
59+
# - distro (e.g., "ubuntu")
60+
# - VERSION_ID (e.g. "22.04" or "11") this must be "sortable" to make sure that
61+
# packages are upgraded when upgrading to a newer distro version ("codename"
62+
# cannot be used for this, as they're not sorted)
63+
# - pkgRevision (usually "0", see above)
64+
# - SUITE ("codename"), e.g. "jammy" or "bullseye". This is mostly for convenience,
65+
# because some places refer to distro versions by codename, others by version.
66+
# we prefix the codename with a tilde (~), which effectively excludes it from
67+
# version comparison.
68+
#
69+
# Note that while the `${EPOCH}${EPOCH_SEP}` is part of the version, it is not
70+
# included in the package's *filename*. (And if you're wondering: we needed the
71+
# EPOCH because of our use of CalVer, which made version comparing not work in
72+
# some cases).
73+
#
74+
# Examples:
75+
#
76+
# docker-ce_22.10.6~beta.0-0~debian.11.0~bullseye_amd64.deb
77+
# docker-ce_22.10.6~beta.0-0~ubuntu.22.04.0~jammy_amd64.deb
4678
cat > "debian/changelog" <<-EOF
47-
$debSource (${EPOCH}${EPOCH_SEP}${DEB_VERSION}-0~${DISTRO}-${SUITE}) $SUITE; urgency=low
79+
$debSource (${EPOCH}${EPOCH_SEP}${DEB_VERSION}-0~${DISTRO}.${versionID}.${pkgRevision}~${SUITE}) $SUITE; urgency=low
4880
* Version: $VERSION
4981
-- $debMaintainer $debDate
5082
EOF

0 commit comments

Comments
 (0)