Add support for and ACCEPT_CHOSTS variable that controls masking behavior
authorZac Medico <zmedico@gentoo.org>
Sun, 15 Jun 2008 04:38:35 +0000 (04:38 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 15 Jun 2008 04:38:35 +0000 (04:38 -0000)
for binary packages wrt CHOST.  The variable is a space separated list of
chosts. It support regular expressions, so if the actual chost contains
any special characters then the user must escape them when setting
ACCEPT_CHOSTS. (trunk r10654)

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

bin/emerge
pym/portage.py

index db6985905361f28c6c0fbfabe73a60ce45af40ae..d607462bb0861c7ffb97ba018e32c8b541c23f36 100755 (executable)
@@ -1285,9 +1285,8 @@ def visible(pkgsettings, pkg):
        """
        if not pkg.metadata["SLOT"]:
                return False
-       if pkg.built and not pkg.installed:
-               pkg_chost = pkg.metadata.get("CHOST")
-               if pkg_chost and pkg_chost != pkgsettings["CHOST"]:
+       if pkg.built and not pkg.installed and "CHOST" in pkg.metadata:
+               if not pkgsettings._accept_chost(pkg):
                        return False
        if not portage.eapi_is_supported(pkg.metadata["EAPI"]):
                return False
@@ -1306,9 +1305,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:
-               pkg_chost = pkg.metadata.get("CHOST")
-               if pkg_chost and pkg_chost != pkgsettings["CHOST"]:
+       if pkg.built and not pkg.installed and "CHOST" in pkg.metadata:
+               if not pkgsettings._accept_chost(pkg):
                        mreasons.append("CHOST: %s" % \
                                pkg.metadata["CHOST"])
 
index 3bef63963193c796b2026151c097437b0cb049d8..8e1a620c6cfa5f6c7a9608bfc09619c8b36a0e24 100644 (file)
@@ -1159,6 +1159,7 @@ class config:
        ]
 
        _environ_filter = frozenset(_environ_filter)
+       _accept_chost_re = None
 
        def __init__(self, clone=None, mycpv=None, config_profile_path=None,
                config_incrementals=None, config_root=None, target_root=None,
@@ -2385,6 +2386,26 @@ class config:
                        missing = mygroups
                return missing
 
+       def _accept_chost(self, pkg):
+               """
+               @return True if pkg CHOST is accepted, False otherwise.
+               """
+               if self._accept_chost_re is None:
+                       accept_chost = self.get("ACCEPT_CHOSTS", "").split()
+                       if not accept_chost:
+                               chost = self.get("CHOST")
+                               if chost:
+                                       accept_chost.append(chost)
+                       if not accept_chost:
+                               self._accept_chost_re = re.compile(".*")
+                       elif len(accept_chost) == 1:
+                               self._accept_chost_re = re.compile(accept_chost[0])
+                       else:
+                               self._accept_chost_re = re.compile(
+                                       r'^(%s)$' % "|".join(accept_chost))
+               return self._accept_chost_re.match(
+                       pkg.metadata.get("CHOST", "")) is not None
+
        def setinst(self,mycpv,mydbapi):
                """This updates the preferences for old-style virtuals,
                affecting the behavior of dep_expand() and dep_check()