Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] Support !test? conditionals in RESTRICT (bug 663278)
Date: Sun, 12 Aug 2018 00:56:54
Message-Id: 20180812005000.12860-1-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] Support !test? conditionals in RESTRICT (bug 663278) by Zac Medico
1 Since RESTRICT="!test? ( test )" can be very useful within the context
2 of bug 663278, pass an appropriate uselist parameter to the RESTRICT
3 use_reduce call. Make self.configdict["features"]["USE"] independent
4 of IUSE and RESTRICT, so that the same value can be shared between
5 packages with different settings, which is important when evaluating
6 USE conditional RESTRICT. When the evaluated value of RESTRICT contains
7 "test", handle it like IUSE="-test", since features USE is independent
8 of RESTRICT.
9
10 Bug: https://bugs.gentoo.org/663278
11 ---
12 [PATCH v2] Make self.configdict["features"]["USE"] independent
13 of IUSE and RESTRICT, so that the same value can be shared between
14 packages with different settings, which is important when evaluating
15 USE conditional RESTRICT. When the evaluated value of RESTRICT contains
16 "test", handle it like IUSE="-test", since features USE is independent
17 of RESTRICT.
18
19 lib/portage/package/ebuild/config.py | 40 +++++++++++++++++++++++-------------
20 1 file changed, 26 insertions(+), 14 deletions(-)
21
22 diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py
23 index 220fa31bb..3b01095d0 100644
24 --- a/lib/portage/package/ebuild/config.py
25 +++ b/lib/portage/package/ebuild/config.py
26 @@ -1457,6 +1457,7 @@ class config(object):
27 cp = cpv_getkey(mycpv)
28 cpv_slot = self.mycpv
29 pkginternaluse = ""
30 + pkginternaluse_list = []
31 feature_use = []
32 iuse = ""
33 pkg_configdict = self.configdict["pkg"]
34 @@ -1513,13 +1514,12 @@ class config(object):
35 cpv_slot = self.mycpv
36 else:
37 cpv_slot = pkg
38 - pkginternaluse = []
39 for x in iuse.split():
40 if x.startswith("+"):
41 - pkginternaluse.append(x[1:])
42 + pkginternaluse_list.append(x[1:])
43 elif x.startswith("-"):
44 - pkginternaluse.append(x)
45 - pkginternaluse = " ".join(pkginternaluse)
46 + pkginternaluse_list.append(x)
47 + pkginternaluse = " ".join(pkginternaluse_list)
48
49 eapi_attrs = _get_eapi_attrs(eapi)
50
51 @@ -1596,6 +1596,9 @@ class config(object):
52 # regenerate() call in order to ensure that self.features
53 # is accurate.
54 has_changed = True
55 + # Prevent stale features USE from corrupting the evaluation
56 + # of USE conditional RESTRICT.
57 + self.configdict["features"]["USE"] = ""
58
59 self._penv = []
60 cpdict = self._penvdict.get(cp)
61 @@ -1675,24 +1678,33 @@ class config(object):
62 restrict = use_reduce(raw_restrict,
63 uselist=built_use, flat=True)
64 else:
65 - # Use matchnone=True to ignore USE conditional parts
66 - # of RESTRICT, since we want to know whether to mask
67 - # the "test" flag _before_ we know the USE values
68 - # that would be needed to evaluate the USE
69 - # conditionals (see bug #273272).
70 restrict = use_reduce(raw_restrict,
71 - matchnone=True, flat=True)
72 + uselist=frozenset(x for x in self['USE'].split()
73 + if x in explicit_iuse or iuse_implicit_match(x)),
74 + flat=True)
75 except PortageException:
76 pass
77 else:
78 restrict_test = "test" in restrict
79
80 - if not restrict_test and ("test" in explicit_iuse or iuse_implicit_match("test")):
81 - if "test" in self.features:
82 - feature_use.append("test")
83 + pkginternaluse_before = pkginternaluse
84 + if "test" in self.features:
85 + # This is independent of IUSE and RESTRICT, so that the same
86 + # value can be shared between packages with different settings,
87 + # which is important when evaluating USE conditional RESTRICT
88 + # above.
89 + feature_use.append("test")
90 +
91 + if restrict_test:
92 + # Handle it like IUSE="-test", since features USE is
93 + # independent of RESTRICT.
94 + pkginternaluse_list.append("-test")
95 + pkginternaluse = " ".join(pkginternaluse_list)
96 + self.configdict["pkginternal"]["USE"] = pkginternaluse
97
98 feature_use = " ".join(feature_use)
99 - if feature_use != self.configdict["features"].get("USE", ""):
100 + if (feature_use != self.configdict["features"].get("USE", "") or
101 + pkginternaluse is not pkginternaluse_before):
102 self.configdict["features"]["USE"] = feature_use
103 # TODO: can we avoid that?
104 self.reset(keeping_pkg=1)
105 --
106 2.16.4