For bug #148702, automatically enable flags from IUSE if they correspond to unset...
authorZac Medico <zmedico@gentoo.org>
Sat, 9 Jun 2007 11:44:20 +0000 (11:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 9 Jun 2007 11:44:20 +0000 (11:44 -0000)
svn path=/main/branches/2.1.2/; revision=6781

pym/portage.py

index 3ace88c92c5a2029268ebca59d34182810dd5c4a..4cd51154ecb8b3ff0bfcf776d060926fe6971e7f 100644 (file)
@@ -1693,6 +1693,7 @@ class config:
                cp = dep_getkey(mycpv)
                cpv_slot = self.mycpv
                pkginternaluse = ""
+               iuse = ""
                if mydb:
                        slot, iuse = mydb.aux_get(self.mycpv, ["SLOT", "IUSE"])
                        cpv_slot = "%s:%s" % (self.mycpv, slot)
@@ -1753,6 +1754,9 @@ class config:
                        has_changed = True
                self.configdict["pkg"]["PKGUSE"] = self.puse[:] # For saving to PUSE file
                self.configdict["pkg"]["USE"]    = self.puse[:] # this gets appended to USE
+               if iuse != self.configdict["pkg"].get("IUSE",""):
+                       self.configdict["pkg"]["IUSE"] = iuse
+                       has_changed = True
                # CATEGORY is essential for doebuild calls
                self.configdict["pkg"]["CATEGORY"] = mycpv.split("/")[0]
                if has_changed:
@@ -1955,8 +1959,6 @@ class config:
                usesplit = [ x for x in myflags if \
                        x not in self.usemask]
 
-               usesplit.sort()
-
                # Use the calculated USE flags to regenerate the USE_EXPAND flags so
                # that they are consistent.
                for var in use_expand:
@@ -1974,6 +1976,18 @@ class config:
                                # exports them as empty.  This is required for vars such as
                                # LINGUAS, where unset and empty have different meanings.
                                self[var] = " ".join(var_split)
+                       else:
+                               # if unset, we enable everything in IUSE that's not masked
+                               iuse = self.configdict["pkg"].get("IUSE")
+                               if iuse:
+                                       var_split = []
+                                       for x in iuse.split():
+                                               x = x.lstrip("+-")
+                                               if x.startswith(prefix) and x not in self.usemask:
+                                                       var_split.append(x[prefix_len:])
+                                                       usesplit.append(x)
+                                       if var_split:
+                                               self[var] = " ".join(var_split)
 
                # Pre-Pend ARCH variable to USE settings so '-*' in env doesn't kill arch.
                if self.configdict["defaults"].has_key("ARCH"):
@@ -1981,6 +1995,7 @@ class config:
                                if self.configdict["defaults"]["ARCH"] not in usesplit:
                                        usesplit.insert(0,self.configdict["defaults"]["ARCH"])
 
+               usesplit.sort()
                self.configlist[-1]["USE"]= " ".join(usesplit)
 
                self.already_in_regenerate = 0