From 4a45bc945fbbe6d7cf7e7c1a397ef59f299b7748 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 31 Mar 2008 18:45:12 +0000 Subject: Pass Package instances into visible() so that the package instance can be used to cache relevant visibility information such as whether or not the package is corrupt or otherwise invalid. (trunk r9643) svn path=/main/branches/2.1.2/; revision=9647 --- bin/emerge | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'bin') diff --git a/bin/emerge b/bin/emerge index 0550fa585..49e521ba2 100755 --- a/bin/emerge +++ b/bin/emerge @@ -466,8 +466,14 @@ class search: def _visible(self, db, cpv, metadata): installed = db is self.vartree.dbapi built = installed or db is not self._portdb - return visible(self.settings, cpv, metadata, - built=built, installed=installed) + pkg_type = "ebuild" + if installed: + pkg_type = "installed" + elif built: + pkg_type = "binary" + return visible(self.settings, + Package(type_name=pkg_type, root=self.settings["ROOT"], + cpv=cpv, built=built, installed=installed, metadata=metadata)) def _xmatch(self, level, atom): """ @@ -1169,7 +1175,7 @@ def perform_global_updates(mycpv, mydb, mycommands): if updates: mydb.aux_update(mycpv, updates) -def visible(pkgsettings, cpv, metadata, built=False, installed=False): +def visible(pkgsettings, pkg): """ Check if a package is visible. This can raise an InvalidDependString exception if LICENSE is invalid. @@ -1177,18 +1183,19 @@ def visible(pkgsettings, cpv, metadata, built=False, installed=False): @rtype: Boolean @returns: True if the package is visible, False otherwise. """ - if not metadata["SLOT"]: + if not pkg.metadata["SLOT"]: return False - if built and not installed and \ - metadata["CHOST"] != pkgsettings["CHOST"]: + if pkg.built and not pkg.installed and \ + pkg.metadata["CHOST"] != pkgsettings["CHOST"]: return False - if not portage.eapi_is_supported(metadata["EAPI"]): + if not portage.eapi_is_supported(pkg.metadata["EAPI"]): return False - if not installed and pkgsettings._getMissingKeywords(cpv, metadata): + if not pkg.installed and \ + pkgsettings._getMissingKeywords(pkg.cpv, pkg.metadata): return False - if pkgsettings._getMaskAtom(cpv, metadata): + if pkgsettings._getMaskAtom(pkg.cpv, pkg.metadata): return False - if pkgsettings._getProfileMaskAtom(cpv, metadata): + if pkgsettings._getProfileMaskAtom(pkg.cpv, pkg.metadata): return False return True @@ -1768,8 +1775,7 @@ class depgraph: # - multi-slot atoms listed in the world file # to prevent depclean from removing them - if not visible(pkgsettings, pkg.cpv, pkg.metadata, - built=pkg.built, installed=pkg.installed): + if not visible(pkgsettings, pkg): self._masked_installed.append((pkg, pkgsettings)) if arg: @@ -2268,12 +2274,9 @@ class depgraph: if not installed: if myarg: found_available_arg = True - try: - if not visible(pkgsettings, cpv, metadata, - built=built, installed=installed): - continue - except portage_exception.InvalidDependString: - # masked by corruption + if not visible(pkgsettings, Package(built=built, + cpv=cpv, installed=installed, metadata=metadata, + type_name=pkg_type)): continue # At this point, we've found the highest visible # match from the current repo. Any lower versions @@ -6091,8 +6094,8 @@ def action_depclean(settings, trees, ldpath_mtimes, for cpv in reversed(pkgs): metadata = dict(izip(metadata_keys, vardb.aux_get(cpv, metadata_keys))) - if visible(settings, cpv, metadata, - built=True, installed=True): + if visible(settings, Package(built=True, cpv=cpv, + installed=True, metadata=metadata, type_name="installed")): pkgs = [cpv] break if len(pkgs) > 1: -- cgit v1.2.3-1-g7c22