Discussion:
[gentoo-portage-dev] [PATCH] Support !test? conditionals in RESTRICT (bug 663278)
Zac Medico
2018-08-11 21:11:54 UTC
Permalink
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.

Bug: https://bugs.gentoo.org/663278
---
lib/portage/package/ebuild/config.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py
index 220fa31bb..353ee239c 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -1675,13 +1675,10 @@ 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:
--
2.16.4
Zac Medico
2018-08-12 00:50:00 UTC
Permalink
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
---
[PATCH v2] 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.

lib/portage/package/ebuild/config.py | 40 +++++++++++++++++++++++-------------
1 file 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)
--
2.16.4
Continue reading on narkive:
Search results for '[gentoo-portage-dev] [PATCH] Support !test? conditionals in RESTRICT (bug 663278)' (Questions and Answers)
18
replies
If Darwin's theory is true, why we don't see that apes are being changed to men?
started 2007-07-24 00:00:19 UTC
anthropology
Loading...