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