1 |
Previously, USE_EXPAND variable settings in profile make.defaults only |
2 |
supported positive incremental settings. This patch adds support for |
3 |
negative settings like PYTHON_TARGETS="-python3_3", which brings |
4 |
behavior into alignment with PMS. |
5 |
|
6 |
Notably, this patch does not change behavior for settings in make.conf. |
7 |
In make.conf, settings to USE_EXPAND variables remain entirely |
8 |
non-incremental. PMS does not govern make.conf behavior. |
9 |
|
10 |
X-Gentoo-Bug: 530222 |
11 |
X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=530222 |
12 |
--- |
13 |
pym/portage/package/ebuild/config.py | 23 ++-- |
14 |
.../tests/ebuild/test_use_expand_incremental.py | 132 +++++++++++++++++++++ |
15 |
pym/portage/tests/resolver/ResolverPlayground.py | 10 ++ |
16 |
3 files changed, 155 insertions(+), 10 deletions(-) |
17 |
create mode 100644 pym/portage/tests/ebuild/test_use_expand_incremental.py |
18 |
|
19 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
20 |
index bf39487..97c794f 100644 |
21 |
--- a/pym/portage/package/ebuild/config.py |
22 |
+++ b/pym/portage/package/ebuild/config.py |
23 |
@@ -2315,6 +2315,7 @@ class config(object): |
24 |
# is enabled (for sub-profiles). |
25 |
configdict_defaults = self.configdict['defaults'] |
26 |
if self._make_defaults is not None: |
27 |
+ defaults_use = [] |
28 |
for i, cfg in enumerate(self._make_defaults): |
29 |
if not cfg: |
30 |
self.make_defaults_use.append("") |
31 |
@@ -2332,22 +2333,24 @@ class config(object): |
32 |
if v is None: |
33 |
continue |
34 |
prefix = k.lower() + '_' |
35 |
- if k in myincrementals: |
36 |
- for x in v.split(): |
37 |
- if x[:1] == '-': |
38 |
- expand_use.append('-' + prefix + x[1:]) |
39 |
- else: |
40 |
- expand_use.append(prefix + x) |
41 |
- else: |
42 |
- for x in v.split(): |
43 |
+ for x in v.split(): |
44 |
+ if x[:1] == '-': |
45 |
+ expand_use.append('-' + prefix + x[1:]) |
46 |
+ else: |
47 |
expand_use.append(prefix + x) |
48 |
+ |
49 |
+ defaults_use.extend(expand_use) |
50 |
+ defaults_use.extend(use.split()) |
51 |
+ |
52 |
if expand_use: |
53 |
expand_use.append(use) |
54 |
use = ' '.join(expand_use) |
55 |
self.make_defaults_use.append(use) |
56 |
self.make_defaults_use = tuple(self.make_defaults_use) |
57 |
- configdict_defaults['USE'] = ' '.join( |
58 |
- stack_lists([x.split() for x in self.make_defaults_use])) |
59 |
+ # Preserve both positive and negative flags here, since |
60 |
+ # negative flags may later interact with other flags pulled |
61 |
+ # in via USE_ORDER. |
62 |
+ configdict_defaults['USE'] = ' '.join(defaults_use) |
63 |
# Set to None so this code only runs once. |
64 |
self._make_defaults = None |
65 |
|
66 |
diff --git a/pym/portage/tests/ebuild/test_use_expand_incremental.py b/pym/portage/tests/ebuild/test_use_expand_incremental.py |
67 |
new file mode 100644 |
68 |
index 0000000..a58f08c |
69 |
--- /dev/null |
70 |
+++ b/pym/portage/tests/ebuild/test_use_expand_incremental.py |
71 |
@@ -0,0 +1,132 @@ |
72 |
+# Copyright 2014 Gentoo Foundation |
73 |
+# Distributed under the terms of the GNU General Public License v2 |
74 |
+ |
75 |
+from __future__ import unicode_literals |
76 |
+ |
77 |
+import io |
78 |
+ |
79 |
+from portage import os, _encodings |
80 |
+from portage.dep import Atom |
81 |
+from portage.package.ebuild.config import config |
82 |
+from portage.tests import TestCase |
83 |
+from portage.tests.resolver.ResolverPlayground import ResolverPlayground |
84 |
+from portage.util import ensure_dirs |
85 |
+ |
86 |
+class UseExpandIncrementalTestCase(TestCase): |
87 |
+ |
88 |
+ def testUseExpandIncremental(self): |
89 |
+ |
90 |
+ profiles = ( |
91 |
+ ( |
92 |
+ 'base', |
93 |
+ { |
94 |
+ "eapi": ("5",), |
95 |
+ "parent": ("..",), |
96 |
+ "make.defaults": ( |
97 |
+ "INPUT_DEVICES=\"keyboard mouse\"", |
98 |
+ "PYTHON_TARGETS=\"python2_7 python3_3\"", |
99 |
+ ("USE_EXPAND=\"INPUT_DEVICES PYTHON_TARGETS " |
100 |
+ "VIDEO_CARDS\""), |
101 |
+ ) |
102 |
+ } |
103 |
+ ), |
104 |
+ ( |
105 |
+ 'default/linux', |
106 |
+ { |
107 |
+ "eapi": ("5",), |
108 |
+ "make.defaults": ( |
109 |
+ "VIDEO_CARDS=\"dummy fbdev v4l\"", |
110 |
+ ) |
111 |
+ } |
112 |
+ ), |
113 |
+ ( |
114 |
+ 'default/linux/x86', |
115 |
+ { |
116 |
+ "eapi": ("5",), |
117 |
+ "make.defaults": ( |
118 |
+ # Test negative incremental for bug 530222. |
119 |
+ "PYTHON_TARGETS=\"-python3_3\"", |
120 |
+ ), |
121 |
+ "parent": ("../../../base", |
122 |
+ "../../../mixins/python/3.4", |
123 |
+ ".." |
124 |
+ ) |
125 |
+ } |
126 |
+ ), |
127 |
+ ( |
128 |
+ 'mixins/python/3.4', |
129 |
+ { |
130 |
+ "eapi": ("5",), |
131 |
+ "make.defaults": ( |
132 |
+ "PYTHON_TARGETS=\"python3_4\"", |
133 |
+ ) |
134 |
+ } |
135 |
+ ), |
136 |
+ ) |
137 |
+ |
138 |
+ # USE_EXPAND variable settings in make.conf will cause |
139 |
+ # profile settings for the same variable to be discarded |
140 |
+ # (non-incremental behavior). PMS does not govern make.conf |
141 |
+ # behavior. |
142 |
+ user_config = { |
143 |
+ "make.conf" : ( |
144 |
+ "VIDEO_CARDS=\"intel\"", |
145 |
+ ) |
146 |
+ } |
147 |
+ |
148 |
+ ebuilds = { |
149 |
+ "x11-base/xorg-drivers-1.15": { |
150 |
+ "EAPI": "5", |
151 |
+ "IUSE": ("input_devices_keyboard input_devices_mouse " |
152 |
+ "videos_cards_dummy video_cards_fbdev " |
153 |
+ "video_cards_v4l video_cards_intel") |
154 |
+ }, |
155 |
+ "sys-apps/portage-2.2.14": { |
156 |
+ "EAPI": "5", |
157 |
+ "IUSE": ("python_targets_python2_7 " |
158 |
+ "python_targets_python3_3 python_targets_python3_4") |
159 |
+ }, |
160 |
+ } |
161 |
+ |
162 |
+ package_expected_use = ( |
163 |
+ ("x11-base/xorg-drivers-1.15", ("input_devices_keyboard", |
164 |
+ "input_devices_mouse", "video_cards_intel",)), |
165 |
+ ("sys-apps/portage-2.2.14", ("python_targets_python2_7", |
166 |
+ "python_targets_python3_4")) |
167 |
+ ) |
168 |
+ |
169 |
+ playground = ResolverPlayground(debug=False, |
170 |
+ ebuilds=ebuilds, user_config=user_config) |
171 |
+ try: |
172 |
+ repo_dir = (playground.settings.repositories. |
173 |
+ get_location_for_name("test_repo")) |
174 |
+ profile_root = os.path.join(repo_dir, "profiles") |
175 |
+ |
176 |
+ for p, data in profiles: |
177 |
+ prof_path = os.path.join(profile_root, p) |
178 |
+ ensure_dirs(prof_path) |
179 |
+ for k, v in data.items(): |
180 |
+ with io.open(os.path.join(prof_path, k), mode="w", |
181 |
+ encoding=_encodings["repo.content"]) as f: |
182 |
+ for line in v: |
183 |
+ f.write("%s\n" % line) |
184 |
+ |
185 |
+ # The config must be reloaded in order to account |
186 |
+ # for the above profile customizations. |
187 |
+ playground.reload_config() |
188 |
+ |
189 |
+ depgraph = playground.run( |
190 |
+ ["=x11-base/xorg-drivers-1.15"]).depgraph |
191 |
+ settings = config(clone=playground.settings) |
192 |
+ |
193 |
+ for cpv, expected_use in package_expected_use: |
194 |
+ pkg, existing_node = depgraph._select_package( |
195 |
+ playground.eroot, Atom("=" + cpv)) |
196 |
+ settings.setcpv(pkg) |
197 |
+ expected = frozenset(expected_use) |
198 |
+ got = frozenset(settings["PORTAGE_USE"].split()) |
199 |
+ self.assertEqual(got, expected, |
200 |
+ "%s != %s" % (got, expected)) |
201 |
+ |
202 |
+ finally: |
203 |
+ playground.cleanup() |
204 |
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py |
205 |
index 2d16251..0be5d81 100644 |
206 |
--- a/pym/portage/tests/resolver/ResolverPlayground.py |
207 |
+++ b/pym/portage/tests/resolver/ResolverPlayground.py |
208 |
@@ -104,6 +104,16 @@ class ResolverPlayground(object): |
209 |
|
210 |
portage.util.noiselimit = 0 |
211 |
|
212 |
+ def reload_config(self): |
213 |
+ """ |
214 |
+ Reload configuration from disk, which is useful if it has |
215 |
+ been modified after the constructor has been called. |
216 |
+ """ |
217 |
+ for eroot in self.trees: |
218 |
+ portdb = self.trees[eroot]["porttree"].dbapi |
219 |
+ portdb.close_caches() |
220 |
+ self.settings, self.trees = self._load_config() |
221 |
+ |
222 |
def _get_repo_dir(self, repo): |
223 |
""" |
224 |
Create the repo directory if needed. |
225 |
-- |
226 |
2.0.4 |