1 |
commit: 8c5598c1af2c4c96546f196e2213211ec9cd7e7a |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jun 4 08:21:45 2017 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jul 31 17:24:02 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8c5598c1 |
7 |
|
8 |
Replace implicit {FEATURES->USE}=test forcing with USE default |
9 |
|
10 |
Use an explicit USE_ORDER entry to control mapping FEATURES=test into |
11 |
default-enabled USE=test, rather than forcing/masking it depending |
12 |
on the state of FEATURES. |
13 |
|
14 |
This makes it possible for users to enable (or disable) USE=test |
15 |
independently of FEATURES. An example use case is installing test |
16 |
dependencies and building test cases without actually running tests |
17 |
at a particular moment which is something I've been doing quite |
18 |
frequently with LLVM. |
19 |
|
20 |
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org> |
21 |
Closes: https://github.com/gentoo/portage/pull/347 |
22 |
|
23 |
cnf/make.globals | 2 +- |
24 |
lib/portage/eapi.py | 2 +- |
25 |
lib/portage/package/ebuild/config.py | 52 ++++++---- |
26 |
.../tests/resolver/test_features_test_use.py | 108 ++++++++++++--------- |
27 |
man/make.conf.5 | 6 +- |
28 |
5 files changed, 102 insertions(+), 68 deletions(-) |
29 |
|
30 |
diff --git a/cnf/make.globals b/cnf/make.globals |
31 |
index 08a37a534..04a708af8 100644 |
32 |
--- a/cnf/make.globals |
33 |
+++ b/cnf/make.globals |
34 |
@@ -107,7 +107,7 @@ CONFIG_PROTECT="/etc" |
35 |
CONFIG_PROTECT_MASK="/etc/env.d" |
36 |
|
37 |
# Disable auto-use |
38 |
-USE_ORDER="env:pkg:conf:defaults:pkginternal:repo:env.d" |
39 |
+USE_ORDER="env:pkg:conf:defaults:pkginternal:features:repo:env.d" |
40 |
|
41 |
# Mode bits for ${WORKDIR} (see ebuild.5). |
42 |
PORTAGE_WORKDIR_MODE="0700" |
43 |
|
44 |
diff --git a/lib/portage/eapi.py b/lib/portage/eapi.py |
45 |
index 158d58243..5e12e976d 100644 |
46 |
--- a/lib/portage/eapi.py |
47 |
+++ b/lib/portage/eapi.py |
48 |
@@ -170,7 +170,7 @@ def _get_eapi_attrs(eapi): |
49 |
exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)), |
50 |
exports_PORTDIR = (eapi is None or eapi_exports_PORTDIR(eapi)), |
51 |
exports_ECLASSDIR = (eapi is not None and eapi_exports_ECLASSDIR(eapi)), |
52 |
- feature_flag_test = True, |
53 |
+ feature_flag_test = False, |
54 |
feature_flag_targetroot = (eapi is not None and eapi_has_targetroot(eapi)), |
55 |
hdepend = (eapi is not None and eapi_has_hdepend(eapi)), |
56 |
iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)), |
57 |
|
58 |
diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py |
59 |
index 320d9f6c0..37c5c6656 100644 |
60 |
--- a/lib/portage/package/ebuild/config.py |
61 |
+++ b/lib/portage/package/ebuild/config.py |
62 |
@@ -294,6 +294,7 @@ class config(object): |
63 |
self.configlist = [ |
64 |
self.configdict['env.d'], |
65 |
self.configdict['repo'], |
66 |
+ self.configdict['features'], |
67 |
self.configdict['pkginternal'], |
68 |
self.configdict['globals'], |
69 |
self.configdict['defaults'], |
70 |
@@ -461,13 +462,16 @@ class config(object): |
71 |
# back up our incremental variables: |
72 |
self.configdict={} |
73 |
self._use_expand_dict = {} |
74 |
- # configlist will contain: [ env.d, globals, defaults, conf, pkg, backupenv, env ] |
75 |
+ # configlist will contain: [ env.d, globals, features, defaults, conf, pkg, backupenv, env ] |
76 |
self.configlist.append({}) |
77 |
self.configdict["env.d"] = self.configlist[-1] |
78 |
|
79 |
self.configlist.append({}) |
80 |
self.configdict["repo"] = self.configlist[-1] |
81 |
|
82 |
+ self.configlist.append({}) |
83 |
+ self.configdict["features"] = self.configlist[-1] |
84 |
+ |
85 |
self.configlist.append({}) |
86 |
self.configdict["pkginternal"] = self.configlist[-1] |
87 |
|
88 |
@@ -868,7 +872,7 @@ class config(object): |
89 |
# reasonable defaults; this is important as without USE_ORDER, |
90 |
# USE will always be "" (nothing set)! |
91 |
if "USE_ORDER" not in self: |
92 |
- self["USE_ORDER"] = "env:pkg:conf:defaults:pkginternal:repo:env.d" |
93 |
+ self["USE_ORDER"] = "env:pkg:conf:defaults:pkginternal:features:repo:env.d" |
94 |
self.backup_changes("USE_ORDER") |
95 |
|
96 |
if "CBUILD" not in self and "CHOST" in self: |
97 |
@@ -1292,6 +1296,7 @@ class config(object): |
98 |
del self._penv[:] |
99 |
self.configdict["pkg"].clear() |
100 |
self.configdict["pkginternal"].clear() |
101 |
+ self.configdict["features"].clear() |
102 |
self.configdict["repo"].clear() |
103 |
self.configdict["defaults"]["USE"] = \ |
104 |
" ".join(self.make_defaults_use) |
105 |
@@ -1452,6 +1457,7 @@ class config(object): |
106 |
cp = cpv_getkey(mycpv) |
107 |
cpv_slot = self.mycpv |
108 |
pkginternaluse = "" |
109 |
+ feature_use = [] |
110 |
iuse = "" |
111 |
pkg_configdict = self.configdict["pkg"] |
112 |
previous_iuse = pkg_configdict.get("IUSE") |
113 |
@@ -1650,6 +1656,24 @@ class config(object): |
114 |
if has_changed: |
115 |
self.reset(keeping_pkg=1) |
116 |
|
117 |
+ if explicit_iuse is None: |
118 |
+ explicit_iuse = frozenset(x.lstrip("+-") for x in iuse.split()) |
119 |
+ if eapi_attrs.iuse_effective: |
120 |
+ iuse_implicit_match = self._iuse_effective_match |
121 |
+ else: |
122 |
+ iuse_implicit_match = self._iuse_implicit_match |
123 |
+ |
124 |
+ if "test" in explicit_iuse or iuse_implicit_match("test"): |
125 |
+ if "test" in self.features: |
126 |
+ feature_use.append("test") |
127 |
+ |
128 |
+ feature_use = " ".join(feature_use) |
129 |
+ if feature_use != self.configdict["features"].get("USE", ""): |
130 |
+ self.configdict["features"]["USE"] = feature_use |
131 |
+ # TODO: can we avoid that? |
132 |
+ self.reset(keeping_pkg=1) |
133 |
+ has_changed = True |
134 |
+ |
135 |
env_configdict = self.configdict['env'] |
136 |
|
137 |
# Ensure that "pkg" values are always preferred over "env" values. |
138 |
@@ -1677,11 +1701,8 @@ class config(object): |
139 |
# package has different IUSE. |
140 |
use = set(self["USE"].split()) |
141 |
unfiltered_use = frozenset(use) |
142 |
- if explicit_iuse is None: |
143 |
- explicit_iuse = frozenset(x.lstrip("+-") for x in iuse.split()) |
144 |
|
145 |
if eapi_attrs.iuse_effective: |
146 |
- iuse_implicit_match = self._iuse_effective_match |
147 |
portage_iuse = set(self._iuse_effective) |
148 |
portage_iuse.update(explicit_iuse) |
149 |
if built_use is not None: |
150 |
@@ -1693,7 +1714,6 @@ class config(object): |
151 |
self.configdict["pkg"]["IUSE_EFFECTIVE"] = \ |
152 |
" ".join(sorted(portage_iuse)) |
153 |
else: |
154 |
- iuse_implicit_match = self._iuse_implicit_match |
155 |
portage_iuse = self._get_implicit_iuse() |
156 |
portage_iuse.update(explicit_iuse) |
157 |
|
158 |
@@ -1729,21 +1749,17 @@ class config(object): |
159 |
self.get("EBUILD_FORCE_TEST") == "1" |
160 |
|
161 |
if "test" in explicit_iuse or iuse_implicit_match("test"): |
162 |
- if "test" not in self.features: |
163 |
- use.discard("test") |
164 |
- elif restrict_test or \ |
165 |
+ if "test" in self.features: |
166 |
+ if ebuild_force_test and "test" in self.usemask: |
167 |
+ self.usemask = \ |
168 |
+ frozenset(x for x in self.usemask if x != "test") |
169 |
+ if restrict_test or \ |
170 |
("test" in self.usemask and not ebuild_force_test): |
171 |
# "test" is in IUSE and USE=test is masked, so execution |
172 |
# of src_test() probably is not reliable. Therefore, |
173 |
# temporarily disable FEATURES=test just for this package. |
174 |
self["FEATURES"] = " ".join(x for x in self.features \ |
175 |
if x != "test") |
176 |
- use.discard("test") |
177 |
- else: |
178 |
- use.add("test") |
179 |
- if ebuild_force_test and "test" in self.usemask: |
180 |
- self.usemask = \ |
181 |
- frozenset(x for x in self.usemask if x != "test") |
182 |
|
183 |
if eapi_attrs.feature_flag_targetroot and \ |
184 |
("targetroot" in explicit_iuse or iuse_implicit_match("targetroot")): |
185 |
@@ -1900,12 +1916,6 @@ class config(object): |
186 |
iuse_implicit.add("build") |
187 |
iuse_implicit.add("bootstrap") |
188 |
|
189 |
- # Controlled by FEATURES=test. Make this implicit, so handling |
190 |
- # of FEATURES=test is consistent regardless of explicit IUSE. |
191 |
- # Users may use use.mask/package.use.mask to control |
192 |
- # FEATURES=test for all ebuilds, regardless of explicit IUSE. |
193 |
- iuse_implicit.add("test") |
194 |
- |
195 |
return iuse_implicit |
196 |
|
197 |
def _getUseMask(self, pkg, stable=None): |
198 |
|
199 |
diff --git a/lib/portage/tests/resolver/test_features_test_use.py b/lib/portage/tests/resolver/test_features_test_use.py |
200 |
index bdd179d7a..da7172c17 100644 |
201 |
--- a/lib/portage/tests/resolver/test_features_test_use.py |
202 |
+++ b/lib/portage/tests/resolver/test_features_test_use.py |
203 |
@@ -1,68 +1,88 @@ |
204 |
-# Copyright 2012 Gentoo Foundation |
205 |
+# Copyright 2012-2018 Gentoo Foundation |
206 |
# Distributed under the terms of the GNU General Public License v2 |
207 |
|
208 |
from portage.tests import TestCase |
209 |
from portage.tests.resolver.ResolverPlayground import (ResolverPlayground, |
210 |
ResolverPlaygroundTestCase) |
211 |
|
212 |
-class FeaturesTestUse(TestCase): |
213 |
|
214 |
- def testFeaturesTestUse(self): |
215 |
- ebuilds = { |
216 |
- "dev-libs/A-1" : { |
217 |
- "IUSE": "test" |
218 |
- }, |
219 |
- "dev-libs/B-1" : { |
220 |
- "IUSE": "test foo" |
221 |
- }, |
222 |
- } |
223 |
+class TestDepend(TestCase): |
224 |
+ ebuilds = { |
225 |
+ "dev-libs/A-1" : { |
226 |
+ "IUSE": "test", |
227 |
+ "DEPEND": "test? ( dev-libs/B )", |
228 |
+ }, |
229 |
+ "dev-libs/B-1" : { |
230 |
+ }, |
231 |
+ } |
232 |
|
233 |
- installed = { |
234 |
- "dev-libs/A-1" : { |
235 |
- "USE": "", |
236 |
- "IUSE": "test" |
237 |
- }, |
238 |
- "dev-libs/B-1" : { |
239 |
- "USE": "foo", |
240 |
- "IUSE": "test foo" |
241 |
- }, |
242 |
- } |
243 |
+ installed = { |
244 |
+ "dev-libs/A-1" : { |
245 |
+ "USE": "", |
246 |
+ "IUSE": "test", |
247 |
+ "DEPEND": "test? ( dev-libs/B )", |
248 |
+ }, |
249 |
+ } |
250 |
|
251 |
+ def test_default_use_test(self): |
252 |
+ """ |
253 |
+ Test that FEATURES=test enables USE=test by default. |
254 |
+ """ |
255 |
user_config = { |
256 |
- "make.conf" : ("FEATURES=test", "USE=\"-test -foo\"") |
257 |
+ "make.conf" : ("FEATURES=test", "USE=\"\"") |
258 |
} |
259 |
- |
260 |
- test_cases = ( |
261 |
- |
262 |
- # USE=test state should not trigger --newuse rebuilds, as |
263 |
- # specified in bug #373209, comment #3. |
264 |
- ResolverPlaygroundTestCase( |
265 |
+ test_case = ResolverPlaygroundTestCase( |
266 |
["dev-libs/A"], |
267 |
- options = {"--newuse": True, "--selective": True}, |
268 |
+ options = {}, |
269 |
success = True, |
270 |
- mergelist = []), |
271 |
+ mergelist = ["dev-libs/B-1", "dev-libs/A-1"]) |
272 |
+ |
273 |
+ playground = ResolverPlayground(ebuilds=self.ebuilds, |
274 |
+ user_config=user_config, debug=False) |
275 |
+ try: |
276 |
+ playground.run_TestCase(test_case) |
277 |
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
278 |
+ finally: |
279 |
+ playground.cleanup() |
280 |
|
281 |
- # USE=-test -> USE=test, with USE=test forced by FEATURES=test |
282 |
- ResolverPlaygroundTestCase( |
283 |
+ def test_no_forced_use_test(self): |
284 |
+ """ |
285 |
+ Test that FEATURES=test no longer forces USE=test. |
286 |
+ """ |
287 |
+ user_config = { |
288 |
+ "make.conf" : ("FEATURES=test", "USE=\"-test\"") |
289 |
+ } |
290 |
+ test_case = ResolverPlaygroundTestCase( |
291 |
["dev-libs/A"], |
292 |
options = {}, |
293 |
success = True, |
294 |
- mergelist = ["dev-libs/A-1"]), |
295 |
+ mergelist = ["dev-libs/A-1"]) |
296 |
+ |
297 |
+ playground = ResolverPlayground(ebuilds=self.ebuilds, |
298 |
+ user_config=user_config, debug=False) |
299 |
+ try: |
300 |
+ playground.run_TestCase(test_case) |
301 |
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
302 |
+ finally: |
303 |
+ playground.cleanup() |
304 |
|
305 |
- # USE=foo -> USE=-foo, with USE=test forced by FEATURES=test |
306 |
- ResolverPlaygroundTestCase( |
307 |
- ["dev-libs/B"], |
308 |
+ def test_newuse(self): |
309 |
+ """ |
310 |
+ Test that --newuse now detects USE=test changes. |
311 |
+ """ |
312 |
+ user_config = { |
313 |
+ "make.conf" : ("FEATURES=test", "USE=\"\"") |
314 |
+ } |
315 |
+ test_case = ResolverPlaygroundTestCase( |
316 |
+ ["dev-libs/A"], |
317 |
options = {"--newuse": True, "--selective": True}, |
318 |
success = True, |
319 |
- mergelist = ["dev-libs/B-1"]), |
320 |
- ) |
321 |
+ mergelist = ["dev-libs/B-1", "dev-libs/A-1"]) |
322 |
|
323 |
- playground = ResolverPlayground(ebuilds=ebuilds, |
324 |
- installed=installed, user_config=user_config, debug=False) |
325 |
+ playground = ResolverPlayground(ebuilds=self.ebuilds, |
326 |
+ user_config=user_config, debug=False) |
327 |
try: |
328 |
- for test_case in test_cases: |
329 |
- playground.run_TestCase(test_case) |
330 |
- self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
331 |
+ playground.run_TestCase(test_case) |
332 |
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
333 |
finally: |
334 |
playground.cleanup() |
335 |
- |
336 |
|
337 |
diff --git a/man/make.conf.5 b/man/make.conf.5 |
338 |
index cb0f00237..a4e33923c 100644 |
339 |
--- a/man/make.conf.5 |
340 |
+++ b/man/make.conf.5 |
341 |
@@ -1138,7 +1138,7 @@ This variable contains options that control the build behavior of several |
342 |
packages. More information in \fBebuild\fR(5). Possible USE values |
343 |
can be found in \fI/usr/portage/profiles/use.desc\fR. |
344 |
.TP |
345 |
-\fBUSE_ORDER\fR = \fI"env:pkg:conf:defaults:pkginternal:repo:env.d"\fR |
346 |
+\fBUSE_ORDER\fR = \fI"env:pkg:conf:defaults:pkginternal:features:repo:env.d"\fR |
347 |
Determines the precedence of layers in the incremental stacking of the USE |
348 |
variable. Precedence decreases from left to right such that env overrides |
349 |
pkg, pkg overrides conf, and so forth. |
350 |
@@ -1167,6 +1167,10 @@ USE from make.defaults and package.use in the profile |
351 |
.B pkginternal |
352 |
USE from \fBebuild\fR(5) IUSE defaults |
353 |
.TP |
354 |
+.B features |
355 |
+Flags implied by FEATURES. Currently includes USE=\fBtest\fR |
356 |
+for FEATURES=\fBtest\fR. |
357 |
+.TP |
358 |
.B repo |
359 |
USE from make.defaults and package.use in the repo's profiles/ top dir |
360 |
(e.g. /usr/portage/profiles/package.use) (see \fBportage\fR(5)) |