summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-09-21 09:31:02 +0200
committerZac Medico <zmedico@gentoo.org>2010-09-26 23:50:14 -0700
commit5e94065640c219d9cf4ae1e632d638d88c007912 (patch)
treef434f25c5478421a258b1679866c02a0b981247b
parentc7d210f346dbcc53d69ee9b99663c62eabfa1b09 (diff)
downloadportage-5e94065640c219d9cf4ae1e632d638d88c007912.tar.gz
portage-5e94065640c219d9cf4ae1e632d638d88c007912.tar.bz2
portage-5e94065640c219d9cf4ae1e632d638d88c007912.zip
reposyntax: add support in _config/*
-rw-r--r--pym/portage/package/ebuild/_config/KeywordsManager.py18
-rw-r--r--pym/portage/package/ebuild/_config/LicenseManager.py14
-rw-r--r--pym/portage/package/ebuild/_config/MaskManager.py13
-rw-r--r--pym/portage/package/ebuild/_config/UseManager.py2
-rw-r--r--pym/portage/package/ebuild/_config/helper.py6
-rw-r--r--pym/portage/tests/ebuild/test_config.py34
6 files changed, 47 insertions, 40 deletions
diff --git a/pym/portage/package/ebuild/_config/KeywordsManager.py b/pym/portage/package/ebuild/_config/KeywordsManager.py
index f6b866795..c21e2d75b 100644
--- a/pym/portage/package/ebuild/_config/KeywordsManager.py
+++ b/pym/portage/package/ebuild/_config/KeywordsManager.py
@@ -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)
diff --git a/pym/portage/package/ebuild/_config/LicenseManager.py b/pym/portage/package/ebuild/_config/LicenseManager.py
index 41f9c7abc..effd55be3 100644
--- a/pym/portage/package/ebuild/_config/LicenseManager.py
+++ b/pym/portage/package/ebuild/_config/LicenseManager.py
@@ -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 == '-*':
diff --git a/pym/portage/package/ebuild/_config/MaskManager.py b/pym/portage/package/ebuild/_config/MaskManager.py
index f5b240a47..c06e34663 100644
--- a/pym/portage/package/ebuild/_config/MaskManager.py
+++ b/pym/portage/package/ebuild/_config/MaskManager.py
@@ -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):
diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py
index 8b3e44b38..13f65736f 100644
--- a/pym/portage/package/ebuild/_config/UseManager.py
+++ b/pym/portage/package/ebuild/_config/UseManager.py
@@ -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
diff --git a/pym/portage/package/ebuild/_config/helper.py b/pym/portage/package/ebuild/_config/helper.py
index c29b95e14..ca720982f 100644
--- a/pym/portage/package/ebuild/_config/helper.py
+++ b/pym/portage/package/ebuild/_config/helper.py
@@ -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)
diff --git a/pym/portage/tests/ebuild/test_config.py b/pym/portage/tests/ebuild/test_config.py
index 9e2d2eaaa..5af8da5fb 100644
--- a/pym/portage/tests/ebuild/test_config.py
+++ b/pym/portage/tests/ebuild/test_config.py
@@ -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()