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/ebuild/, pym/portage/tests/resolver/, ...
Date: Thu, 27 Nov 2014 08:47:58
Message-Id: 1417077940.b9c06a6a2dd4ccc875f8b9dd3139ea582e1e5621.zmedico@gentoo
1 commit: b9c06a6a2dd4ccc875f8b9dd3139ea582e1e5621
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:45:40 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b9c06a6a
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 | 18 +--
25 .../tests/ebuild/test_use_expand_incremental.py | 132 +++++++++++++++++++++
26 pym/portage/tests/resolver/ResolverPlayground.py | 10 ++
27 3 files changed, 151 insertions(+), 9 deletions(-)
28
29 diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
30 index bf39487..aca27f2 100644
31 --- a/pym/portage/package/ebuild/config.py
32 +++ b/pym/portage/package/ebuild/config.py
33 @@ -2332,22 +2332,22 @@ class config(object):
34 if v is None:
35 continue
36 prefix = k.lower() + '_'
37 - if k in myincrementals:
38 - for x in v.split():
39 - if x[:1] == '-':
40 - expand_use.append('-' + prefix + x[1:])
41 - else:
42 - expand_use.append(prefix + x)
43 - else:
44 - for x in v.split():
45 + for x in v.split():
46 + if x[:1] == '-':
47 + expand_use.append('-' + prefix + x[1:])
48 + else:
49 expand_use.append(prefix + x)
50 +
51 if expand_use:
52 expand_use.append(use)
53 use = ' '.join(expand_use)
54 self.make_defaults_use.append(use)
55 self.make_defaults_use = tuple(self.make_defaults_use)
56 + # Preserve both positive and negative flags here, since
57 + # negative flags may later interact with other flags pulled
58 + # in via USE_ORDER.
59 configdict_defaults['USE'] = ' '.join(
60 - stack_lists([x.split() for x in self.make_defaults_use]))
61 + filter(None, self.make_defaults_use))
62 # Set to None so this code only runs once.
63 self._make_defaults = None
64
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
205 diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
206 index 2d16251..0be5d81 100644
207 --- a/pym/portage/tests/resolver/ResolverPlayground.py
208 +++ b/pym/portage/tests/resolver/ResolverPlayground.py
209 @@ -104,6 +104,16 @@ class ResolverPlayground(object):
210
211 portage.util.noiselimit = 0
212
213 + def reload_config(self):
214 + """
215 + Reload configuration from disk, which is useful if it has
216 + been modified after the constructor has been called.
217 + """
218 + for eroot in self.trees:
219 + portdb = self.trees[eroot]["porttree"].dbapi
220 + portdb.close_caches()
221 + self.settings, self.trees = self._load_config()
222 +
223 def _get_repo_dir(self, repo):
224 """
225 Create the repo directory if needed.