aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2018-08-11 14:04:05 -0700
committerZac Medico <zmedico@gentoo.org>2018-08-11 17:40:32 -0700
commit45986341a80cfb01dad470f56f02b210b3ebf753 (patch)
tree7a609fdcfbd417e3edbf72537fc64165562d3a82
parentMake features USE respect RESTRICT=test (bug 663278) (diff)
downloadportage-45986341a80cfb01dad470f56f02b210b3ebf753.tar.gz
portage-45986341a80cfb01dad470f56f02b210b3ebf753.tar.bz2
portage-45986341a80cfb01dad470f56f02b210b3ebf753.zip
Support !test? conditionals in RESTRICT (bug 663278)
Since RESTRICT="!test? ( test )" can be very useful within the context of bug 663278, pass an appropriate uselist parameter to the RESTRICT use_reduce call. Make self.configdict["features"]["USE"] independent of IUSE and RESTRICT, so that the same value can be shared between packages with different settings, which is important when evaluating USE conditional RESTRICT. When the evaluated value of RESTRICT contains "test", handle it like IUSE="-test", since features USE is independent of RESTRICT. Bug: https://bugs.gentoo.org/663278
-rw-r--r--lib/portage/package/ebuild/config.py40
1 files changed, 26 insertions, 14 deletions
diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py
index 220fa31bb..3b01095d0 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -1457,6 +1457,7 @@ class config(object):
cp = cpv_getkey(mycpv)
cpv_slot = self.mycpv
pkginternaluse = ""
+ pkginternaluse_list = []
feature_use = []
iuse = ""
pkg_configdict = self.configdict["pkg"]
@@ -1513,13 +1514,12 @@ class config(object):
cpv_slot = self.mycpv
else:
cpv_slot = pkg
- pkginternaluse = []
for x in iuse.split():
if x.startswith("+"):
- pkginternaluse.append(x[1:])
+ pkginternaluse_list.append(x[1:])
elif x.startswith("-"):
- pkginternaluse.append(x)
- pkginternaluse = " ".join(pkginternaluse)
+ pkginternaluse_list.append(x)
+ pkginternaluse = " ".join(pkginternaluse_list)
eapi_attrs = _get_eapi_attrs(eapi)
@@ -1596,6 +1596,9 @@ class config(object):
# regenerate() call in order to ensure that self.features
# is accurate.
has_changed = True
+ # Prevent stale features USE from corrupting the evaluation
+ # of USE conditional RESTRICT.
+ self.configdict["features"]["USE"] = ""
self._penv = []
cpdict = self._penvdict.get(cp)
@@ -1675,24 +1678,33 @@ class config(object):
restrict = use_reduce(raw_restrict,
uselist=built_use, flat=True)
else:
- # Use matchnone=True to ignore USE conditional parts
- # of RESTRICT, since we want to know whether to mask
- # the "test" flag _before_ we know the USE values
- # that would be needed to evaluate the USE
- # conditionals (see bug #273272).
restrict = use_reduce(raw_restrict,
- matchnone=True, flat=True)
+ uselist=frozenset(x for x in self['USE'].split()
+ if x in explicit_iuse or iuse_implicit_match(x)),
+ flat=True)
except PortageException:
pass
else:
restrict_test = "test" in restrict
- if not restrict_test and ("test" in explicit_iuse or iuse_implicit_match("test")):
- if "test" in self.features:
- feature_use.append("test")
+ pkginternaluse_before = pkginternaluse
+ if "test" in self.features:
+ # This is independent of IUSE and RESTRICT, so that the same
+ # value can be shared between packages with different settings,
+ # which is important when evaluating USE conditional RESTRICT
+ # above.
+ feature_use.append("test")
+
+ if restrict_test:
+ # Handle it like IUSE="-test", since features USE is
+ # independent of RESTRICT.
+ pkginternaluse_list.append("-test")
+ pkginternaluse = " ".join(pkginternaluse_list)
+ self.configdict["pkginternal"]["USE"] = pkginternaluse
feature_use = " ".join(feature_use)
- if feature_use != self.configdict["features"].get("USE", ""):
+ if (feature_use != self.configdict["features"].get("USE", "") or
+ pkginternaluse is not pkginternaluse_before):
self.configdict["features"]["USE"] = feature_use
# TODO: can we avoid that?
self.reset(keeping_pkg=1)