From: Zac Medico Date: Wed, 11 Mar 2009 06:34:01 +0000 (-0000) Subject: When ACCEPT_CHOSTS is set, enable CHOST masking for unbuilt ebuilds. This X-Git-Tag: v2.1.6.8~87 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b4b0b543c4fdbdd8fe8c1ece31e0145e7eb52d48;p=portage.git When ACCEPT_CHOSTS is set, enable CHOST masking for unbuilt ebuilds. This behaves as a sanity check to protect people who are cross-compiling from accidentally merging an ebuild with CHOST set incorrectly. Thanks to Ned Ludd for reporting the problem. (trunk r12741) svn path=/main/branches/2.1.6/; revision=12990 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 9173d58bb..94dc3f465 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1368,8 +1368,8 @@ def visible(pkgsettings, pkg): """ if not pkg.metadata["SLOT"]: return False - if pkg.built and not pkg.installed and "CHOST" in pkg.metadata: - if not pkgsettings._accept_chost(pkg): + if not pkg.installed: + if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): return False eapi = pkg.metadata["EAPI"] if not portage.eapi_is_supported(eapi): @@ -1396,8 +1396,8 @@ def get_masking_status(pkg, pkgsettings, root_config): pkg, settings=pkgsettings, portdb=root_config.trees["porttree"].dbapi) - if pkg.built and not pkg.installed and "CHOST" in pkg.metadata: - if not pkgsettings._accept_chost(pkg): + if not pkg.installed: + if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): mreasons.append("CHOST: %s" % \ pkg.metadata["CHOST"]) @@ -1417,6 +1417,7 @@ def get_mask_info(root_config, cpv, pkgsettings, if metadata and not built: pkgsettings.setcpv(cpv, mydb=metadata) metadata["USE"] = pkgsettings["PORTAGE_USE"] + metadata['CHOST'] = pkgsettings.get('CHOST', '') if metadata is None: mreasons = ["corruption"] else: @@ -5452,6 +5453,7 @@ class depgraph(object): cpv=mykey, metadata=metadata, onlydeps=onlydeps) pkgsettings.setcpv(pkg) pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"] + pkg.metadata['CHOST'] = pkgsettings.get('CHOST', '') self._pkg_cache[pkg] = pkg args.append(PackageArg(arg=x, package=pkg, root_config=root_config)) @@ -6172,6 +6174,8 @@ class depgraph(object): onlydeps=onlydeps, root_config=root_config, type_name=pkg_type) metadata = pkg.metadata + if not built: + metadata['CHOST'] = pkgsettings.get('CHOST', '') if not built and ("?" in metadata["LICENSE"] or \ "?" in metadata["PROVIDE"]): # This is avoided whenever possible because @@ -6505,6 +6509,7 @@ class depgraph(object): settings = self.pkgsettings[root_config.root] settings.setcpv(pkg) pkg.metadata["USE"] = settings["PORTAGE_USE"] + pkg.metadata['CHOST'] = settings.get('CHOST', '') self._pkg_cache[pkg] = pkg return pkg @@ -8680,6 +8685,7 @@ class depgraph(object): pkgsettings = self.pkgsettings[myroot] pkgsettings.setcpv(pkg) pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"] + pkg.metadata['CHOST'] = pkgsettings.get('CHOST', '') self._pkg_cache[pkg] = pkg root_config = self.roots[pkg.root] @@ -11423,6 +11429,7 @@ class Scheduler(PollScheduler): settings = self.pkgsettings[root_config.root] settings.setcpv(pkg) pkg.metadata["USE"] = settings["PORTAGE_USE"] + pkg.metadata['CHOST'] = settings.get('CHOST', '') return pkg diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 5b661ce24..20de5af10 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -2528,7 +2528,7 @@ class config(object): ret.append(element) return ret - def _accept_chost(self, pkg): + def _accept_chost(self, cpv, metadata): """ @return True if pkg CHOST is accepted, False otherwise. """ @@ -2557,7 +2557,7 @@ class config(object): self._accept_chost_re = re.compile("^$") return self._accept_chost_re.match( - pkg.metadata.get("CHOST", "")) is not None + metadata.get('CHOST', '')) is not None def setinst(self,mycpv,mydbapi): """This updates the preferences for old-style virtuals, diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index dd2257afe..7ac281e8b 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -856,6 +856,8 @@ class portdbapi(dbapi): aux_keys = list(self._aux_cache_keys) metadata = {} local_config = self.mysettings.local_config + chost = self.mysettings.get('CHOST', '') + accept_chost = self.mysettings._accept_chost for mycpv in mylist: metadata.clear() try: @@ -876,6 +878,9 @@ class portdbapi(dbapi): if self.mysettings._getMissingKeywords(mycpv, metadata): continue if local_config: + metadata['CHOST'] = chost + if not accept_chost(mycpv, metadata): + continue metadata["USE"] = "" if "?" in metadata["LICENSE"]: self.doebuild_settings.setcpv(mycpv, mydb=metadata)