Bug #149816 - Implement visibility filtering for binary packages.
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 11:17:41 +0000 (11:17 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 11:17:41 +0000 (11:17 -0000)
This is only the least invasive part of the implementation that is
currently in trunk.

svn path=/main/branches/2.1.2/; revision=8984

bin/emerge
pym/portage.py

index 3759de185082734d20e9321beca0acdf90f544e3..3240d79abc6b6b4949775c78be59a329d575a225 100755 (executable)
@@ -1045,6 +1045,29 @@ def perform_global_updates(mycpv, mydb, mycommands):
        if updates:
                mydb.aux_update(mycpv, updates)
 
+def visible(pkgsettings, cpv, metadata, built=False, installed=False):
+       """
+       Check if a package is visible. This can raise an InvalidDependString
+       exception if LICENSE is invalid.
+       TODO: optionally generate a list of masking reasons
+       @rtype: Boolean
+       @returns: True if the package is visible, False otherwise.
+       """
+       if not metadata["SLOT"]:
+               return False
+       if built and not installed and \
+               metadata["CHOST"] != pkgsettings["CHOST"]:
+               return False
+       if not portage.eapi_is_supported(metadata["EAPI"]):
+               return False
+       if pkgsettings._getMissingKeywords(cpv, metadata):
+               return False
+       if pkgsettings._getMaskAtom(cpv, metadata):
+               return False
+       if pkgsettings._getProfileMaskAtom(cpv, metadata):
+               return False
+       return True
+
 class BlockerCache(DictMixin):
        """This caches blockers of installed packages so that dep_check does not
        have to be done for every single installed package on every invocation of
@@ -1975,17 +1998,7 @@ class depgraph:
                                        for pkg in bindb.match(x):
                                                metadata = dict(izip(bindb_keys,
                                                        bindb.aux_get(pkg, bindb_keys)))
-                                               if not metadata["SLOT"]:
-                                                       continue
-                                               if chost != metadata["CHOST"]:
-                                                       continue
-                                               if not portage.eapi_is_supported(metadata["EAPI"]):
-                                                       continue
-                                               # Remove any binary package entries that are
-                                               # masked in the portage tree (#55871).
-                                               if not usepkgonly and \
-                                                       not (pkg in myeb_matches or \
-                                                       not portdb.cpv_exists(pkg)):
+                                               if not visible(pkgsettings, pkg, metadata, built=True):
                                                        continue
                                                myeb_pkg_matches.append(pkg)
                                        if myeb_pkg_matches:
index 6195e6843891afe123d4e09da41d8f764b6e9a61..bf6016579521083d670a52d7bd47bd302ef0efc7 100644 (file)
@@ -6002,7 +6002,9 @@ class bindbapi(fakedbapi):
                self.settings = settings
                self._match_cache = {}
                # Selectively cache metadata in order to optimize dep matching.
-               self._aux_cache_keys = set(["CHOST","EAPI","SLOT"])
+               self._aux_cache_keys = set(
+                                       ["CHOST", "EAPI", "IUSE", "KEYWORDS",
+                                       "LICENSE", "PROVIDE", "SLOT", "USE"])
                self._aux_cache = {}
 
        def match(self, *pargs, **kwargs):