summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/__init__.py25
-rw-r--r--pym/portage/__init__.py123
2 files changed, 76 insertions, 72 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 4b407f034..f03203217 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1103,7 +1103,7 @@ def get_mask_info(root_config, cpv, pkgsettings,
metadata = None
if metadata and not built:
pkgsettings.setcpv(cpv, mydb=metadata)
- metadata["USE"] = pkgsettings.get("USE", "")
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
if metadata is None:
mreasons = ["corruption"]
else:
@@ -2119,7 +2119,7 @@ class depgraph(object):
metadata = dict(izip(self._mydbapi_keys,
portdb.aux_get(mykey, self._mydbapi_keys)))
pkgsettings.setcpv(mykey, mydb=metadata)
- metadata["USE"] = pkgsettings["USE"]
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
pkg = Package(type_name="ebuild", root=myroot,
cpv=mykey, metadata=metadata, onlydeps=onlydeps)
args.append(PackageArg(arg=x, package=pkg,
@@ -2427,7 +2427,7 @@ class depgraph(object):
if not built:
if (is_virt or "?" in metadata["LICENSE"]):
pkgsettings.setcpv(cpv, mydb=metadata)
- metadata["USE"] = pkgsettings["USE"]
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
else:
metadata["USE"] = ""
@@ -2615,7 +2615,7 @@ class depgraph(object):
if not built:
if "?" in metadata["LICENSE"]:
pkgsettings.setcpv(cpv, mydb=metadata)
- metadata["USE"] = pkgsettings.get("USE","")
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
else:
metadata["USE"] = ""
myarg = None
@@ -2672,7 +2672,7 @@ class depgraph(object):
pkgsettings.setcpv(myeb, mydb=mydb)
else:
pkgsettings.setcpv(cpv, mydb=mydb)
- now_use = pkgsettings["USE"].split()
+ now_use = pkgsettings["PORTAGE_USE"].split()
forced_flags = set()
forced_flags.update(pkgsettings.useforce)
forced_flags.update(pkgsettings.usemask)
@@ -2698,7 +2698,7 @@ class depgraph(object):
old_use = vardb.aux_get(cpv, ["USE"])[0].split()
old_iuse = set(filter_iuse_defaults(
vardb.aux_get(cpv, ["IUSE"])[0].split()))
- cur_use = pkgsettings["USE"].split()
+ cur_use = pkgsettings["PORTAGE_USE"].split()
cur_iuse = set(filter_iuse_defaults(
metadata["IUSE"].split()))
reinstall_for_flags = \
@@ -2729,7 +2729,7 @@ class depgraph(object):
db.aux_get(cpv, self._mydbapi_keys)))
if not built:
pkgsettings.setcpv(cpv, mydb=metadata)
- metadata["USE"] = pkgsettings.get("USE","")
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
myeb = cpv
matched_packages.append(
Package(type_name=pkg_type, root=root,
@@ -3652,7 +3652,7 @@ class depgraph(object):
repo_path_real = os.path.dirname(os.path.dirname(
os.path.dirname(ebuild_path)))
pkgsettings.setcpv(pkg_key, mydb=mydbapi)
- metadata["USE"] = pkgsettings["USE"]
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
else:
repo_path_real = portdb.getRepositoryPath(repo_name)
pkg_use = metadata["USE"].split()
@@ -4242,7 +4242,8 @@ class depgraph(object):
if pkg_type == "ebuild":
pkgsettings = self.pkgsettings[myroot]
pkgsettings.setcpv(pkg_key, mydb=fakedb[myroot])
- fakedb[myroot].aux_update(pkg_key, {"USE":pkgsettings["USE"]})
+ fakedb[myroot].aux_update(pkg_key,
+ {"USE":pkgsettings["PORTAGE_USE"]})
self.spinner.update()
class RepoDisplay(object):
@@ -4532,7 +4533,7 @@ class MergeTask(object):
metadata.update(izip(metadata_keys,
mydbapi.aux_get(pkg_key, metadata_keys)))
pkgsettings.setcpv(pkg_key, mydb=mydbapi)
- metadata["USE"] = pkgsettings["USE"]
+ metadata["USE"] = pkgsettings["PORTAGE_USE"]
else:
if pkg_type == "binary":
mydbapi = bindb
@@ -6282,8 +6283,8 @@ def action_info(settings, trees, myopts, myfiles):
if portdb.cpv_exists(pkg):
mydb = portdb
pkgsettings.setcpv(pkg, mydb=mydb)
- if valuesmap["IUSE"].intersection(pkgsettings["USE"].split()) != \
- valuesmap["USE"]:
+ if valuesmap["IUSE"].intersection(
+ pkgsettings["PORTAGE_USE"].split()) != valuesmap["USE"]:
diff_values["USE"] = valuesmap["USE"]
# If a difference was found, print the info for
# this package.
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 8bc7a8c82..634fe4ceb 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1292,7 +1292,7 @@ class config(object):
# Blacklist vars that could interfere with portage internals.
for blacklisted in "CATEGORY", "PKGUSE", "PORTAGE_CONFIGROOT", \
- "ROOT":
+ "PORTAGE_IUSE", "PORTAGE_USE", "ROOT":
for cfg in self.lookuplist:
cfg.pop(blacklisted, None)
del blacklisted, cfg
@@ -1836,6 +1836,7 @@ class config(object):
self.modifying()
if self.mycpv == mycpv:
return
+ ebuild_phase = self.get("EBUILD_PHASE")
has_changed = False
self.mycpv = mycpv
cp = dep_getkey(mycpv)
@@ -1924,6 +1925,63 @@ class config(object):
if has_changed:
self.reset(keeping_pkg=1,use_cache=use_cache)
+ # Filter out USE flags that aren't part of IUSE. This has to
+ # be done for every setcpv() call since practically every
+ # package has different IUSE. Some flags are considered to
+ # be implicit members of IUSE:
+ #
+ # * Flags derived from ARCH
+ # * Flags derived from USE_EXPAND_HIDDEN variables
+ # * Masked flags, such as those from {,package}use.mask
+ # * Forced flags, such as those from {,package}use.force
+ # * build and bootstrap flags used by bootstrap.sh
+
+ usesplit = self["USE"].split()
+ iuse_implicit = set(x.lstrip("+-") for x in iuse.split())
+
+ # Flags derived from ARCH.
+ arch = self.configdict["defaults"].get("ARCH")
+ if arch:
+ iuse_implicit.add(arch)
+ iuse_implicit.update(self.get("PORTAGE_ARCHLIST", "").split())
+
+ # Flags derived from USE_EXPAND_HIDDEN variables
+ # such as ELIBC, KERNEL, and USERLAND.
+ use_expand_hidden = self.get("USE_EXPAND_HIDDEN", "").split()
+ use_expand_hidden_raw = use_expand_hidden
+ 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 masked or forced.
+ iuse_implicit.update(self.usemask)
+ iuse_implicit.update(self.useforce)
+
+ # build and bootstrap flags used by bootstrap.sh
+ iuse_implicit.add("build")
+ iuse_implicit.add("bootstrap")
+
+ if ebuild_phase:
+ iuse_grep = iuse_implicit.copy()
+ if use_expand_hidden_raw:
+ for x in use_expand_hidden_raw:
+ iuse_grep.add(x.lower() + "_.*")
+ if iuse_grep:
+ iuse_grep = "^(%s)$" % "|".join(sorted(iuse_grep))
+ else:
+ iuse_grep = ""
+ self.configdict["pkg"]["PORTAGE_IUSE"] = iuse_grep
+
+ # 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 in iuse_implicit))
+
def getMaskAtom(self, cpv, metadata):
"""
Take a package and return a matching package.mask atom, or None if no
@@ -2135,7 +2193,7 @@ class config(object):
return
if isinstance(mydbapi, portdbapi):
self.setcpv(mycpv, mydb=mydbapi)
- myuse = self["USE"]
+ myuse = self["PORTAGE_USE"]
elif isinstance(mydbapi, dict):
myuse = mydbapi["USE"]
else:
@@ -2415,64 +2473,9 @@ class config(object):
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
- # * Masked flags, such as those from {,package}use.mask
- # * Forced flags, such as those from {,package}use.force
- # * build and bootstrap flags used by bootstrap.sh
-
- # Do this even when there's no package since setcpv() can
- # optimize away regenerate() calls.
- iuse_implicit = set(iuse)
-
- # Flags derived from ARCH.
- if arch:
- iuse_implicit.add(arch)
- iuse_implicit.update(self.get("PORTAGE_ARCHLIST", "").split())
-
- # Flags derived from USE_EXPAND_HIDDEN variables
- # such as ELIBC, KERNEL, and USERLAND.
- use_expand_hidden = self.get("USE_EXPAND_HIDDEN", "").split()
- use_expand_hidden_raw = use_expand_hidden
- 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 masked or forced.
- iuse_implicit.update(self.usemask)
- iuse_implicit.update(self.useforce)
-
- # build and bootstrap flags used by bootstrap.sh
- iuse_implicit.add("build")
- iuse_implicit.add("bootstrap")
-
- iuse_grep = iuse_implicit.copy()
- if use_expand_hidden_raw:
- for x in use_expand_hidden_raw:
- iuse_grep.add(x.lower() + "_.*")
- if iuse_grep:
- iuse_grep = "^(%s)$" % "|".join(sorted(iuse_grep))
- else:
- iuse_grep = ""
- self["PORTAGE_IUSE"] = iuse_grep
-
usesplit = [x for x in usesplit if \
x not in self.usemask]
- # 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["PORTAGE_USE"] = " ".join(sorted(
- x for x in usesplit if \
- x in iuse_implicit))
- self.backup_changes("PORTAGE_USE")
-
usesplit.sort()
self.configlist[-1]["USE"]= " ".join(usesplit)
@@ -2700,7 +2703,7 @@ class config(object):
def selinux_enabled(self):
if getattr(self, "_selinux_enabled", None) is None:
self._selinux_enabled = 0
- if "selinux" in self["USE"].split():
+ if "selinux" in self["PORTAGE_USE"].split():
if "selinux" in globals():
if selinux.is_selinux_enabled() == 1:
self._selinux_enabled = 1
@@ -5393,7 +5396,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
if use=="yes":
if myuse is None:
#default behavior
- myusesplit = mysettings["USE"].split()
+ myusesplit = mysettings["PORTAGE_USE"].split()
else:
myusesplit = myuse
# We've been given useflags to use.
@@ -5718,7 +5721,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
return ["corruption"]
if "?" in metadata["LICENSE"]:
settings.setcpv(p, mydb=metadata)
- metadata["USE"] = settings.get("USE", "")
+ metadata["USE"] = settings["PORTAGE_USE"]
else:
metadata["USE"] = ""
mycp=mysplit[0]+"/"+mysplit[1]