summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/__init__.py58
-rw-r--r--pym/portage/dbapi/porttree.py57
2 files changed, 69 insertions, 46 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index e2f498760..a8a7ea561 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1838,6 +1838,64 @@ class config(object):
if has_changed:
self.reset(keeping_pkg=1,use_cache=use_cache)
+ def getMaskAtom(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: An matching atom string or None if one is not found.
+ """
+
+ cp = cpv_getkey(cpv)
+ mask_atoms = self.pmaskdict.get(cp)
+ if mask_atoms:
+ pkg_list = ["%s:%s" % (cpv, metadata["SLOT"])]
+ unmask_atoms = self.punmaskdict.get(cp)
+ for x in mask_atoms:
+ if not match_from_list(x, pkg_list):
+ continue
+ masked = True
+ if unmask_atoms:
+ for y in unmask_atoms:
+ if match_from_list(y, pkg_list):
+ masked = False
+ break
+ if not masked:
+ continue
+ return x
+ return None
+
+ def getProfileMaskAtom(self, cpv, metadata):
+ """
+ Take a package and return a matching profile atom, or None if no
+ such atom exists. Note that a profile atom may or may not have a "*"
+ prefix. 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: An matching profile atom string or None if one is not found.
+ """
+
+ cp = cpv_getkey(cpv)
+ profile_atoms = self.prevmaskdict.get(cp)
+ if profile_atoms:
+ pkg_list = ["%s:%s" % (cpv, metadata["SLOT"])]
+ for x in profile_atoms:
+ if match_from_list(x.lstrip("*"), pkg_list):
+ continue
+ return x
+ return None
+
def getMissingKeywords(self, cpv, metadata):
"""
Take a package and return a list of any KEYWORDS that the user may
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 14a50b126..ee8c4776d 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -604,57 +604,22 @@ class portdbapi(dbapi):
if not mylist:
return []
- mysplit = catpkgsplit(mylist[0])
- if not mysplit:
- #invalid cat/pkg-v
- writemsg("visible(): invalid cat/pkg-v: %s\n" % (mylist[0], ),
- noiselevel=-1)
- return []
- mycp = "%s/%s" % (mysplit[0], mysplit[1])
-
- cpv_slots = []
+ db_keys = ["SLOT"]
+ visible = []
+ getMaskAtom = self.mysettings.getMaskAtom
+ getProfileMaskAtom = self.mysettings.getProfileMaskAtom
for cpv in mylist:
try:
- myslot = self.aux_get(cpv, ["SLOT"])[0]
+ metadata = dict(izip(db_keys, self.aux_get(cpv, db_keys)))
except KeyError:
# masked by corruption
continue
- cpv_slots.append("%s:%s" % (cpv, myslot))
-
- if cpv_slots:
- mask_atoms = self.mysettings.pmaskdict.get(mycp)
- if mask_atoms:
- unmask_atoms = self.mysettings.punmaskdict.get(mycp)
- for x in mask_atoms:
- masked_pkgs = match_from_list(x, cpv_slots)
- if not masked_pkgs:
- continue
- if unmask_atoms:
- for y in unmask_atoms:
- unmasked_pkgs = match_from_list(y, masked_pkgs)
- if unmasked_pkgs:
- masked_pkgs = [pkg for pkg in masked_pkgs \
- if pkg not in unmasked_pkgs]
- if not masked_pkgs:
- break
- if masked_pkgs:
- cpv_slots = [pkg for pkg in cpv_slots \
- if pkg not in masked_pkgs]
- if not cpv_slots:
- break
-
- if cpv_slots:
- profile_atoms = self.mysettings.prevmaskdict.get(mycp)
- if profile_atoms:
- for x in profile_atoms:
- cpv_slots = match_from_list(x.lstrip("*"), cpv_slots)
- if not cpv_slots:
- break
-
- if not cpv_slots:
- return cpv_slots
-
- return [remove_slot(pkg) for pkg in cpv_slots]
+ if getMaskAtom(cpv, metadata):
+ continue
+ if getProfileMaskAtom(cpv, metadata):
+ continue
+ visible.append(cpv)
+ return visible
def gvisible(self,mylist):
"strip out group-masked (not in current group) entries"