commit: c82a051e9031149eb51a947c951c145b3c60eab7 Author: Brian Harring <ferringb <AT> gmail <DOT> com> AuthorDate: Wed Dec 27 18:35:17 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Thu Dec 28 05:27:13 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c82a051e
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 <AT> gmail.com> Closes: https://github.com/pkgcore/pkgcore/pull/422 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcore/ebuild/cpv.py | 7 ++++++- tests/ebuild/test_cpv.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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")
