Bug #176467 - Filter out USE flags that aren't part of IUSE.
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Dec 2007 06:49:32 +0000 (06:49 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Dec 2007 06:49:32 +0000 (06:49 -0000)
Some flags are considered to be implicit members of IUSE:

* Flags derived from ARCH
* Flags derived from USE_EXPAND_HIDDEN variables
* Forced flags, such as those from {,package}use.force

(trunk r8944)

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

pym/portage.py

index 9cf99b196e167985a4b5d00f1deb544721dd0732..eed8dd158d4a331f670a4f8db803b2c4e7613775 100644 (file)
@@ -2362,11 +2362,41 @@ class config:
                                                # USE_EXPAND context.
                                                pass
 
-               # Pre-Pend ARCH variable to USE settings so '-*' in env doesn't kill arch.
-               if self.configdict["defaults"].has_key("ARCH"):
-                       if self.configdict["defaults"]["ARCH"]:
-                               if self.configdict["defaults"]["ARCH"] not in usesplit:
-                                       usesplit.insert(0,self.configdict["defaults"]["ARCH"])
+               arch = self.configdict["defaults"].get("ARCH")
+               if arch and arch not in usesplit:
+                       usesplit.append(arch)
+
+               # Filter out USE flags that aren't part of IUSE. Some
+               # flags are considered to be implicit members of IUSE:
+               #
+               #  * Flags derived from ARCH
+               #  * Flags derived from USE_EXPAND_HIDDEN variables
+               #  * Forced flags, such as those from {,package}use.force
+
+               if self.mycpv:
+                       iuse_implicit = set(iuse)
+
+                       # Flags derived from ARCH.
+                       if arch:
+                               iuse_implicit.add(arch)
+
+                       # Flags derived from USE_EXPAND_HIDDEN variables
+                       # such as ELIBC, KERNEL, and USERLAND.
+                       use_expand_hidden = self.get("USE_EXPAND_HIDDEN", "").split()
+                       if use_expand_hidden:
+                               use_expand_hidden = re.compile("^(%s)_.*" % \
+                                       ("|".join(x.lower() for x in use_expand_hidden)))
+                               for x in usesplit:
+                                       if use_expand_hidden.match(x):
+                                               iuse_implicit.add(x)
+
+                       # Flags that have been forced.
+                       iuse_implicit.update(x for x in self.useforce \
+                               if x not in self.usemask)
+
+                       usesplit = [x for x in usesplit if \
+                               x in iuse_implicit and \
+                               x not in self.usemask]
 
                usesplit.sort()
                self.configlist[-1]["USE"]= " ".join(usesplit)