1 |
Place choices that do not pull in new slots into a preferred |
2 |
choice bin, so that they will not be mixed with choices that |
3 |
contain unnecessary upgrades. This fixes the included test |
4 |
case so that an unnecessary new python slot is not pulled in. |
5 |
|
6 |
Bug: https://bugs.gentoo.org/828136 |
7 |
Signed-off-by: Zac Medico <zmedico@g.o> |
8 |
--- |
9 |
lib/portage/dep/dep_check.py | 6 +- |
10 |
.../resolver/test_unecessary_slot_upgrade.py | 62 +++++++++++++++++++ |
11 |
2 files changed, 67 insertions(+), 1 deletion(-) |
12 |
create mode 100644 lib/portage/tests/resolver/test_unecessary_slot_upgrade.py |
13 |
|
14 |
diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py |
15 |
index 9fccda08b..8ca4c0b9d 100644 |
16 |
--- a/lib/portage/dep/dep_check.py |
17 |
+++ b/lib/portage/dep/dep_check.py |
18 |
@@ -376,6 +376,7 @@ def dep_zapdeps( |
19 |
# c) contains masked installed packages |
20 |
# d) is the first item |
21 |
|
22 |
+ no_new_slots = [] |
23 |
preferred_in_graph = [] |
24 |
preferred_installed = preferred_in_graph |
25 |
preferred_any_slot = preferred_in_graph |
26 |
@@ -391,6 +392,7 @@ def dep_zapdeps( |
27 |
# unsat_use_* must come after preferred_non_installed |
28 |
# for correct ordering in cases like || ( foo[a] foo[b] ). |
29 |
choice_bins = ( |
30 |
+ no_new_slots, |
31 |
preferred_in_graph, |
32 |
preferred_non_installed, |
33 |
unsat_use_in_graph, |
34 |
@@ -689,7 +691,9 @@ def dep_zapdeps( |
35 |
other.append(this_choice) |
36 |
else: |
37 |
if all_use_satisfied: |
38 |
- if all_in_graph: |
39 |
+ if new_slot_count == 0 and not want_update: |
40 |
+ no_new_slots.append(this_choice) |
41 |
+ elif all_in_graph: |
42 |
preferred_in_graph.append(this_choice) |
43 |
elif all_installed: |
44 |
if all_installed_slots: |
45 |
diff --git a/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py b/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py |
46 |
new file mode 100644 |
47 |
index 000000000..f8b8b346a |
48 |
--- /dev/null |
49 |
+++ b/lib/portage/tests/resolver/test_unecessary_slot_upgrade.py |
50 |
@@ -0,0 +1,62 @@ |
51 |
+# Copyright 2021 Gentoo Authors |
52 |
+# Distributed under the terms of the GNU General Public License v2 |
53 |
+ |
54 |
+from portage.tests import TestCase |
55 |
+from portage.tests.resolver.ResolverPlayground import ( |
56 |
+ ResolverPlayground, |
57 |
+ ResolverPlaygroundTestCase, |
58 |
+) |
59 |
+ |
60 |
+ |
61 |
+class UnnecessarySlotrUpgradeTestCase(TestCase): |
62 |
+ def testUnnecessarySlotUpgrade(self): |
63 |
+ ebuilds = { |
64 |
+ "app-misc/a-1": { |
65 |
+ "EAPI": "8", |
66 |
+ "RDEPEND": "|| ( dev-lang/python:3.10 dev-lang/python:3.9 ) || ( dev-lang/python:3.10 dev-lang/python:3.9 )", |
67 |
+ }, |
68 |
+ "dev-lang/python-3.9": {"SLOT": "3.9"}, |
69 |
+ "dev-lang/python-3.10": {"SLOT": "3.10"}, |
70 |
+ } |
71 |
+ |
72 |
+ installed = { |
73 |
+ "dev-lang/python-3.9": {"SLOT": "3.9"}, |
74 |
+ } |
75 |
+ |
76 |
+ test_cases = ( |
77 |
+ # Test bug 828136, where an unnecessary python slot upgrade |
78 |
+ # was triggered. |
79 |
+ ResolverPlaygroundTestCase( |
80 |
+ [ |
81 |
+ "app-misc/a", |
82 |
+ ], |
83 |
+ success=True, |
84 |
+ mergelist=("app-misc/a-1",), |
85 |
+ ), |
86 |
+ ResolverPlaygroundTestCase( |
87 |
+ [ |
88 |
+ "app-misc/a", |
89 |
+ ], |
90 |
+ success=True, |
91 |
+ mergelist=( |
92 |
+ "dev-lang/python-3.10", |
93 |
+ "app-misc/a-1", |
94 |
+ ), |
95 |
+ options={ |
96 |
+ "--deep": True, |
97 |
+ "--update": True, |
98 |
+ }, |
99 |
+ ), |
100 |
+ ) |
101 |
+ |
102 |
+ playground = ResolverPlayground( |
103 |
+ debug=False, ebuilds=ebuilds, installed=installed |
104 |
+ ) |
105 |
+ |
106 |
+ try: |
107 |
+ for test_case in test_cases: |
108 |
+ playground.run_TestCase(test_case) |
109 |
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg) |
110 |
+ finally: |
111 |
+ playground.debug = False |
112 |
+ playground.cleanup() |
113 |
-- |
114 |
2.32.0 |