1 |
commit: 1b3131db0e22085dba7d0fb9fc6e5ec70c8c577d |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Nov 26 18:05:47 2019 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Nov 26 20:34:53 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1b3131db |
7 |
|
8 |
emerge --buildpkgonly: respect buildtime hard blockers |
9 |
|
10 |
Bug: https://bugs.gentoo.org/689226 |
11 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
12 |
|
13 |
lib/_emerge/depgraph.py | 24 ++++++--- |
14 |
lib/portage/tests/resolver/test_blocker.py | 87 +++++++++++++++++++++++++++++- |
15 |
2 files changed, 102 insertions(+), 9 deletions(-) |
16 |
|
17 |
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py |
18 |
index 68b5bdb2e..1127a6234 100644 |
19 |
--- a/lib/_emerge/depgraph.py |
20 |
+++ b/lib/_emerge/depgraph.py |
21 |
@@ -2791,7 +2791,6 @@ class depgraph(object): |
22 |
|
23 |
def _add_dep(self, dep, allow_unsatisfied=False): |
24 |
debug = "--debug" in self._frozen_config.myopts |
25 |
- buildpkgonly = "--buildpkgonly" in self._frozen_config.myopts |
26 |
nodeps = "--nodeps" in self._frozen_config.myopts |
27 |
if dep.blocker: |
28 |
|
29 |
@@ -2799,8 +2798,7 @@ class depgraph(object): |
30 |
# blocker validation is only able to account for one package per slot. |
31 |
is_slot_conflict_parent = any(dep.parent in conflict.pkgs[1:] for conflict in \ |
32 |
self._dynamic_config._package_tracker.slot_conflicts()) |
33 |
- if not buildpkgonly and \ |
34 |
- not nodeps and \ |
35 |
+ if not nodeps and \ |
36 |
not dep.collapsed_priority.ignored and \ |
37 |
not dep.collapsed_priority.optional and \ |
38 |
not is_slot_conflict_parent: |
39 |
@@ -6805,8 +6803,7 @@ class depgraph(object): |
40 |
for depclean and prune removal operations) |
41 |
@type required_sets: dict |
42 |
""" |
43 |
- if "--buildpkgonly" in self._frozen_config.myopts or \ |
44 |
- "recurse" not in self._dynamic_config.myparams: |
45 |
+ if "recurse" not in self._dynamic_config.myparams: |
46 |
return 1 |
47 |
|
48 |
complete_if_new_use = self._dynamic_config.myparams.get( |
49 |
@@ -7061,8 +7058,7 @@ class depgraph(object): |
50 |
# has been called before it, by checking that it is not None. |
51 |
self._dynamic_config._blocked_pkgs = digraph() |
52 |
|
53 |
- if "--buildpkgonly" in self._frozen_config.myopts or \ |
54 |
- "--nodeps" in self._frozen_config.myopts: |
55 |
+ if "--nodeps" in self._frozen_config.myopts: |
56 |
return True |
57 |
|
58 |
if True: |
59 |
@@ -7338,6 +7334,10 @@ class depgraph(object): |
60 |
# so apparently this one is unresolvable. |
61 |
unresolved_blocks = True |
62 |
|
63 |
+ if "--buildpkgonly" in self._frozen_config.myopts and not ( |
64 |
+ blocker.priority.buildtime and blocker.atom.blocker.overlap.forbid): |
65 |
+ depends_on_order.clear() |
66 |
+ |
67 |
# Make sure we don't unmerge any package that have been pulled |
68 |
# into the graph. |
69 |
if not unresolved_blocks and depends_on_order: |
70 |
@@ -8292,9 +8292,17 @@ class depgraph(object): |
71 |
retlist.extend(unsolvable_blockers) |
72 |
retlist = tuple(retlist) |
73 |
|
74 |
+ buildtime_blockers = [] |
75 |
+ if unsolvable_blockers and "--buildpkgonly" in self._frozen_config.myopts: |
76 |
+ for blocker in unsolvable_blockers: |
77 |
+ if blocker.priority.buildtime and blocker.atom.blocker.overlap.forbid: |
78 |
+ buildtime_blockers.append(blocker) |
79 |
+ |
80 |
if unsolvable_blockers and \ |
81 |
+ not buildtime_blockers and \ |
82 |
not self._accept_blocker_conflicts(): |
83 |
- self._dynamic_config._unsatisfied_blockers_for_display = unsolvable_blockers |
84 |
+ self._dynamic_config._unsatisfied_blockers_for_display = (tuple(buildtime_blockers) |
85 |
+ if buildtime_blockers else unsolvable_blockers) |
86 |
self._dynamic_config._serialized_tasks_cache = retlist |
87 |
self._dynamic_config._scheduler_graph = scheduler_graph |
88 |
# Blockers don't trigger the _skip_restart flag, since |
89 |
|
90 |
diff --git a/lib/portage/tests/resolver/test_blocker.py b/lib/portage/tests/resolver/test_blocker.py |
91 |
index 94a88b8b4..6534f99e6 100644 |
92 |
--- a/lib/portage/tests/resolver/test_blocker.py |
93 |
+++ b/lib/portage/tests/resolver/test_blocker.py |
94 |
@@ -1,4 +1,4 @@ |
95 |
-# Copyright 2014 Gentoo Foundation |
96 |
+# Copyright 2014-2019 Gentoo Authors |
97 |
# Distributed under the terms of the GNU General Public License v2 |
98 |
|
99 |
from portage.tests import TestCase |
100 |
@@ -46,3 +46,88 @@ class SlotConflictWithBlockerTestCase(TestCase): |
101 |
self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
102 |
finally: |
103 |
playground.cleanup() |
104 |
+ |
105 |
+ def testBlockerBuildpkgonly(self): |
106 |
+ ebuilds = { |
107 |
+ 'dev-libs/A-1': { |
108 |
+ 'EAPI': '7', |
109 |
+ 'DEPEND': '!!dev-libs/X' |
110 |
+ }, |
111 |
+ |
112 |
+ 'dev-libs/B-1': { |
113 |
+ 'EAPI': '7', |
114 |
+ 'BDEPEND': '!!dev-libs/X' |
115 |
+ }, |
116 |
+ |
117 |
+ 'dev-libs/C-1': { |
118 |
+ 'EAPI': '7', |
119 |
+ 'BDEPEND': '!dev-libs/X' |
120 |
+ }, |
121 |
+ |
122 |
+ 'dev-libs/D-1': { |
123 |
+ 'EAPI': '7', |
124 |
+ 'DEPEND': '!dev-libs/X' |
125 |
+ }, |
126 |
+ |
127 |
+ 'dev-libs/E-1': { |
128 |
+ 'EAPI': '7', |
129 |
+ 'RDEPEND': '!dev-libs/X !!dev-libs/X' |
130 |
+ }, |
131 |
+ |
132 |
+ 'dev-libs/F-1': { |
133 |
+ 'EAPI': '7', |
134 |
+ 'PDEPEND': '!dev-libs/X !!dev-libs/X' |
135 |
+ }, |
136 |
+ } |
137 |
+ |
138 |
+ installed = { |
139 |
+ 'dev-libs/X-1': {}, |
140 |
+ } |
141 |
+ |
142 |
+ test_cases = ( |
143 |
+ ResolverPlaygroundTestCase( |
144 |
+ ['dev-libs/A'], |
145 |
+ success = False, |
146 |
+ options = {'--buildpkgonly': True}, |
147 |
+ mergelist = ['dev-libs/A-1', '!!dev-libs/X']), |
148 |
+ |
149 |
+ ResolverPlaygroundTestCase( |
150 |
+ ['dev-libs/B'], |
151 |
+ success = False, |
152 |
+ options = {'--buildpkgonly': True}, |
153 |
+ mergelist = ['dev-libs/B-1', '!!dev-libs/X']), |
154 |
+ |
155 |
+ ResolverPlaygroundTestCase( |
156 |
+ ['dev-libs/C'], |
157 |
+ success = True, |
158 |
+ options = {'--buildpkgonly': True}, |
159 |
+ mergelist = ['dev-libs/C-1']), |
160 |
+ |
161 |
+ ResolverPlaygroundTestCase( |
162 |
+ ['dev-libs/D'], |
163 |
+ success = True, |
164 |
+ options = {'--buildpkgonly': True}, |
165 |
+ mergelist = ['dev-libs/D-1']), |
166 |
+ |
167 |
+ ResolverPlaygroundTestCase( |
168 |
+ ['dev-libs/E'], |
169 |
+ success = True, |
170 |
+ options = {'--buildpkgonly': True}, |
171 |
+ mergelist = ['dev-libs/E-1']), |
172 |
+ |
173 |
+ ResolverPlaygroundTestCase( |
174 |
+ ['dev-libs/F'], |
175 |
+ success = True, |
176 |
+ options = {'--buildpkgonly': True}, |
177 |
+ mergelist = ['dev-libs/F-1']), |
178 |
+ ) |
179 |
+ |
180 |
+ playground = ResolverPlayground(ebuilds=ebuilds, |
181 |
+ installed=installed, debug=False) |
182 |
+ try: |
183 |
+ for test_case in test_cases: |
184 |
+ playground.run_TestCase(test_case) |
185 |
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
186 |
+ finally: |
187 |
+ playground.debug = False |
188 |
+ playground.cleanup() |