From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.77) (envelope-from ) id 1SradI-0003Y8-Ci for garchives@archives.gentoo.org; Wed, 18 Jul 2012 20:14:04 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6F437E0767; Wed, 18 Jul 2012 19:55:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3097AE0767 for ; Wed, 18 Jul 2012 19:55:29 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 701EA1B4060 for ; Wed, 18 Jul 2012 19:55:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 29E3EE5434 for ; Wed, 18 Jul 2012 19:55:27 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1342641316.3e84557b91b43ea6924bbab8a3d477509513cac8.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: man/, pym/portage/dep/, pym/portage/tests/dep/ X-VCS-Repository: proj/portage X-VCS-Files: man/portage.5 pym/portage/dep/__init__.py pym/portage/tests/dep/testAtom.py pym/portage/tests/dep/test_best_match_to_list.py X-VCS-Directories: man/ pym/portage/dep/ pym/portage/tests/dep/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 3e84557b91b43ea6924bbab8a3d477509513cac8 X-VCS-Branch: master Date: Wed, 18 Jul 2012 19:55:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: ef2484af-3699-4550-9f95-5f2c9dc171ec X-Archives-Hash: 20253731c303bcf71362b4855533cfbc commit: 3e84557b91b43ea6924bbab8a3d477509513cac8 Author: Zac Medico gentoo org> AuthorDate: Wed Jul 18 19:55:16 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Jul 18 19:55:16 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D3e84557b Support =3D*/*-*9999* wildcard atom, bug #402197. --- man/portage.5 | 3 + pym/portage/dep/__init__.py | 75 ++++++++++++++++= +---- pym/portage/tests/dep/testAtom.py | 4 + pym/portage/tests/dep/test_best_match_to_list.py | 2 + 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/man/portage.5 b/man/portage.5 index 9823eb1..ad84ff1 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -162,6 +162,9 @@ next to each other. =20 .I Examples: .nf +# match anything with a version containing 9999, which can be used in +# package.mask to prevent emerge --autounmask from selecting live ebuild= s +=3D*/*-*9999* # match anything from the 'sys\-apps' category sys\-apps/* # match packages named 'zlib' from any category diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index f0d07a5..8286e8d 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -141,9 +141,10 @@ def _get_atom_wildcard_re(eapi_attrs): else: pkg_re =3D r'[\w+*][\w+*-]*?' =20 - atom_re =3D re.compile(r'(?P(' + - _extended_cat + r')/(' + pkg_re + - r'))(:(?P' + _slot_loose + r'))?(' + + atom_re =3D re.compile(r'((?P(' + + _extended_cat + r')/(' + pkg_re + r'))' + \ + '|(?P=3D((' + _extended_cat + r')/(' + pkg_re + r'))-(?P\*\d+\*)))' + \ + '(:(?P' + _slot_loose + r'))?(' + _repo_separator + r'(?P' + _repo_name + r'))?$') =20 _atom_wildcard_re_cache[cache_key] =3D atom_re @@ -1243,18 +1244,27 @@ class Atom(_unicode): self.__dict__['blocker'] =3D blocker m =3D atom_re.match(s) extended_syntax =3D False + extended_version =3D None if m is None: if allow_wildcard: - m =3D _get_atom_wildcard_re(eapi_attrs).match(s) + atom_re =3D _get_atom_wildcard_re(eapi_attrs) + m =3D atom_re.match(s) if m is None: raise InvalidAtom(self) - op =3D None gdict =3D m.groupdict() - cpv =3D cp =3D gdict['simple'] + if m.group('star') is not None: + op =3D '=3D*' + base =3D atom_re.groupindex['star'] + cp =3D m.group(base + 1) + cpv =3D m.group('star')[1:] + extended_version =3D m.group(base + 4) + else: + op =3D None + cpv =3D cp =3D m.group('simple') if cpv.find("**") !=3D -1: raise InvalidAtom(self) - slot =3D gdict['slot'] - repo =3D gdict['repo'] + slot =3D m.group('slot') + repo =3D m.group('repo') use_str =3D None extended_syntax =3D True else: @@ -1297,7 +1307,7 @@ class Atom(_unicode): except InvalidData: # plain cp, wildcard, or something self.__dict__['cpv'] =3D cpv - self.__dict__['version'] =3D None + self.__dict__['version'] =3D extended_version self.__dict__['repo'] =3D repo if slot is None: self.__dict__['slot'] =3D None @@ -2003,19 +2013,23 @@ def best_match_to_list(mypkg, mylist): """ operator_values =3D {'=3D':6, '~':5, '=3D*':4, '>':2, '<':2, '>=3D':2, '<=3D':2, None:1} - maxvalue =3D -2 + maxvalue =3D -99 bestm =3D None mypkg_cpv =3D None for x in match_to_list(mypkg, mylist): if x.extended_syntax: - if dep_getslot(x) is not None: + if x.operator =3D=3D '=3D*': if maxvalue < 0: maxvalue =3D 0 bestm =3D x - else: + elif x.slot is not None: if maxvalue < -1: maxvalue =3D -1 bestm =3D x + else: + if maxvalue < -2: + maxvalue =3D -2 + bestm =3D x continue if dep_getslot(x) is not None: if maxvalue < 3: @@ -2099,7 +2113,39 @@ def match_from_list(mydep, candidate_list): =20 mylist =3D [] =20 - if operator is None: + if mydep.extended_syntax: + + for x in candidate_list: + cp =3D getattr(x, "cp", None) + if cp is None: + mysplit =3D catpkgsplit(remove_slot(x)) + if mysplit is not None: + cp =3D mysplit[0] + '/' + mysplit[1] + + if cp is None: + continue + + if cp =3D=3D mycpv or extended_cp_match(mydep.cp, cp): + mylist.append(x) + + if mylist and mydep.operator =3D=3D "=3D*": + + candidate_list =3D mylist + mylist =3D [] + # Currently, only \*\d+\* is supported. + ver =3D mydep.version[1:-1] + + for x in candidate_list: + x_ver =3D getattr(x, "version", None) + if x_ver is None: + xs =3D catpkgsplit(remove_slot(x)) + if xs is None: + continue + x_ver =3D "-".join(xs[-2:]) + if ver in x_ver: + mylist.append(x) + + elif operator is None: for x in candidate_list: cp =3D getattr(x, "cp", None) if cp is None: @@ -2110,8 +2156,7 @@ def match_from_list(mydep, candidate_list): if cp is None: continue =20 - if cp =3D=3D mycpv or (mydep.extended_syntax and \ - extended_cp_match(mydep.cp, cp)): + if cp =3D=3D mydep.cp: mylist.append(x) =20 elif operator =3D=3D "=3D": # Exact match diff --git a/pym/portage/tests/dep/testAtom.py b/pym/portage/tests/dep/te= stAtom.py index e0cfaab..f5a7d37 100644 --- a/pym/portage/tests/dep/testAtom.py +++ b/pym/portage/tests/dep/testAtom.py @@ -20,6 +20,10 @@ class TestAtom(TestCase): (None, 'sys-apps/portage', None, '0', '[doc]', None), False, False = ), ( "*/*", (None, '*/*', None, None, None, None), True, False ), + ( "=3D*/*-*9999*", + ('=3D*', '*/*', '*9999*', None, None, None), True, False ), + ( "=3D*/*-*9999*:0::repo_name", + ('=3D*', '*/*', '*9999*', '0', None, 'repo_name'), True, True ), ( "sys-apps/*", (None, 'sys-apps/*', None, None, None, None), True, False ), ( "*/portage", diff --git a/pym/portage/tests/dep/test_best_match_to_list.py b/pym/porta= ge/tests/dep/test_best_match_to_list.py index 58ab95b..8a14038 100644 --- a/pym/portage/tests/dep/test_best_match_to_list.py +++ b/pym/portage/tests/dep/test_best_match_to_list.py @@ -38,6 +38,8 @@ class Test_best_match_to_list(TestCase): [Atom("=3Ddev-libs/A-1:0")], True), ("dev-libs/A-1", [Atom("dev-libs/*", allow_wildcard=3DTrue), Atom("= =3Ddev-libs/A-1:0")], \ [Atom("=3Ddev-libs/A-1:0"), Atom("dev-libs/*", allow_wildcard=3DTr= ue)], True), + ("dev-libs/A-4.9999-r1", [Atom("dev-libs/*", allow_wildcard=3DTrue)= , Atom("=3D*/*-*9999*", allow_wildcard=3DTrue)], \ + [Atom("=3D*/*-*9999*", allow_wildcard=3DTrue), Atom("dev-libs/*", = allow_wildcard=3DTrue)], True), ("dev-libs/A-1:0", [Atom("dev-*/*", allow_wildcard=3DTrue), Atom("d= ev-*/*:0", allow_wildcard=3DTrue),\ Atom("dev-libs/A"), Atom("<=3Ddev-libs/A-2"), Atom("dev-libs/A:0")= , \ Atom("=3Ddev-libs/A-1*"), Atom("~dev-libs/A-1"), Atom("=3Ddev-libs= /A-1")], \