1 |
Fix the code from bug 643974 to set the installed_downgrade flag only |
2 |
if the selected newer package is either installed or in the graph. This |
3 |
is currently needed for appropriate handling of virtual/rust-1.19.0, |
4 |
since there's an upgrade to dev-lang/rust-1.23.0 available which may |
5 |
not be desired since it would mean that dev-lang/rust-bin-1.19.0 has |
6 |
to be installed in order to satisfy virtual/rust-1.19.0: |
7 |
|
8 |
|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* ) |
9 |
|
10 |
So, the rust-bin choice is desirable only if the rust-1.23.0 package is |
11 |
already installed or in the graph. |
12 |
|
13 |
Fixes: 86ba22da7a2f ("dep_zapdeps: install new package, allow upgrade (bug 643974)") |
14 |
Bug: https://bugs.gentoo.org/645416 |
15 |
--- |
16 |
pym/portage/dep/dep_check.py | 10 ++-- |
17 |
.../tests/resolver/test_or_upgrade_installed.py | 59 ++++++++++++++++++++++ |
18 |
2 files changed, 66 insertions(+), 3 deletions(-) |
19 |
|
20 |
diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py |
21 |
index c56f545ec..7e5a3186e 100644 |
22 |
--- a/pym/portage/dep/dep_check.py |
23 |
+++ b/pym/portage/dep/dep_check.py |
24 |
@@ -463,11 +463,15 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None): |
25 |
avail_pkg = avail_pkg_use |
26 |
avail_slot = Atom("%s:%s" % (atom.cp, avail_pkg.slot)) |
27 |
|
28 |
- if downgrade_probe is not None: |
29 |
+ if downgrade_probe is not None and graph is not None: |
30 |
highest_in_slot = mydbapi_match_pkgs(avail_slot) |
31 |
+ highest_in_slot = (highest_in_slot[-1] |
32 |
+ if highest_in_slot else None) |
33 |
if (avail_pkg and highest_in_slot and |
34 |
- avail_pkg < highest_in_slot[-1] and |
35 |
- not downgrade_probe(avail_pkg)): |
36 |
+ avail_pkg < highest_in_slot and |
37 |
+ not downgrade_probe(avail_pkg) and |
38 |
+ (highest_in_slot.installed or |
39 |
+ highest_in_slot in graph)): |
40 |
installed_downgrade = True |
41 |
|
42 |
slot_map[avail_slot] = avail_pkg |
43 |
diff --git a/pym/portage/tests/resolver/test_or_upgrade_installed.py b/pym/portage/tests/resolver/test_or_upgrade_installed.py |
44 |
index 6e01d321d..7018e08de 100644 |
45 |
--- a/pym/portage/tests/resolver/test_or_upgrade_installed.py |
46 |
+++ b/pym/portage/tests/resolver/test_or_upgrade_installed.py |
47 |
@@ -99,3 +99,62 @@ class OrUpgradeInstalledTestCase(TestCase): |
48 |
finally: |
49 |
playground.debug = False |
50 |
playground.cleanup() |
51 |
+ |
52 |
+ def testVirtualRust(self): |
53 |
+ ebuilds = { |
54 |
+ 'dev-lang/rust-1.19.0': {}, |
55 |
+ 'dev-lang/rust-1.23.0': {}, |
56 |
+ 'dev-lang/rust-bin-1.19.0': {}, |
57 |
+ 'virtual/rust-1.19.0': { |
58 |
+ 'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )' |
59 |
+ }, |
60 |
+ } |
61 |
+ |
62 |
+ installed = { |
63 |
+ 'dev-lang/rust-1.19.0': {}, |
64 |
+ 'virtual/rust-1.19.0': { |
65 |
+ 'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )' |
66 |
+ }, |
67 |
+ } |
68 |
+ |
69 |
+ world = ['virtual/rust'] |
70 |
+ |
71 |
+ test_cases = ( |
72 |
+ # Test bug 645416, where rust-bin-1.19.0 was pulled in |
73 |
+ # inappropriately due to the rust-1.23.0 update being |
74 |
+ # available. |
75 |
+ ResolverPlaygroundTestCase( |
76 |
+ ['virtual/rust'], |
77 |
+ options={'--update': True, '--deep': True}, |
78 |
+ success=True, |
79 |
+ mergelist=[] |
80 |
+ ), |
81 |
+ # Test upgrade to rust-1.23.0, which is only possible |
82 |
+ # if rust-bin-1.19.0 is installed in order to satisfy |
83 |
+ # virtual/rust-1.19.0. |
84 |
+ ResolverPlaygroundTestCase( |
85 |
+ ['=dev-lang/rust-1.23.0', 'virtual/rust'], |
86 |
+ options={'--update': True, '--deep': True}, |
87 |
+ all_permutations=True, |
88 |
+ success=True, |
89 |
+ ambiguous_merge_order=True, |
90 |
+ mergelist=( |
91 |
+ ( |
92 |
+ 'dev-lang/rust-1.23.0', |
93 |
+ 'dev-lang/rust-bin-1.19.0', |
94 |
+ ), |
95 |
+ ), |
96 |
+ ), |
97 |
+ ) |
98 |
+ |
99 |
+ playground = ResolverPlayground(debug=False, |
100 |
+ ebuilds=ebuilds, installed=installed, world=world) |
101 |
+ |
102 |
+ try: |
103 |
+ for test_case in test_cases: |
104 |
+ playground.run_TestCase(test_case) |
105 |
+ self.assertEqual(test_case.test_success, True, |
106 |
+ test_case.fail_msg) |
107 |
+ finally: |
108 |
+ playground.debug = False |
109 |
+ playground.cleanup() |
110 |
-- |
111 |
2.13.6 |