)
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
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()
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)
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
# 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
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)
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)
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.
"""
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
licenses = set()
licenses.discard('||')
- accept_license = self._getPkgAcceptLicense(cpv, slot)
+ accept_license = self._getPkgAcceptLicense(cpv, slot, repo)
if accept_license:
acceptable_licenses = set()
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
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 == '-*':
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
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.
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
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):
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
'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
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)
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()