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] Make features USE respect RESTRICT=test (bug 663278)
Date: Sat, 11 Aug 2018 20:08:46
Message-Id: 20180811200521.17178-1-zmedico@gentoo.org
1 Make RESTRICT=test prevent the "test" USE flag from being added to
2 features USE flags when FEATURES=test is enabled, in order to preserve
3 default behavior for ebuilds that set RESTRICT=test. The code that sets
4 the restrict_test variable in the setcpv method must execute earlier
5 now, but the logic is unchanged. Note that it is still possible to
6 enable USE=test for ebuilds that set RESTRICT=test, but FEATURES=test
7 will not do it, so it will only be triggered by an explicit USE=test
8 setting by the user or profile.
9
10 Fixes: 8c5598c1af2c ("Replace implicit {FEATURES->USE}=test forcing with USE default")
11 Bug: https://bugs.gentoo.org/663278
12 ---
13 lib/portage/package/ebuild/config.py | 50 ++++++++++++++++++------------------
14 1 file changed, 25 insertions(+), 25 deletions(-)
15
16 diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py
17 index 3e0081829..220fa31bb 100644
18 --- a/lib/portage/package/ebuild/config.py
19 +++ b/lib/portage/package/ebuild/config.py
20 @@ -1663,7 +1663,31 @@ class config(object):
21 else:
22 iuse_implicit_match = self._iuse_implicit_match
23
24 - if "test" in explicit_iuse or iuse_implicit_match("test"):
25 + if pkg is None:
26 + raw_restrict = pkg_configdict.get("RESTRICT")
27 + else:
28 + raw_restrict = pkg._raw_metadata["RESTRICT"]
29 +
30 + restrict_test = False
31 + if raw_restrict:
32 + try:
33 + if built_use is not None:
34 + restrict = use_reduce(raw_restrict,
35 + uselist=built_use, flat=True)
36 + else:
37 + # Use matchnone=True to ignore USE conditional parts
38 + # of RESTRICT, since we want to know whether to mask
39 + # the "test" flag _before_ we know the USE values
40 + # that would be needed to evaluate the USE
41 + # conditionals (see bug #273272).
42 + restrict = use_reduce(raw_restrict,
43 + matchnone=True, flat=True)
44 + except PortageException:
45 + pass
46 + else:
47 + restrict_test = "test" in restrict
48 +
49 + if not restrict_test and ("test" in explicit_iuse or iuse_implicit_match("test")):
50 if "test" in self.features:
51 feature_use.append("test")
52
53 @@ -1721,30 +1745,6 @@ class config(object):
54 self.configdict["env"].addLazySingleton(
55 "PORTAGE_IUSE", _lazy_iuse_regex, portage_iuse)
56
57 - if pkg is None:
58 - raw_restrict = pkg_configdict.get("RESTRICT")
59 - else:
60 - raw_restrict = pkg._raw_metadata["RESTRICT"]
61 -
62 - restrict_test = False
63 - if raw_restrict:
64 - try:
65 - if built_use is not None:
66 - restrict = use_reduce(raw_restrict,
67 - uselist=built_use, flat=True)
68 - else:
69 - # Use matchnone=True to ignore USE conditional parts
70 - # of RESTRICT, since we want to know whether to mask
71 - # the "test" flag _before_ we know the USE values
72 - # that would be needed to evaluate the USE
73 - # conditionals (see bug #273272).
74 - restrict = use_reduce(raw_restrict,
75 - matchnone=True, flat=True)
76 - except PortageException:
77 - pass
78 - else:
79 - restrict_test = "test" in restrict
80 -
81 ebuild_force_test = not restrict_test and \
82 self.get("EBUILD_FORCE_TEST") == "1"
83
84 --
85 2.16.4