reposyntax: add support in _config/*
authorSebastian Luther <SebastianLuther@gmx.de>
Tue, 21 Sep 2010 07:31:02 +0000 (09:31 +0200)
committerZac Medico <zmedico@gentoo.org>
Mon, 27 Sep 2010 06:50:14 +0000 (23:50 -0700)
pym/portage/package/ebuild/_config/KeywordsManager.py
pym/portage/package/ebuild/_config/LicenseManager.py
pym/portage/package/ebuild/_config/MaskManager.py
pym/portage/package/ebuild/_config/UseManager.py
pym/portage/package/ebuild/_config/helper.py
pym/portage/tests/ebuild/test_config.py

index f6b866795a73dea2e7c60528b22e08ad1a2a09e3..c21e2d75bd09c33c736b1f69d4cd11f5c6271fdc 100644 (file)
@@ -6,7 +6,7 @@ __all__ = (
 )
 
 from portage import os
-from portage.dep import ExtendedAtomDict
+from portage.dep import ExtendedAtomDict, _repo_separator, _slot_separator
 from portage.localization import _
 from portage.package.ebuild._config.helper import ordered_by_atom_specificity
 from portage.util import grabdict_package, stack_lists, writemsg
@@ -52,11 +52,11 @@ class KeywordsManager(object):
                if user_config:
                        pkgdict = grabdict_package(
                                os.path.join(abs_user_config, "package.keywords"),
-                               recursive=1, allow_wildcard=True, verify_eapi=False)
+                               recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
 
                        for k, v in grabdict_package(
                                os.path.join(abs_user_config, "package.accept_keywords"),
-                               recursive=1, allow_wildcard=True, verify_eapi=False).items():
+                               recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False).items():
                                pkgdict.setdefault(k, []).extend(v)
 
                        accept_keywords_defaults = global_accept_keywords.split()
@@ -70,9 +70,11 @@ class KeywordsManager(object):
                                        v = tuple(v)
                                self.pkeywordsdict.setdefault(k.cp, {})[k] = v
 
-       def getKeywords(self, cpv, slot, keywords):
+       def getKeywords(self, cpv, slot, keywords, repo):
                cp = cpv_getkey(cpv)
-               pkg = "%s:%s" % (cpv, slot)
+               pkg = "".join((cpv, _slot_separator, slot))
+               if repo:
+                       pkg = "".join((pkg, _repo_separator, repo))
                keywords = [[x for x in keywords.split() if x != "-*"]]
                for pkeywords_dict in self._pkeywords_list:
                        cpdict = pkeywords_dict.get(cp)
@@ -82,7 +84,7 @@ class KeywordsManager(object):
                                        keywords.extend(pkg_keywords)
                return stack_lists(keywords, incremental=True)
 
-       def getMissingKeywords(self, cpv, slot, keywords, global_accept_keywords, backuped_accept_keywords):
+       def getMissingKeywords(self, cpv, slot, keywords, repo, global_accept_keywords, backuped_accept_keywords):
                """
                Take a package and return a list of any KEYWORDS that the user may
                need to accept for the given package. If the KEYWORDS are empty
@@ -108,7 +110,7 @@ class KeywordsManager(object):
                # doesn't work properly as negative values are lost in the config
                # object (bug #139600)
                egroups = backuped_accept_keywords.split()
-               mygroups = self.getKeywords(cpv, slot, keywords)
+               mygroups = self.getKeywords(cpv, slot, keywords, repo)
                # Repoman may modify this attribute as necessary.
                pgroups = global_accept_keywords.split()
                matches = False
@@ -134,7 +136,7 @@ class KeywordsManager(object):
                if pkgdict:
                        cpv_slot = "%s:%s" % (cpv, slot)
                        pkg_accept_keywords = \
-                               ordered_by_atom_specificity(pkgdict, cpv_slot)
+                               ordered_by_atom_specificity(pkgdict, cpv_slot, repo=repo)
                        if pkg_accept_keywords:
                                for x in pkg_accept_keywords:
                                        pgroups.extend(x)
index 41f9c7abccd6d6f493f8badeca8897e964ede5dc..effd55be3f262de6efe7d3fd9c57c417821ae338 100644 (file)
@@ -35,7 +35,7 @@ class LicenseManager(object):
 
        def _read_user_config(self, abs_user_config):
                licdict = grabdict_package(os.path.join(
-                       abs_user_config, "package.license"), recursive=1, allow_wildcard=True, verify_eapi=False)
+                       abs_user_config, "package.license"), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
                for k, v in licdict.items():
                        self._plicensedict.setdefault(k.cp, {})[k] = \
                                self.expandLicenseTokens(v)
@@ -111,7 +111,7 @@ class LicenseManager(object):
                        rValue = ["-" + token for token in rValue]
                return rValue
 
-       def _getPkgAcceptLicense(self, cpv, slot):
+       def _getPkgAcceptLicense(self, cpv, slot, repo):
                """
                Get an ACCEPT_LICENSE list, accounting for package.license.
                """
@@ -120,14 +120,14 @@ class LicenseManager(object):
                cpdict = self._plicensedict.get(cp)
                if cpdict:
                        cpv_slot = "%s:%s" % (cpv, slot)
-                       plicence_list = ordered_by_atom_specificity(cpdict, cpv_slot)
+                       plicence_list = ordered_by_atom_specificity(cpdict, cpv_slot, repo)
                        if plicence_list:
                                accept_license = list(self._accept_license)
                                for x in plicence_list:
                                        accept_license.extend(x)
                return accept_license
 
-       def get_prunned_accept_license(self, cpv, use, lic, slot):
+       def get_prunned_accept_license(self, cpv, use, lic, slot, repo):
                """
                Generate a pruned version of ACCEPT_LICENSE, by intersection with
                LICENSE. This is required since otherwise ACCEPT_LICENSE might be
@@ -140,7 +140,7 @@ class LicenseManager(object):
                        licenses = set()
                licenses.discard('||')
 
-               accept_license = self._getPkgAcceptLicense(cpv, slot)
+               accept_license = self._getPkgAcceptLicense(cpv, slot, repo)
 
                if accept_license:
                        acceptable_licenses = set()
@@ -157,7 +157,7 @@ class LicenseManager(object):
                        licenses = acceptable_licenses
                return ' '.join(sorted(licenses))
 
-       def getMissingLicenses(self, cpv, use, lic, slot):
+       def getMissingLicenses(self, cpv, use, lic, slot, repo):
                """
                Take a LICENSE string and return a list of any licenses that the user
                may need to accept for the given package.  The returned list will not
@@ -180,7 +180,7 @@ class LicenseManager(object):
                licenses.discard('||')
 
                acceptable_licenses = set()
-               for x in self._getPkgAcceptLicense(cpv, slot):
+               for x in self._getPkgAcceptLicense(cpv, slot, repo):
                        if x == '*':
                                acceptable_licenses.update(licenses)
                        elif x == '-*':
index f5b240a4743b52949793d04960878cdc2696226a..c06e346634a8086a8d2927173898776ac583749b 100644 (file)
@@ -7,7 +7,7 @@ __all__ = (
 
 from itertools import chain
 from portage import os
-from portage.dep import ExtendedAtomDict, match_from_list
+from portage.dep import ExtendedAtomDict, match_from_list, _repo_separator, _slot_separator
 from portage.util import grabfile_package, stack_lists
 from portage.versions import cpv_getkey
 
@@ -61,10 +61,10 @@ class MaskManager(object):
                if user_config:
                        user_pkgmasklines = grabfile_package(
                                os.path.join(abs_user_config, "package.mask"), recursive=1, \
-                               allow_wildcard=True, remember_source_file=True, verify_eapi=False)
+                               allow_wildcard=True, allow_repo=True, remember_source_file=True, verify_eapi=False)
                        user_pkgunmasklines = grabfile_package(
                                os.path.join(abs_user_config, "package.unmask"), recursive=1, \
-                               allow_wildcard=True, remember_source_file=True, verify_eapi=False)
+                               allow_wildcard=True, allow_repo=True, remember_source_file=True, verify_eapi=False)
 
                #Stack everything together. At this point, only user_pkgmasklines may contain -atoms.
                #Don't warn for unmatched -atoms here, since we don't do it for any other user config file.
@@ -83,7 +83,7 @@ class MaskManager(object):
                        for k, v in d.items():
                                d[k] = tuple(v)
 
-       def getMaskAtom(self, cpv, slot):
+       def getMaskAtom(self, cpv, slot, repo):
                """
                Take a package and return a matching package.mask atom, or None if no
                such atom exists or it has been cancelled by package.unmask. PROVIDE
@@ -100,7 +100,10 @@ class MaskManager(object):
                cp = cpv_getkey(cpv)
                mask_atoms = self._pmaskdict.get(cp)
                if mask_atoms:
-                       pkg_list = ["%s:%s" % (cpv, slot)]
+                       pkg = "".join((cpv, _slot_separator, slot))
+                       if repo:
+                               pkg = "".join((pkg, _repo_separator, repo))
+                       pkg_list = [pkg]
                        unmask_atoms = self._punmaskdict.get(cp)
                        for x in mask_atoms:
                                if not match_from_list(x, pkg_list):
index 8b3e44b380558fb6785c805aa75973b50c8760f7..13f65736fa3db2e0ea892b38a4452b6da9935b65 100644 (file)
@@ -52,7 +52,7 @@ class UseManager(object):
                ret = ExtendedAtomDict(dict)
                if user_config:
                        pusedict = grabdict_package(
-                               os.path.join(location, file_name), recursive=1, allow_wildcard=True, verify_eapi=False)
+                               os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
                        for k, v in pusedict.items():
                                ret.setdefault(k.cp, {})[k] = v
 
index c29b95e14b5180a96128e0d3cdecd4c4a702c696..ca720982fae1d3fb93405237124c868720404020 100644 (file)
@@ -5,9 +5,9 @@ __all__ = (
        'ordered_by_atom_specificity', 'prune_incremental',
 )
 
-from portage.dep import best_match_to_list
+from portage.dep import best_match_to_list, _repo_separator
 
-def ordered_by_atom_specificity(cpdict, pkg):
+def ordered_by_atom_specificity(cpdict, pkg, repo=None):
        """
        Return a list of matched values from the given cpdict,
        in ascending order by atom specificity. The rationale
@@ -23,6 +23,8 @@ def ordered_by_atom_specificity(cpdict, pkg):
        order to achieve desired results (and thus corrupting
        the ChangeLog like ordering of the file).
        """
+       if repo is not None:
+               pkg = pkg + _repo_separator + repo
 
        results = []
        keys = list(cpdict)
index 9e2d2eaaa6edd1019ef1187c3198f087871ae17a..5af8da5fbd2e7196af84d6920dac9f3eab15a348 100644 (file)
@@ -83,23 +83,23 @@ class ConfigTestCase(TestCase):
                        self.assertEqual(lic_man.extract_global_changes(), "")
 
                        lic_man.set_accept_license_str("TEST TEST2")
-                       self.assertEqual(lic_man._getPkgAcceptLicense("dev-libs/B-1", "0"), ["TEST", "TEST2", "TEST"])
-                       self.assertEqual(lic_man._getPkgAcceptLicense("dev-libs/A-1", "0"), ["TEST", "TEST2", "TEST", "-TEST2"])
-                       self.assertEqual(lic_man._getPkgAcceptLicense("dev-libs/A-2", "0"), ["TEST", "TEST2", "TEST", "-TEST2", "TEST3", "@TEST"])
-
-                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/B-1", [], "TEST", "0"), "TEST")
-                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/A-1", [], "-TEST2", "0"), "")
-                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/A-2", [], "|| ( TEST TEST2 )", "0"), "TEST")
-                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/C-1", [], "TEST5", "0"), "TEST5")
-                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/C-2", [], "TEST2", "0"), "")
-
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/B-1", [], "TEST", "0"), [])
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/A-1", [], "-TEST2", "0"), ["-TEST2"])
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/A-2", [], "|| ( TEST TEST2 )", "0"), [])
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/A-3", [], "|| ( TEST2 || ( TEST3 TEST4 ) )", "0"), ["TEST2", "TEST3", "TEST4"])
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/C-1", [], "TEST5", "0"), [])
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/C-2", [], "TEST2", "0"), ["TEST2"])
-                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/D-1", [], "", "0"), [])
+                       self.assertEqual(lic_man._getPkgAcceptLicense("dev-libs/B-1", "0", None), ["TEST", "TEST2", "TEST"])
+                       self.assertEqual(lic_man._getPkgAcceptLicense("dev-libs/A-1", "0", None), ["TEST", "TEST2", "TEST", "-TEST2"])
+                       self.assertEqual(lic_man._getPkgAcceptLicense("dev-libs/A-2", "0", None), ["TEST", "TEST2", "TEST", "-TEST2", "TEST3", "@TEST"])
+
+                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/B-1", [], "TEST", "0", None), "TEST")
+                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/A-1", [], "-TEST2", "0", None), "")
+                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/A-2", [], "|| ( TEST TEST2 )", "0", None), "TEST")
+                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/C-1", [], "TEST5", "0", None), "TEST5")
+                       self.assertEqual(lic_man.get_prunned_accept_license("dev-libs/C-2", [], "TEST2", "0", None), "")
+
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/B-1", [], "TEST", "0", None), [])
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/A-1", [], "-TEST2", "0", None), ["-TEST2"])
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/A-2", [], "|| ( TEST TEST2 )", "0", None), [])
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/A-3", [], "|| ( TEST2 || ( TEST3 TEST4 ) )", "0", None), ["TEST2", "TEST3", "TEST4"])
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/C-1", [], "TEST5", "0", None), [])
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/C-2", [], "TEST2", "0", None), ["TEST2"])
+                       self.assertEqual(lic_man.getMissingLicenses("dev-libs/D-1", [], "", "0", None), [])
                finally:
                        portage.util.noiselimit = 0
                        playground.cleanup()