Merge ~jslarraz/ubuntu-security-tools:fix-increment-version into ubuntu-security-tools:master

Proposed by Jorge Sancho Larraz
Status: Merged
Approved by: Eduardo Barretto
Approved revision: 3f4d285f1a432215ec99f58f3fe803159a86ff90
Merged at revision: d97cb07d2246f9fbb35e6b322a8fe5be32274019
Proposed branch: ~jslarraz/ubuntu-security-tools:fix-increment-version
Merge into: ubuntu-security-tools:master
Diff against target: 75 lines (+16/-15)
3 files modified
build-tools/umt (+0/-12)
package-tools/increment_version.py (+11/-3)
package-tools/test_increment_version.py (+5/-0)
Reviewer Review Type Date Requested Status
Eduardo Barretto Approve
Review via email: mp+461971@code.launchpad.net

Commit message

umt/increment_version: fix regex for ~XX.YY versions

To post a comment you must log in.
Revision history for this message
Ian Constantin (iconstantin) wrote :

The changes lgtm re: what we discussed in sec-priv, thanks!

Revision history for this message
Eduardo Barretto (ebarretto) wrote :

lgtm!
I just added a comment, but that could be added to this PR or added later directly.

review: Approve
Revision history for this message
Jorge Sancho Larraz (jslarraz) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/build-tools/umt b/build-tools/umt
index b76e9d6..7382143 100755
--- a/build-tools/umt
+++ b/build-tools/umt
@@ -5623,18 +5623,6 @@ def launch_dch(old_ver, new_ver, release=None, note=None, is_devel_release=False
5623 warn("Suggestion is not valid if releases have the same previous version\n" +5623 warn("Suggestion is not valid if releases have the same previous version\n" +
5624 "Use '%s' style instead\n" % (re.sub('build.*', '', old_ver) + 'ubuntu0.Y.MM.1'))5624 "Use '%s' style instead\n" % (re.sub('build.*', '', old_ver) + 'ubuntu0.Y.MM.1'))
56255625
5626 release_name = None
5627 release_num = None
5628 if "security" in release:
5629 release_name = release.split("-")[0]
5630
5631 if release_name:
5632 release_num = BetterUbuntuDistroInfo().get_release(release_name)
5633
5634 if release_num:
5635 if release_num == old_ver[-5:]:
5636 new_ver = old_ver+".1"
5637
5638 if is_devel_release and not build:5626 if is_devel_release and not build:
5639 command = ['/usr/bin/dch', '-i']5627 command = ['/usr/bin/dch', '-i']
5640 else:5628 else:
diff --git a/package-tools/increment_version.py b/package-tools/increment_version.py
index 8fa2669..e56dc1e 100644
--- a/package-tools/increment_version.py
+++ b/package-tools/increment_version.py
@@ -157,20 +157,28 @@ def increment_version_security(old_version, esm=False, devel=False, details=None
157 new_version = old_version + suffix157 new_version = old_version + suffix
158 if esm:158 if esm:
159 new_version = new_version + "~esm1"159 new_version = new_version + "~esm1"
160 elif re.search("~([0-9]+\\.)?([0-9]{2}\\.[0-9]{2})(\\.[0-9]+)$", old_version):160 elif re.search("~([0-9]+\\.)?([0-9]{2}\\.[0-9]{2})(\\.[0-9]+)?$", old_version):
161 # eg. ~XX.YY ~XX.YY.1, ~0.XX.YY.1161 # eg. ~XX.YY ~XX.YY.1, ~0.XX.YY.1
162 if devel:162 if devel:
163 new_version = increment_version_security(old_version.split("~")[0], esm=esm, devel=devel)163 new_version = increment_version_security(old_version.split("~")[0], esm=esm, devel=devel)
164 else:164 else:
165 split = old_version.split(".")165 # Intentionally not handling potential errors with details["release"] not in subprojects
166 if len(split) == 2:166 # or release_name.split(' ')[1] being len 1. It should not happen. If it crash we will
167 # have the chance to look at the code instead of proposing a wrong version
168 release_name = cve_lib.subprojects['ubuntu/' + details["release"]]['name']
169 release_id = release_name.split(' ')[1]
170
171 # Handle ~XX.YY and ~0.XX.YY
172 if old_version.endswith(release_id):
167 new_version = old_version + ".1"173 new_version = old_version + ".1"
168 if esm:174 if esm:
169 new_version = new_version + "~esm1"175 new_version = new_version + "~esm1"
176 # Handle ~0.XX.YY.1
170 else:177 else:
171 if esm:178 if esm:
172 new_version = old_version + "+esm1"179 new_version = old_version + "+esm1"
173 else:180 else:
181 split = old_version.split(".")
174 new_version = re.sub(182 new_version = re.sub(
175 "\\.[0-9]+$", "." + str(int(split[len(split) - 1]) + 1), old_version183 "\\.[0-9]+$", "." + str(int(split[len(split) - 1]) + 1), old_version
176 )184 )
diff --git a/package-tools/test_increment_version.py b/package-tools/test_increment_version.py
index bebc5b0..6065217 100755
--- a/package-tools/test_increment_version.py
+++ b/package-tools/test_increment_version.py
@@ -46,6 +46,11 @@ class TestIncrementVersion(unittest.TestCase):
46 TC("2.0cvs.20060707-2", "2.0cvs.20060707-2ubuntu1", devel=True),46 TC("2.0cvs.20060707-2", "2.0cvs.20060707-2ubuntu1", devel=True),
47 TC("2.0-2ubuntu0.1~esm9", "2.0-2ubuntu0.1~esm10", esm=True),47 TC("2.0-2ubuntu0.1~esm9", "2.0-2ubuntu0.1~esm10", esm=True),
48 TC("2.1.0-3build2~16.04.1", "2.1.0-3ubuntu0.1~esm1", esm=True),48 TC("2.1.0-3build2~16.04.1", "2.1.0-3ubuntu0.1~esm1", esm=True),
49 TC("2.1.0-1~0.16.04", "2.1.0-1~0.16.04.1", esm=False, details={'release': 'xenial'}),
50 TC("2.1.0-1~16.04", "2.1.0-1~16.04.1", esm=False, details={'release': 'xenial'}),
51 TC("2.1.0-1~16.04.1", "2.1.0-1~16.04.2", esm=False, details={'release': 'xenial'}),
52 TC("2.1.0-1~16.04", "2.1.0-1~16.04.1~esm1", esm=True, details={'release': 'xenial'}),
53 TC("2.1.0-1~16.04.1~esm1", "2.1.0-1~16.04.1~esm2", esm=True, details={'release': 'xenial'}),
49 TC("4.3-1", "4.3-1ubuntu0.1", details={'package': 'plib', 'release': 'focal'},54 TC("4.3-1", "4.3-1ubuntu0.1", details={'package': 'plib', 'release': 'focal'},
50 pkg_list={'focal': ['4.3-1', '', ''], 'jammy': ['4.3-2', '', '']},55 pkg_list={'focal': ['4.3-1', '', ''], 'jammy': ['4.3-2', '', '']},
51 msg="The exact same version is not used in other releases (debian build changes)"),56 msg="The exact same version is not used in other releases (debian build changes)"),

Subscribers

People subscribed via source and target branches