Gentoo Archives: gentoo-commits

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