summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorBrian Dolbec <brian.dolbec@gmail.com>2011-01-29 19:22:58 -0800
committerZac Medico <zmedico@gentoo.org>2011-01-30 01:11:58 -0800
commitce0cbf82cafc78ee22354257b9821d55b780d35e (patch)
tree46872f42f40fc9c46fc242ba8939d78eca52e7e9 /pym
parent6b7177c92af62ee17200f118dcdcad35e50c7ade (diff)
downloadportage-ce0cbf82cafc78ee22354257b9821d55b780d35e.tar.gz
portage-ce0cbf82cafc78ee22354257b9821d55b780d35e.tar.bz2
portage-ce0cbf82cafc78ee22354257b9821d55b780d35e.zip
add a new function to MaskManager that optimizies getting any raw mask atoms
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/Package.py29
-rw-r--r--pym/portage/package/ebuild/_config/MaskManager.py28
-rw-r--r--pym/portage/package/ebuild/config.py22
3 files changed, 53 insertions, 26 deletions
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index 96c76b965..ae9e8f293 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -239,7 +239,7 @@ class Package(Task):
def accepted_keyword(self):
"""returns the keyword used from the ebuild's KEYWORDS string"""
-
+
keywords = set(self.metadata.get('KEYWORDS').split())
accept_keywords = set(self.root_config.settings['ACCEPT_KEYWORDS'].split())
used_keyword = list(set.intersection(keywords, accept_keywords))
@@ -250,31 +250,14 @@ class Package(Task):
writemsg_level( "_emerge.output.resolver.Display(), too many keywords recieved for pkg: %s, %s"
% (pkg.cpv, used_keyword))
used_keyword = used_keyword[0]
- #print "pmaskdict", self.root_config.settings.pmaskdict
return used_keyword
def isHardMasked(self):
- """returns a bool if the cpv is in the list of
+ """returns a bool if the cpv is in the list of
expanded pmaskdict[cp] availble ebuilds"""
- try:
- # returns a list of mask atoms
- pmask = self.root_config.settings.pmaskdict[self.cp]
- except KeyError:
- pmask = []
- if pmask:
- # narrow pmask atoms down to the relevant repo
- n = [x for x in pmask if x.split('::')[-1] in [self.repo]]
- # hopefully it is down to only 1 mask atom
- #print "n =", n
- #count = 0
- hardmasked = set()
- for x in n:
- #expand the atom to matching available ebuilds
- hardmasked.update(self.root_config.trees['porttree'].dbapi.xmatch("match-all",x))
- #count += 1
- #print "for x in n: loop count =", count, hardmasked
- return self.cpv in hardmasked
- return False
+ pmask = self.root_config.settings._getRawMaskAtom(self.cpv, self.metadata)
+ print "pmask =", pmask
+ return pmask is not None
def _metadata_exception(self, k, e):
@@ -448,7 +431,7 @@ class Package(Task):
not self._iuse_implicit_match(flag):
return False
return True
-
+
def get_missing_iuse(self, flags):
"""
@returns: A list of flags missing from IUSE.
diff --git a/pym/portage/package/ebuild/_config/MaskManager.py b/pym/portage/package/ebuild/_config/MaskManager.py
index 25d679e9f..66278ec5e 100644
--- a/pym/portage/package/ebuild/_config/MaskManager.py
+++ b/pym/portage/package/ebuild/_config/MaskManager.py
@@ -135,3 +135,31 @@ class MaskManager(object):
return None
return x
return None
+
+ def getRawMaskAtom(self, cpv, slot, repo):
+ """
+ Take a package and return a matching package.mask atom, or None if no
+ such atom exists. It HAS NOT! been cancelled by any package.unmask.
+ PROVIDE is not checked, so atoms will not be found for old-style
+ virtuals.
+
+ @param cpv: The package name
+ @type cpv: String
+ @param slot: The package's slot
+ @type slot: String
+ @rtype: String
+ @return: A matching atom string or None if one is not found.
+ """
+
+ cp = cpv_getkey(cpv)
+ mask_atoms = self._pmaskdict.get(cp)
+ if mask_atoms:
+ pkg = "".join((cpv, _slot_separator, slot))
+ if repo:
+ pkg = "".join((pkg, _repo_separator, repo))
+ pkg_list = [pkg]
+ for x in mask_atoms:
+ if not match_from_list(x, pkg_list):
+ continue
+ return x
+ return None
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index ba6ac21fa..b15a1952e 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -110,10 +110,10 @@ class _iuse_implicit_match_cache(object):
class config(object):
"""
This class encompasses the main portage configuration. Data is pulled from
- ROOT/PORTDIR/profiles/, from ROOT/etc/make.profile incrementally through all
+ ROOT/PORTDIR/profiles/, from ROOT/etc/make.profile incrementally through all
parent profiles as well as from ROOT/PORTAGE_CONFIGROOT/* for user specified
overrides.
-
+
Generally if you need data like USE flags, FEATURES, environment variables,
virtuals ...etc you look in here.
"""
@@ -1376,6 +1376,22 @@ class config(object):
"""
return self._mask_manager.getMaskAtom(cpv, metadata["SLOT"], metadata.get('repository'))
+ def _getRawMaskAtom(self, cpv, metadata):
+ """
+ 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
+ is not checked, so atoms will not be found for old-style virtuals.
+
+ @param cpv: The package name
+ @type cpv: String
+ @param metadata: A dictionary of raw package metadata
+ @type metadata: dict
+ @rtype: String
+ @return: A matching atom string or None if one is not found.
+ """
+ return self._mask_manager.getRawMaskAtom(cpv, metadata["SLOT"], metadata.get('repository'))
+
+
def _getProfileMaskAtom(self, cpv, metadata):
"""
Take a package and return a matching profile atom, or None if no
@@ -1424,7 +1440,7 @@ class config(object):
@return: A list of KEYWORDS that have not been accepted.
"""
- # Hack: Need to check the env directly here as otherwise stacking
+ # Hack: Need to check the env directly here as otherwise stacking
# doesn't work properly as negative values are lost in the config
# object (bug #139600)
backuped_accept_keywords = self.configdict["backupenv"].get("ACCEPT_KEYWORDS", "")