summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py203
1 files changed, 88 insertions, 115 deletions
diff --git a/pym/portage.py b/pym/portage.py
index aa5234ca7..b7c1db52b 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -1165,7 +1165,6 @@ class config:
self.user_profile_dir = None
self.local_config = local_config
- self._use_wildcards = False
self._env_d_mtime = 0
if clone:
@@ -1224,7 +1223,6 @@ class config:
self.prevmaskdict = copy.deepcopy(clone.prevmaskdict)
self.pprovideddict = copy.deepcopy(clone.pprovideddict)
self.features = copy.deepcopy(clone.features)
- self._use_wildcards = copy.deepcopy(clone._use_wildcards)
else:
def check_var_directory(varname, var):
@@ -1524,11 +1522,6 @@ class config:
if not self.pusedict.has_key(cp):
self.pusedict[cp] = {}
self.pusedict[cp][key] = pusedict[key]
- if not self._use_wildcards:
- for x in pusedict[key]:
- if x.endswith("_*"):
- self._use_wildcards = True
- break
#package.keywords
pkgdict = grabdict_package(
@@ -2010,19 +2003,7 @@ 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
- test_use_changed = False
- if "test" in self.features:
- test_use_changed = \
- bool(re.search(r'(^|\s)[-+]?test(\s|$)', iuse)) != \
- ("test" in self["USE"].split())
- if self.get("EBUILD_PHASE") or \
- self._use_wildcards or \
- test_use_changed:
- # Without this conditional, regenerate() would be called
- # *every* time.
- has_changed = True
+ self.configdict["pkg"]["IUSE"] = iuse
# Always set known good values for these variables, since
# corruption of these can cause problems:
@@ -2044,7 +2025,7 @@ class config:
# * Forced flags, such as those from {,package}use.force
# * build and bootstrap flags used by bootstrap.sh
- usesplit = self["USE"].split()
+ use = set(self["USE"].split())
iuse_implicit = set(x.lstrip("+-") for x in iuse.split())
# Flags derived from ARCH.
@@ -2060,7 +2041,7 @@ class config:
if use_expand_hidden:
use_expand_hidden = re.compile("^(%s)_.*" % \
("|".join(x.lower() for x in use_expand_hidden)))
- for x in usesplit:
+ for x in use:
if use_expand_hidden.match(x):
iuse_implicit.add(x)
@@ -2083,11 +2064,88 @@ class config:
iuse_grep = ""
self.configdict["pkg"]["PORTAGE_IUSE"] = iuse_grep
+ ebuild_force_test = self.get("EBUILD_FORCE_TEST") == "1"
+ if ebuild_force_test and ebuild_phase and \
+ not hasattr(self, "_ebuild_force_test_msg_shown"):
+ self._ebuild_force_test_msg_shown = True
+ writemsg("Forcing test.\n", noiselevel=-1)
+ if "test" in self.features and "test" in iuse_implicit:
+ if "test" in self.usemask and not ebuild_force_test:
+ # "test" is in IUSE and USE=test is masked, so execution
+ # of src_test() probably is not reliable. Therefore,
+ # temporarily disable FEATURES=test just for this package.
+ self["FEATURES"] = " ".join(x for x in self.features \
+ if x != "test")
+ use.discard("test")
+ else:
+ use.add("test")
+ if ebuild_force_test:
+ self.usemask.discard("test")
+
+ # Use the calculated USE flags to regenerate the USE_EXPAND flags so
+ # that they are consistent.
+ use_expand = self.get("USE_EXPAND", "").split()
+ for var in use_expand:
+ prefix = var.lower() + "_"
+ prefix_len = len(prefix)
+ expand_flags = set([ x[prefix_len:] for x in use \
+ if x.startswith(prefix) ])
+ var_split = self.get(var, "").split()
+ # Preserve the order of var_split because it can matter for things
+ # like LINGUAS.
+ var_split = [ x for x in var_split if x in expand_flags ]
+ var_split.extend(expand_flags.difference(var_split))
+ has_wildcard = "*" in var_split
+ if has_wildcard:
+ var_split = [ x for x in var_split if x != "*" ]
+ has_iuse = False
+ for x in iuse_implicit:
+ if x.startswith(prefix):
+ has_iuse = True
+ break
+ if has_wildcard:
+ # * means to enable everything in IUSE that's not masked
+ if has_iuse:
+ for x in iuse_implicit:
+ if x.startswith(prefix) and x not in self.usemask:
+ suffix = x[prefix_len:]
+ if suffix in var_split:
+ continue
+ var_split.append(suffix)
+ use.add(x)
+ else:
+ # If there is a wildcard and no matching flags in IUSE then
+ # LINGUAS should be unset so that all .mo files are
+ # installed.
+ var_split = []
+ var_split = [x for x in var_split if x in iuse_implicit]
+ if var_split:
+ self[var] = " ".join(var_split)
+ else:
+ # Don't export empty USE_EXPAND vars unless the user config
+ # exports them as empty. This is required for vars such as
+ # LINGUAS, where unset and empty have different meanings.
+ if has_wildcard:
+ # ebuild.sh will see this and unset the variable so
+ # that things like LINGUAS work properly
+ self[var] = "*"
+ else:
+ if has_iuse:
+ self[var] = ""
+ else:
+ # It's not in IUSE, so just allow the variable content
+ # to pass through if it is defined somewhere. This
+ # allows packages that support LINGUAS but don't
+ # declare it in IUSE to use the variable outside of the
+ # USE_EXPAND context.
+ pass
+
# Filtered for the ebuild environment. Store this in a separate
# attribute since we still want to be able to see global USE
# settings for things like emerge --info.
+
self.configdict["pkg"]["PORTAGE_USE"] = " ".join(sorted(
- x for x in usesplit if \
+ x for x in use if \
x in iuse_implicit))
def _getMaskAtom(self, cpv, metadata):
@@ -2431,103 +2489,18 @@ class config:
continue
myflags.add(var_lower + "_" + x)
- myflags.update(self.useforce)
-
- iuse = self.configdict["pkg"].get("IUSE","").split()
- iuse = [ x.lstrip("+-") for x in iuse ]
- # FEATURES=test should imply USE=test
if not hasattr(self, "features"):
- self.features = list(sorted(set(
- self.configlist[-1].get("FEATURES","").split())))
+ self.features = sorted(set(
+ self.configlist[-1].get("FEATURES","").split()))
self["FEATURES"] = " ".join(self.features)
- ebuild_force_test = self.get("EBUILD_FORCE_TEST") == "1"
- if ebuild_force_test and \
- self.get("EBUILD_PHASE") == "test" and \
- not hasattr(self, "_ebuild_force_test_msg_shown"):
- self._ebuild_force_test_msg_shown = True
- writemsg("Forcing test.\n", noiselevel=-1)
- if "test" in self.features and "test" in iuse:
- if "test" in self.usemask and not ebuild_force_test:
- # "test" is in IUSE and USE=test is masked, so execution
- # of src_test() probably is not reliable. Therefore,
- # temporarily disable FEATURES=test just for this package.
- self["FEATURES"] = " ".join(x for x in self.features \
- if x != "test")
- myflags.discard("test")
- else:
- myflags.add("test")
- if ebuild_force_test:
- self.usemask.discard("test")
-
- usesplit = [ x for x in myflags if \
- x not in self.usemask]
-
- # Use the calculated USE flags to regenerate the USE_EXPAND flags so
- # that they are consistent.
- for var in use_expand:
- prefix = var.lower() + "_"
- prefix_len = len(prefix)
- expand_flags = set([ x[prefix_len:] for x in usesplit \
- if x.startswith(prefix) ])
- var_split = self.get(var, "").split()
- # Preserve the order of var_split because it can matter for things
- # like LINGUAS.
- var_split = [ x for x in var_split if x in expand_flags ]
- var_split.extend(expand_flags.difference(var_split))
- has_wildcard = "*" in var_split
- if has_wildcard:
- var_split = [ x for x in var_split if x != "*" ]
- self._use_wildcards = True
- has_iuse = False
- for x in iuse:
- if x.startswith(prefix):
- has_iuse = True
- break
- if has_wildcard:
- # * means to enable everything in IUSE that's not masked
- if has_iuse:
- for x in iuse:
- if x.startswith(prefix) and x not in self.usemask:
- suffix = x[prefix_len:]
- if suffix in var_split:
- continue
- var_split.append(suffix)
- usesplit.append(x)
- else:
- # If there is a wildcard and no matching flags in IUSE then
- # LINGUAS should be unset so that all .mo files are
- # installed.
- var_split = []
- if var_split:
- self[var] = " ".join(var_split)
- else:
- # Don't export empty USE_EXPAND vars unless the user config
- # exports them as empty. This is required for vars such as
- # LINGUAS, where unset and empty have different meanings.
- if has_wildcard:
- # ebuild.sh will see this and unset the variable so
- # that things like LINGUAS work properly
- self[var] = "*"
- else:
- if has_iuse:
- self[var] = ""
- else:
- # It's not in IUSE, so just allow the variable content
- # to pass through if it is defined somewhere. This
- # allows packages that support LINGUAS but don't
- # declare it in IUSE to use the variable outside of the
- # USE_EXPAND context.
- pass
+ myflags.update(self.useforce)
arch = self.configdict["defaults"].get("ARCH")
- if arch and arch not in usesplit:
- usesplit.append(arch)
-
- usesplit = [x for x in usesplit if \
- x not in self.usemask]
+ if arch:
+ myflags.add(arch)
- usesplit.sort()
- self.configlist[-1]["USE"]= " ".join(usesplit)
+ myflags.difference_update(self.usemask)
+ self.configlist[-1]["USE"]= " ".join(sorted(myflags))
self.already_in_regenerate = 0