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] config: regenerate USE for conditional RESTRICT (bug 664104)
Date: Mon, 20 Aug 2018 22:15:38
Message-Id: 20180820221523.2342-1-zmedico@gentoo.org
1 When the features USE state changes due to package.env settings,
2 regenerate USE for correct evaluation of conditional RESTRICT.
3
4 Fixes: 45986341a80c ("Support !test? conditionals in RESTRICT (bug 663278)")
5 Bug: https://bugs.gentoo.org/664104
6 ---
7 lib/portage/package/ebuild/config.py | 39 ++++++++++++++++++------------------
8 1 file changed, 20 insertions(+), 19 deletions(-)
9
10 diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py
11 index 9fbf7e8fc..a68df5807 100644
12 --- a/lib/portage/package/ebuild/config.py
13 +++ b/lib/portage/package/ebuild/config.py
14 @@ -1666,8 +1666,22 @@ class config(object):
15 has_changed = True
16
17 if has_changed:
18 + # This can modify self.features due to package.env settings.
19 self.reset(keeping_pkg=1)
20
21 + if "test" in self.features:
22 + # This is independent of IUSE and RESTRICT, so that the same
23 + # value can be shared between packages with different settings,
24 + # which is important when evaluating USE conditional RESTRICT.
25 + feature_use.append("test")
26 +
27 + feature_use = " ".join(feature_use)
28 + if feature_use != self.configdict["features"]["USE"]:
29 + # Regenerate USE for evaluation of conditional RESTRICT.
30 + self.configdict["features"]["USE"] = feature_use
31 + self.reset(keeping_pkg=1)
32 + has_changed = True
33 +
34 if explicit_iuse is None:
35 explicit_iuse = frozenset(x.lstrip("+-") for x in iuse.split())
36 if eapi_attrs.iuse_effective:
37 @@ -1696,25 +1710,12 @@ class config(object):
38 else:
39 restrict_test = "test" in restrict
40
41 - pkginternaluse_before = pkginternaluse
42 - if "test" in self.features:
43 - # This is independent of IUSE and RESTRICT, so that the same
44 - # value can be shared between packages with different settings,
45 - # which is important when evaluating USE conditional RESTRICT
46 - # above.
47 - feature_use.append("test")
48 -
49 - if restrict_test:
50 - # Handle it like IUSE="-test", since features USE is
51 - # independent of RESTRICT.
52 - pkginternaluse_list.append("-test")
53 - pkginternaluse = " ".join(pkginternaluse_list)
54 - self.configdict["pkginternal"]["USE"] = pkginternaluse
55 -
56 - feature_use = " ".join(feature_use)
57 - if (feature_use != self.configdict["features"].get("USE", "") or
58 - pkginternaluse is not pkginternaluse_before):
59 - self.configdict["features"]["USE"] = feature_use
60 + if restrict_test and "test" in self.features:
61 + # Handle it like IUSE="-test", since features USE is
62 + # independent of RESTRICT.
63 + pkginternaluse_list.append("-test")
64 + pkginternaluse = " ".join(pkginternaluse_list)
65 + self.configdict["pkginternal"]["USE"] = pkginternaluse
66 # TODO: can we avoid that?
67 self.reset(keeping_pkg=1)
68 has_changed = True
69 --
70 2.16.4