aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2023-12-27 10:35:17 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2023-12-28 07:27:13 +0200
commitc82a051e9031149eb51a947c951c145b3c60eab7 (patch)
treed6957d575374ff49629d654ad4f066f451948171
parentfix: add atom test for 'foo/bar-11-r3' (diff)
downloadpkgcore-c82a051e9031149eb51a947c951c145b3c60eab7.tar.gz
pkgcore-c82a051e9031149eb51a947c951c145b3c60eab7.tar.bz2
pkgcore-c82a051e9031149eb51a947c951c145b3c60eab7.zip
fix: tweak CPV parsing rules to match PMS.
Bug #421 captures this; pkgcore was allowing version components as the package name if it was suffixed by a revision; the fix for that incorrectly limited a package name that has a trailing revision, but *no version syntax* in the name. This commit just refactors the revision check to also force a check for a leading version if revision-like is found. Resolves: https://github.com/pkgcore/pkgcore/issues/421 Signed-off-by: Brian Harring <ferringb@gmail.com> Closes: https://github.com/pkgcore/pkgcore/pull/422 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/pkgcore/ebuild/cpv.py7
-rw-r--r--tests/ebuild/test_cpv.py1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/pkgcore/ebuild/cpv.py b/src/pkgcore/ebuild/cpv.py
index b7149fc1e..39a0339ed 100644
--- a/src/pkgcore/ebuild/cpv.py
+++ b/src/pkgcore/ebuild/cpv.py
@@ -42,7 +42,12 @@ def isvalid_pkg_name(chunks):
# chunk, i.e. at least one hyphen
if len(chunks) == 1:
return True
- return not (isvalid_version_re.match(chunks[-1]) or isvalid_rev(chunks[-1]))
+ if isvalid_version_re.match(chunks[-1]):
+ return False
+ if len(chunks) >= 3 and isvalid_rev(chunks[-1]):
+ # if the last chunk is a revision, the proceeding *must not* be version like.
+ return not isvalid_version_re.match(chunks[-2])
+ return True
def isvalid_rev(s: str):
diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py
index 1a778a936..ae7d80260 100644
--- a/tests/ebuild/test_cpv.py
+++ b/tests/ebuild/test_cpv.py
@@ -64,6 +64,7 @@ class TestCPV:
"bah/f-100dpi",
"dev-util/diffball-blah-monkeys",
"virtual/7z",
+ "x11-drivers/xf86-video-r128",
)
good_vers = ("1", "2.3.4", "2.3.4a", "02.3", "2.03", "3d", "3D")