1 |
commit: 852c729bdef3d4c2e2d459a43dc21f0a05dfa2ba |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Mar 4 06:24:21 2017 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 8 19:19:53 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=852c729b |
7 |
|
8 |
emerge: auto-enable --with-bdeps if --usepkg is not enabled (bug 598444) |
9 |
|
10 |
It's useful to automatically enable --with-bdeps so that @world updates |
11 |
will update all packages that are not eligible for removal by |
12 |
emerge --depclean. However, many users of binary packages do not want |
13 |
unnecessary build time dependencies installed, therefore do not |
14 |
auto-enable --with-bdeps for installation actions when the --usepkg |
15 |
option is enabled. |
16 |
|
17 |
A new --with-bdeps-auto=<y|n> option is provided, making it possible to |
18 |
enable or disable the program logic that causes --with-bdeps to be |
19 |
automatically enabled. Use --with-bdeps-auto=n to prevent --with-bdeps |
20 |
from being automatically enabled for installation actions. This is useful |
21 |
for some rare cases in which --with-bdeps triggers unsolvable dependency |
22 |
conflicts (and putting --with-bdeps=n in EMERGE_DEFAULT_OPTS would cause |
23 |
undesirable --depclean behavior). |
24 |
|
25 |
X-Gentoo-bug: 598444 |
26 |
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=598444 |
27 |
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org> |
28 |
|
29 |
man/emerge.1 | 37 +++- |
30 |
pym/_emerge/create_depgraph_params.py | 5 + |
31 |
pym/_emerge/depgraph.py | 4 +- |
32 |
pym/_emerge/main.py | 5 + |
33 |
pym/portage/tests/resolver/ResolverPlayground.py | 5 + |
34 |
pym/portage/tests/resolver/test_bdeps.py | 215 +++++++++++++++++++++++ |
35 |
6 files changed, 266 insertions(+), 5 deletions(-) |
36 |
|
37 |
diff --git a/man/emerge.1 b/man/emerge.1 |
38 |
index 5b6122023..7db427199 100644 |
39 |
--- a/man/emerge.1 |
40 |
+++ b/man/emerge.1 |
41 |
@@ -986,13 +986,44 @@ The default is set to "y" (on). |
42 |
.TP |
43 |
.BR "\-\-with\-bdeps < y | n >" |
44 |
In dependency calculations, pull in build time dependencies |
45 |
-that are not strictly required. This defaults to \'n\' for |
46 |
-installation actions, meaning they will not be installed, and |
47 |
-\'y\' for the \fB\-\-depclean\fR action, meaning they will not be removed. |
48 |
+that are not strictly required. This option is automatically enabled for |
49 |
+installation actions, meaning they will be installed, and defaults to |
50 |
+\(aqy\(aq for the \fB\-\-depclean\fR action, meaning they will not be |
51 |
+removed. In order to prevent the \fB\-\-with\-bdeps\fR option from being |
52 |
+automatically enabled for installation actions, specify |
53 |
+\fB\-\-with\-bdeps\-auto=n\fR in either the command line or |
54 |
+\fBEMERGE_DEFAULT_OPTS\fR. |
55 |
+ |
56 |
+Since many users of binary packages do not want unnecessary build time |
57 |
+dependencies installed, this option is not automatically enabled for |
58 |
+installation actions when the \fB\-\-usepkg\fR option is enabled. In |
59 |
+order to pull in build time dependencies for binary packages with |
60 |
+\fB\-\-usepkg\fR, \fB\-\-with\-bdeps=y\fR must be specified explicitly. |
61 |
+This also applies to options that enable the \fB\-\-usepkg\fR option |
62 |
+implicitly, such as \fB\-\-getbinpkg\fR. |
63 |
+ |
64 |
This setting can be added to |
65 |
\fBEMERGE_DEFAULT_OPTS\fR (see make.conf(5)) and later overridden via the |
66 |
command line. |
67 |
.TP |
68 |
+.BR "\-\-with\-bdeps\-auto < y | n >" |
69 |
+This option is used to enable or disable the program logic that causes |
70 |
+\fB\-\-with\-bdeps\fR is to be automatically enabled for installation |
71 |
+actions. This option is enabled by default. Use |
72 |
+\fB\-\-with\-bdeps\-auto=n\fR to prevent \fB\-\-with\-bdeps\fR from |
73 |
+being automatically enabled for installation actions. This setting can |
74 |
+be added to \fBEMERGE_DEFAULT_OPTS\fR (see make.conf(5)) and later |
75 |
+overridden via the command line. |
76 |
+ |
77 |
+\fBNOTE:\fR The program logic that causes \fB\-\-with\-bdeps\fR to be |
78 |
+automatically enabled for installation actions does not affect removal |
79 |
+actions such as the \fB\-\-depclean\fR action. Therefore, when |
80 |
+\fB\-\-with\-bdeps\-auto=n\fR is specified in \fBEMERGE_DEFAULT_OPTS\fR, |
81 |
+it does not affect the default \fB\-\-with\-bdeps=y\fR setting that |
82 |
+applies to the \fB\-\-depclean\fR action. The default |
83 |
+\fB\-\-with\-bdeps=y\fR setting that applies to the \fB\-\-depclean\fR |
84 |
+action can be overridden only by specifying \fB\-\-with\-bdeps=n\fR. |
85 |
+.TP |
86 |
.BR "\-\-with\-test\-deps [ y | n ]" |
87 |
For packages matched by arguments, this option will pull in dependencies |
88 |
that are conditional on the "test" USE flag, even if "test" is not |
89 |
|
90 |
diff --git a/pym/_emerge/create_depgraph_params.py b/pym/_emerge/create_depgraph_params.py |
91 |
index 2c6492883..cdea029ba 100644 |
92 |
--- a/pym/_emerge/create_depgraph_params.py |
93 |
+++ b/pym/_emerge/create_depgraph_params.py |
94 |
@@ -13,6 +13,8 @@ def create_depgraph_params(myopts, myaction): |
95 |
# deep: go into the dependencies of already merged packages |
96 |
# empty: pretend nothing is merged |
97 |
# complete: completely account for all known dependencies |
98 |
+ # bdeps: satisfy build time dependencies of packages that are |
99 |
+ # already built, even though they are not strictly required |
100 |
# remove: build graph for use in removing packages |
101 |
# rebuilt_binaries: replace installed packages with rebuilt binaries |
102 |
# rebuild_if_new_slot: rebuild or reinstall packages when |
103 |
@@ -32,6 +34,9 @@ def create_depgraph_params(myopts, myaction): |
104 |
bdeps = myopts.get("--with-bdeps") |
105 |
if bdeps is not None: |
106 |
myparams["bdeps"] = bdeps |
107 |
+ elif myaction == "remove" or ( |
108 |
+ myopts.get("--with-bdeps-auto") != "n" and "--usepkg" not in myopts): |
109 |
+ myparams["bdeps"] = "auto" |
110 |
|
111 |
ignore_built_slot_operator_deps = myopts.get("--ignore-built-slot-operator-deps") |
112 |
if ignore_built_slot_operator_deps is not None: |
113 |
|
114 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
115 |
index ce0fde156..02a32260a 100644 |
116 |
--- a/pym/_emerge/depgraph.py |
117 |
+++ b/pym/_emerge/depgraph.py |
118 |
@@ -2362,7 +2362,7 @@ class depgraph(object): |
119 |
if ebuild is None: |
120 |
changed = False |
121 |
else: |
122 |
- if self._dynamic_config.myparams.get("bdeps", "n") == "y": |
123 |
+ if self._dynamic_config.myparams.get("bdeps") in ("y", "auto"): |
124 |
depvars = Package._dep_keys |
125 |
else: |
126 |
depvars = Package._runtime_keys |
127 |
@@ -2998,7 +2998,7 @@ class depgraph(object): |
128 |
|
129 |
ignore_build_time_deps = False |
130 |
if pkg.built and not removal_action: |
131 |
- if self._dynamic_config.myparams.get("bdeps", "n") == "y": |
132 |
+ if self._dynamic_config.myparams.get("bdeps") in ("y", "auto"): |
133 |
# Pull in build time deps as requested, but marked them as |
134 |
# "optional" since they are not strictly required. This allows |
135 |
# more freedom in the merge order calculation for solving |
136 |
|
137 |
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py |
138 |
index a83b328aa..76e963ac9 100644 |
139 |
--- a/pym/_emerge/main.py |
140 |
+++ b/pym/_emerge/main.py |
141 |
@@ -516,6 +516,11 @@ def parse_opts(tmpcmdline, silent=False): |
142 |
"help":"include unnecessary build time dependencies", |
143 |
"choices":("y", "n") |
144 |
}, |
145 |
+ "--with-bdeps-auto": { |
146 |
+ "help":("automatically enable --with-bdeps for installation" |
147 |
+ " actions, unless --usepkg is enabled"), |
148 |
+ "choices":("y", "n") |
149 |
+ }, |
150 |
"--reinstall": { |
151 |
"help":"specify conditions to trigger package reinstallation", |
152 |
"choices":["changed-use"] |
153 |
|
154 |
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py |
155 |
index d1434f724..d8037194b 100644 |
156 |
--- a/pym/portage/tests/resolver/ResolverPlayground.py |
157 |
+++ b/pym/portage/tests/resolver/ResolverPlayground.py |
158 |
@@ -558,6 +558,7 @@ class ResolverPlaygroundTestCase(object): |
159 |
def __init__(self, request, **kwargs): |
160 |
self.all_permutations = kwargs.pop("all_permutations", False) |
161 |
self.ignore_mergelist_order = kwargs.pop("ignore_mergelist_order", False) |
162 |
+ self.ignore_cleanlist_order = kwargs.pop("ignore_cleanlist_order", False) |
163 |
self.ambiguous_merge_order = kwargs.pop("ambiguous_merge_order", False) |
164 |
self.ambiguous_slot_collision_solutions = kwargs.pop("ambiguous_slot_collision_solutions", False) |
165 |
self.check_repo_names = kwargs.pop("check_repo_names", False) |
166 |
@@ -675,6 +676,10 @@ class ResolverPlaygroundTestCase(object): |
167 |
str((node1, node2))) + \ |
168 |
", got: " + str(got)) |
169 |
|
170 |
+ elif key == "cleanlist" and self.ignore_cleanlist_order: |
171 |
+ got = set(got) |
172 |
+ expected = set(expected) |
173 |
+ |
174 |
elif key == "slot_collision_solutions" and \ |
175 |
self.ambiguous_slot_collision_solutions: |
176 |
# Tests that use all_permutations can have multiple |
177 |
|
178 |
diff --git a/pym/portage/tests/resolver/test_bdeps.py b/pym/portage/tests/resolver/test_bdeps.py |
179 |
new file mode 100644 |
180 |
index 000000000..c0d64991c |
181 |
--- /dev/null |
182 |
+++ b/pym/portage/tests/resolver/test_bdeps.py |
183 |
@@ -0,0 +1,215 @@ |
184 |
+# Copyright 2017 Gentoo Foundation |
185 |
+# Distributed under the terms of the GNU General Public License v2 |
186 |
+ |
187 |
+from portage.tests import TestCase |
188 |
+from portage.tests.resolver.ResolverPlayground import ( |
189 |
+ ResolverPlayground, |
190 |
+ ResolverPlaygroundTestCase, |
191 |
+) |
192 |
+ |
193 |
+class BdepsTestCase(TestCase): |
194 |
+ |
195 |
+ def testImageMagickUpdate(self): |
196 |
+ |
197 |
+ ebuilds = { |
198 |
+ "app-misc/A-1" : { |
199 |
+ "EAPI": "6", |
200 |
+ "DEPEND": "app-misc/B", |
201 |
+ "RDEPEND": "app-misc/C", |
202 |
+ }, |
203 |
+ |
204 |
+ "app-misc/B-1" : { |
205 |
+ "EAPI": "6" |
206 |
+ }, |
207 |
+ "app-misc/B-2" : { |
208 |
+ "EAPI": "6", |
209 |
+ }, |
210 |
+ |
211 |
+ "app-misc/C-1" : { |
212 |
+ "EAPI": "6", |
213 |
+ "DEPEND": "app-misc/D", |
214 |
+ }, |
215 |
+ "app-misc/C-2" : { |
216 |
+ "EAPI": "6", |
217 |
+ "DEPEND": "app-misc/D", |
218 |
+ }, |
219 |
+ |
220 |
+ "app-misc/D-1" : { |
221 |
+ "EAPI": "6", |
222 |
+ }, |
223 |
+ "app-misc/D-2" : { |
224 |
+ "EAPI": "6", |
225 |
+ }, |
226 |
+ } |
227 |
+ |
228 |
+ installed = { |
229 |
+ "app-misc/A-1" : { |
230 |
+ "EAPI": "6", |
231 |
+ "DEPEND": "app-misc/B", |
232 |
+ "RDEPEND": "app-misc/C", |
233 |
+ }, |
234 |
+ |
235 |
+ "app-misc/B-1" : { |
236 |
+ "EAPI": "6", |
237 |
+ }, |
238 |
+ "app-misc/C-1" : { |
239 |
+ "EAPI": "6", |
240 |
+ "DEPEND": "app-misc/D", |
241 |
+ }, |
242 |
+ |
243 |
+ "app-misc/D-1" : { |
244 |
+ "EAPI": "6", |
245 |
+ }, |
246 |
+ } |
247 |
+ |
248 |
+ binpkgs = { |
249 |
+ "app-misc/A-1" : { |
250 |
+ "EAPI": "6", |
251 |
+ "DEPEND": "app-misc/B", |
252 |
+ "RDEPEND": "app-misc/C", |
253 |
+ }, |
254 |
+ |
255 |
+ "app-misc/B-1" : { |
256 |
+ "EAPI": "6", |
257 |
+ }, |
258 |
+ "app-misc/B-2" : { |
259 |
+ "EAPI": "6", |
260 |
+ }, |
261 |
+ |
262 |
+ "app-misc/C-1" : { |
263 |
+ "EAPI": "6", |
264 |
+ "DEPEND": "app-misc/D", |
265 |
+ }, |
266 |
+ "app-misc/C-2" : { |
267 |
+ "EAPI": "6", |
268 |
+ "DEPEND": "app-misc/D", |
269 |
+ }, |
270 |
+ |
271 |
+ "app-misc/D-1" : { |
272 |
+ "EAPI": "6", |
273 |
+ }, |
274 |
+ "app-misc/D-2" : { |
275 |
+ "EAPI": "6", |
276 |
+ }, |
277 |
+ } |
278 |
+ |
279 |
+ world = ( |
280 |
+ "app-misc/A", |
281 |
+ ) |
282 |
+ |
283 |
+ test_cases = ( |
284 |
+ |
285 |
+ # Enable --with-bdeps automatically when |
286 |
+ # --usepkg has not been specified. |
287 |
+ ResolverPlaygroundTestCase( |
288 |
+ ["@world"], |
289 |
+ options = { |
290 |
+ "--update": True, |
291 |
+ "--deep": True, |
292 |
+ }, |
293 |
+ success = True, |
294 |
+ ambiguous_merge_order = True, |
295 |
+ mergelist = [ |
296 |
+ "app-misc/D-2", |
297 |
+ ("app-misc/B-2", "app-misc/C-2"), |
298 |
+ ] |
299 |
+ ), |
300 |
+ |
301 |
+ # Use --with-bdeps-auto=n to prevent --with-bdeps |
302 |
+ # from being enabled automatically. |
303 |
+ ResolverPlaygroundTestCase( |
304 |
+ ["@world"], |
305 |
+ options = { |
306 |
+ "--update": True, |
307 |
+ "--deep": True, |
308 |
+ "--with-bdeps-auto": "n", |
309 |
+ }, |
310 |
+ success = True, |
311 |
+ mergelist = [ |
312 |
+ "app-misc/D-2", |
313 |
+ "app-misc/C-2", |
314 |
+ ] |
315 |
+ ), |
316 |
+ |
317 |
+ # Do not enable --with-bdeps automatically when |
318 |
+ # --usepkg has been specified, since many users of binary |
319 |
+ # packages do not want unnecessary build time dependencies |
320 |
+ # installed. In this case we miss an update to |
321 |
+ # app-misc/D-2, since DEPEND is not pulled in for |
322 |
+ # the [binary]app-misc/C-2 update. |
323 |
+ ResolverPlaygroundTestCase( |
324 |
+ ["@world"], |
325 |
+ options = { |
326 |
+ "--update": True, |
327 |
+ "--deep": True, |
328 |
+ "--usepkg": True, |
329 |
+ }, |
330 |
+ success = True, |
331 |
+ mergelist = [ |
332 |
+ "[binary]app-misc/C-2", |
333 |
+ ] |
334 |
+ ), |
335 |
+ |
336 |
+ # Use --with-bdeps=y to pull in build-time dependencies of |
337 |
+ # binary packages. |
338 |
+ ResolverPlaygroundTestCase( |
339 |
+ ["@world"], |
340 |
+ options = { |
341 |
+ "--update": True, |
342 |
+ "--deep": True, |
343 |
+ "--usepkg": True, |
344 |
+ "--with-bdeps": "y", |
345 |
+ }, |
346 |
+ success = True, |
347 |
+ ambiguous_merge_order = True, |
348 |
+ mergelist = [ |
349 |
+ ( |
350 |
+ "[binary]app-misc/D-2", |
351 |
+ "[binary]app-misc/B-2", |
352 |
+ "[binary]app-misc/C-2", |
353 |
+ ), |
354 |
+ ] |
355 |
+ ), |
356 |
+ |
357 |
+ # For --depclean, do not remove build-time dependencies by |
358 |
+ # default. Specify --with-bdeps-auto=n, in order to |
359 |
+ # demonstrate that it does not affect removal actions. |
360 |
+ ResolverPlaygroundTestCase( |
361 |
+ [], |
362 |
+ options = { |
363 |
+ "--depclean": True, |
364 |
+ "--with-bdeps-auto": "n", |
365 |
+ }, |
366 |
+ success = True, |
367 |
+ cleanlist = [], |
368 |
+ ), |
369 |
+ |
370 |
+ # For --depclean, remove build-time dependencies if |
371 |
+ # --with-bdeps=n has been specified. |
372 |
+ ResolverPlaygroundTestCase( |
373 |
+ [], |
374 |
+ options = { |
375 |
+ "--depclean": True, |
376 |
+ "--with-bdeps": "n", |
377 |
+ }, |
378 |
+ success = True, |
379 |
+ ignore_cleanlist_order = True, |
380 |
+ cleanlist = [ |
381 |
+ "app-misc/D-1", |
382 |
+ "app-misc/B-1", |
383 |
+ ], |
384 |
+ ), |
385 |
+ ) |
386 |
+ |
387 |
+ playground = ResolverPlayground(debug=False, |
388 |
+ ebuilds=ebuilds, installed=installed, |
389 |
+ binpkgs=binpkgs, world=world) |
390 |
+ try: |
391 |
+ for test_case in test_cases: |
392 |
+ playground.run_TestCase(test_case) |
393 |
+ self.assertEqual(test_case.test_success, True, |
394 |
+ test_case.fail_msg) |
395 |
+ finally: |
396 |
+ # Disable debug so that cleanup works. |
397 |
+ playground.debug = False |
398 |
+ playground.cleanup() |