1 |
When a slot conflict occurs involving a package that is matched by all |
2 |
involved parent atoms, consider masking the package in order to avoid |
3 |
a possible missed update. The included unit test demonstrates the case |
4 |
fixed by this patch. There are 2 previously existing unit tests that |
5 |
require larger backtracking values in order to succeed with this patch, |
6 |
since more possible solutions are now considered. |
7 |
|
8 |
Bug: https://bugs.gentoo.org/692746 |
9 |
Signed-off-by: Zac Medico <zmedico@g.o> |
10 |
--- |
11 |
lib/_emerge/depgraph.py | 5 ++ |
12 |
lib/_emerge/resolver/backtracking.py | 9 +++ |
13 |
.../test_slot_conflict_update_virt.py | 79 +++++++++++++++++++ |
14 |
.../test_slot_operator_complete_graph.py | 2 +- |
15 |
.../test_slot_operator_runtime_pkg_mask.py | 2 +- |
16 |
5 files changed, 95 insertions(+), 2 deletions(-) |
17 |
create mode 100644 lib/portage/tests/resolver/test_slot_conflict_update_virt.py |
18 |
|
19 |
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py |
20 |
index 08240af67..6be1b3ec7 100644 |
21 |
--- a/lib/_emerge/depgraph.py |
22 |
+++ b/lib/_emerge/depgraph.py |
23 |
@@ -1768,6 +1768,11 @@ class depgraph(object): |
24 |
debug = "--debug" in self._frozen_config.myopts |
25 |
existing_node = next(self._dynamic_config._package_tracker.match( |
26 |
root, slot_atom, installed=False)) |
27 |
+ if existing_node not in conflict_pkgs: |
28 |
+ # Even though all parent atoms match existing_node, |
29 |
+ # consider masking it in order to avoid a missed update |
30 |
+ # as in bug 692746. |
31 |
+ conflict_pkgs.append(existing_node) |
32 |
# In order to avoid a missed update, first mask lower versions |
33 |
# that conflict with higher versions (the backtracker visits |
34 |
# these in reverse order). |
35 |
diff --git a/lib/_emerge/resolver/backtracking.py b/lib/_emerge/resolver/backtracking.py |
36 |
index c29b9d42a..99e4565c8 100644 |
37 |
--- a/lib/_emerge/resolver/backtracking.py |
38 |
+++ b/lib/_emerge/resolver/backtracking.py |
39 |
@@ -135,11 +135,20 @@ class Backtracker(object): |
40 |
continue |
41 |
|
42 |
entry_is_valid = False |
43 |
+ any_conflict_parents = False |
44 |
|
45 |
for ppkg, patom in runtime_pkg_mask[pkg].get("slot conflict", set()): |
46 |
+ any_conflict_parents = True |
47 |
if ppkg not in runtime_pkg_mask: |
48 |
entry_is_valid = True |
49 |
break |
50 |
+ else: |
51 |
+ if not any_conflict_parents: |
52 |
+ # Even though pkg was involved in a slot conflict |
53 |
+ # where it was matched by all involved parent atoms, |
54 |
+ # consider masking it in order to avoid a missed |
55 |
+ # update as in bug 692746. |
56 |
+ entry_is_valid = True |
57 |
|
58 |
if not entry_is_valid: |
59 |
return False |
60 |
diff --git a/lib/portage/tests/resolver/test_slot_conflict_update_virt.py b/lib/portage/tests/resolver/test_slot_conflict_update_virt.py |
61 |
new file mode 100644 |
62 |
index 000000000..ce89925ba |
63 |
--- /dev/null |
64 |
+++ b/lib/portage/tests/resolver/test_slot_conflict_update_virt.py |
65 |
@@ -0,0 +1,79 @@ |
66 |
+# Copyright 2019 Gentoo Authors |
67 |
+# Distributed under the terms of the GNU General Public License v2 |
68 |
+ |
69 |
+from portage.tests import TestCase |
70 |
+from portage.tests.resolver.ResolverPlayground import (ResolverPlayground, |
71 |
+ ResolverPlaygroundTestCase) |
72 |
+ |
73 |
+class SlotConflictUpdateVirtTestCase(TestCase): |
74 |
+ |
75 |
+ def testSlotConflictUpdateVirt(self): |
76 |
+ |
77 |
+ ebuilds = { |
78 |
+ "dev-db/mysql-connector-c-6.1.11-r2" : { |
79 |
+ "EAPI": "7", |
80 |
+ "SLOT" : "0/18" |
81 |
+ }, |
82 |
+ |
83 |
+ "dev-db/mysql-connector-c-8.0.17-r3" : { |
84 |
+ "EAPI": "7", |
85 |
+ "SLOT" : "0/21" |
86 |
+ }, |
87 |
+ |
88 |
+ "virtual/libmysqlclient-18-r1" : { |
89 |
+ "EAPI": "7", |
90 |
+ "SLOT" : "0/18", |
91 |
+ "RDEPEND": "dev-db/mysql-connector-c:0/18", |
92 |
+ }, |
93 |
+ |
94 |
+ "virtual/libmysqlclient-21" : { |
95 |
+ "EAPI": "7", |
96 |
+ "SLOT" : "0/21", |
97 |
+ "RDEPEND": "dev-db/mysql-connector-c:0/21", |
98 |
+ }, |
99 |
+ |
100 |
+ "dev-perl/DBD-mysql-4.44.0" : { |
101 |
+ "EAPI": "7", |
102 |
+ "RDEPEND": "virtual/libmysqlclient:=", |
103 |
+ }, |
104 |
+ } |
105 |
+ |
106 |
+ installed = { |
107 |
+ "dev-db/mysql-connector-c-6.1.11-r2" : { |
108 |
+ "EAPI": "7", |
109 |
+ "SLOT" : "0/18" |
110 |
+ }, |
111 |
+ |
112 |
+ "virtual/libmysqlclient-18-r1" : { |
113 |
+ "EAPI": "7", |
114 |
+ "SLOT" : "0/18", |
115 |
+ "RDEPEND": "dev-db/mysql-connector-c:0/18", |
116 |
+ }, |
117 |
+ |
118 |
+ "dev-perl/DBD-mysql-4.44.0" : { |
119 |
+ "EAPI": "7", |
120 |
+ "RDEPEND": "virtual/libmysqlclient:0/18=", |
121 |
+ }, |
122 |
+ } |
123 |
+ |
124 |
+ world = ["dev-db/mysql-connector-c", "dev-perl/DBD-mysql"] |
125 |
+ |
126 |
+ test_cases = ( |
127 |
+ # In order to avoid missed updates for bug 692746, create a |
128 |
+ # backtrack node for a downgrade matched by all parent atoms. |
129 |
+ ResolverPlaygroundTestCase( |
130 |
+ ['@world'], |
131 |
+ options = {"--update": True, "--deep": True}, |
132 |
+ success = True, |
133 |
+ mergelist = ['dev-db/mysql-connector-c-8.0.17-r3', 'virtual/libmysqlclient-21', 'dev-perl/DBD-mysql-4.44.0']), |
134 |
+ ) |
135 |
+ |
136 |
+ playground = ResolverPlayground(ebuilds=ebuilds, |
137 |
+ installed=installed, world=world, debug=False) |
138 |
+ try: |
139 |
+ for test_case in test_cases: |
140 |
+ playground.run_TestCase(test_case) |
141 |
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
142 |
+ finally: |
143 |
+ playground.debug = False |
144 |
+ playground.cleanup() |
145 |
diff --git a/lib/portage/tests/resolver/test_slot_operator_complete_graph.py b/lib/portage/tests/resolver/test_slot_operator_complete_graph.py |
146 |
index 1d59bcef1..4dcae71ca 100644 |
147 |
--- a/lib/portage/tests/resolver/test_slot_operator_complete_graph.py |
148 |
+++ b/lib/portage/tests/resolver/test_slot_operator_complete_graph.py |
149 |
@@ -115,7 +115,7 @@ class SlotOperatorCompleteGraphTestCase(TestCase): |
150 |
ResolverPlaygroundTestCase( |
151 |
["=app-misc/meta-pkg-2", "app-misc/C"], |
152 |
options = { |
153 |
- "--backtrack": 5, |
154 |
+ "--backtrack": 9, |
155 |
}, |
156 |
success = True, |
157 |
ambiguous_merge_order = True, |
158 |
diff --git a/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py b/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py |
159 |
index 0a5a7fa78..f8b53e2b5 100644 |
160 |
--- a/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py |
161 |
+++ b/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py |
162 |
@@ -110,7 +110,7 @@ class SlotOperatorRuntimePkgMaskTestCase(TestCase): |
163 |
ResolverPlaygroundTestCase( |
164 |
["=app-misc/meta-pkg-2"], |
165 |
options = { |
166 |
- "--backtrack": 5, |
167 |
+ "--backtrack": 12, |
168 |
}, |
169 |
success = True, |
170 |
ambiguous_merge_order = True, |
171 |
-- |
172 |
2.21.0 |