pre-upload: allow rust to have special virtual versions
Rust was inherited from an upstream package, and we have to use
|--no-verify| on every change at the moment. Specifically opt Rust out
of this virtual checking, since it seems to meet the criteria for having
an 'incorrect' PV.
This also makes this loop exit early, so `continue`'ing is a bit less
awkward, and to reduce nesting.
BUG=b:187743188
TEST=./pre-upload_unittest.py
Change-Id: Ib070f0ecf369cf1e37403f605e41a1be38481abb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/repohooks/+/2892117
Commit-Queue: George Burgess <gbiv@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 82ac375..36f40aa 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -1422,6 +1422,13 @@
if project.name in allowlist:
return None
+ # Per-project listings of packages with virtuals known to come from upstream
+ # Gentoo, so we shouldn't complain about them.
+ if project.name == 'chromiumos/overlays/chromiumos':
+ pkg_allowlist = ('rust',)
+ else:
+ pkg_allowlist = ()
+
# We assume the repo name is the same as the dir name on disk.
# It would be dumb to not have them match though.
project_base = os.path.basename(project.name)
@@ -1445,33 +1452,37 @@
for ebuild in ebuilds:
m = get_pv.match(ebuild)
- if m:
- overlay = m.group(1)
- if not overlay or not is_special_overlay(overlay):
- overlay = project_base
+ if not m:
+ continue
- pv = m.group(3).split('-', 1)[0]
+ overlay, package_name, pv = m.groups()
+ if package_name in pkg_allowlist:
+ continue
- # Virtual versions >= 4 are special cases used above the standard
- # versioning structure, e.g. if one has a board inheriting a board.
- if pv[0] >= '4':
- want_pv = pv
+ pv = pv.split('-', 1)[0]
+ if not overlay or not is_special_overlay(overlay):
+ overlay = project_base
+
+ # Virtual versions >= 4 are special cases used above the standard
+ # versioning structure, e.g. if one has a board inheriting a board.
+ if pv[0] >= '4':
+ want_pv = pv
+ elif is_board(overlay):
+ if is_private(overlay):
+ want_pv = '3.5' if is_variant(overlay) else '3'
elif is_board(overlay):
- if is_private(overlay):
- want_pv = '3.5' if is_variant(overlay) else '3'
- elif is_board(overlay):
- want_pv = '2.5' if is_variant(overlay) else '2'
- elif is_baseboard(overlay):
- want_pv = '1.9.5' if is_private(overlay) else '1.9'
- elif is_chipset(overlay):
- want_pv = '1.8.5' if is_private(overlay) else '1.8'
- elif is_project(overlay):
- want_pv = '1.7' if is_private(overlay) else '1.5'
- else:
- want_pv = '1'
+ want_pv = '2.5' if is_variant(overlay) else '2'
+ elif is_baseboard(overlay):
+ want_pv = '1.9.5' if is_private(overlay) else '1.9'
+ elif is_chipset(overlay):
+ want_pv = '1.8.5' if is_private(overlay) else '1.8'
+ elif is_project(overlay):
+ want_pv = '1.7' if is_private(overlay) else '1.5'
+ else:
+ want_pv = '1'
- if pv != want_pv:
- bad_ebuilds.append((ebuild, pv, want_pv))
+ if pv != want_pv:
+ bad_ebuilds.append((ebuild, pv, want_pv))
if bad_ebuilds:
# pylint: disable=C0301
diff --git a/pre-upload_unittest.py b/pre-upload_unittest.py
index 3554946..1bb63b4 100755
--- a/pre-upload_unittest.py
+++ b/pre-upload_unittest.py
@@ -1085,6 +1085,12 @@
ret = pre_upload._check_ebuild_virtual_pv(self.CHROMIUMOS_OVERLAY, 'H')
self.assertTrue(isinstance(ret, errors.HookFailure))
+ def testKnownUpstreamVirtuals(self):
+ """Known upstream packages should be exempted from these checks."""
+ self.file_mock.return_value = ['virtual/rust/rust-1.47.0-r6.ebuild']
+ ret = pre_upload._check_ebuild_virtual_pv(self.CHROMIUMOS_OVERLAY, 'H')
+ self.assertIsNone(ret)
+
def testPublicBoardVirtuals(self):
"""Public board overlays should use PV=2."""
template = 'overlay-lumpy/virtual/foo/foo-%s.ebuild'