When ACCEPT_CHOSTS is set, enable CHOST masking for unbuilt ebuilds. This
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:34:01 +0000 (06:34 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:34:01 +0000 (06:34 -0000)
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 <solar@g.o> for reporting the problem. (trunk r12741)

svn path=/main/branches/2.1.6/; revision=12990

pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/porttree.py

index 9173d58bb21d7494720b8b89a62380a8d1d28905..94dc3f465571bd209eed38db86cb6ba43a9d74dd 100644 (file)
@@ -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
 
index 5b661ce2438f37507ff91ad3faf5c7496f58f2b1..20de5af10d4d4015ff99e297ddc4558a19cf8a85 100644 (file)
@@ -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,
index dd2257afea9f2ef2b38913277de2fc49b2ff172c..7ac281e8b50b94dae8b6c60b8316bb2b59b8bd8f 100644 (file)
@@ -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)