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