1 |
On Thu, 2 Nov 2017 02:21:14 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> Prefer to install a new package rather than to downgrade an |
5 |
> installed package. If the installed package should be |
6 |
> downgraded due to it being masked, then allow the downgrade. |
7 |
> |
8 |
> Bug: https://bugs.gentoo.org/635540 |
9 |
> --- |
10 |
> pym/portage/dep/dep_check.py | 11 ++- |
11 |
> .../tests/resolver/test_or_downgrade_installed.py | 97 |
12 |
> ++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 |
13 |
> deletion(-) create mode 100644 |
14 |
> pym/portage/tests/resolver/test_or_downgrade_installed.py |
15 |
> |
16 |
> diff --git a/pym/portage/dep/dep_check.py |
17 |
> b/pym/portage/dep/dep_check.py index 35caecc74..2c69c1c48 100644 |
18 |
> --- a/pym/portage/dep/dep_check.py |
19 |
> +++ b/pym/portage/dep/dep_check.py |
20 |
> @@ -323,8 +323,10 @@ def dep_zapdeps(unreduced, reduced, myroot, |
21 |
> use_binaries=0, trees=None): want_update_pkg = |
22 |
> trees[myroot].get("want_update_pkg") downgrade_probe = |
23 |
> trees[myroot].get("downgrade_probe") vardb = None |
24 |
> + vardb_match_pkgs = None |
25 |
> if "vartree" in trees[myroot]: |
26 |
> vardb = trees[myroot]["vartree"].dbapi |
27 |
> + vardb_match_pkgs = getattr(vardb, 'match_pkgs', None) |
28 |
> if use_binaries: |
29 |
> mydbapi = trees[myroot]["bintree"].dbapi |
30 |
> else: |
31 |
> @@ -355,6 +357,7 @@ def dep_zapdeps(unreduced, reduced, myroot, |
32 |
> use_binaries=0, trees=None): all_use_satisfied = True |
33 |
> all_use_unmasked = True |
34 |
> conflict_downgrade = False |
35 |
> + installed_downgrade = False |
36 |
> slot_atoms = collections.defaultdict(list) |
37 |
> slot_map = {} |
38 |
> cp_map = {} |
39 |
> @@ -419,6 +422,12 @@ def dep_zapdeps(unreduced, reduced, myroot, |
40 |
> use_binaries=0, trees=None): avail_pkg = avail_pkg_use |
41 |
> avail_slot = Atom("%s:%s" % |
42 |
> (atom.cp, avail_pkg.slot)) |
43 |
> + if vardb_match_pkgs is not None: |
44 |
> + inst_pkg = |
45 |
> vardb_match_pkgs(avail_slot) |
46 |
> + if (inst_pkg and avail_pkg < |
47 |
> inst_pkg[-1] and |
48 |
> + not |
49 |
> downgrade_probe(inst_pkg[-1])): |
50 |
> + installed_downgrade = True |
51 |
> + |
52 |
> slot_map[avail_slot] = avail_pkg |
53 |
> slot_atoms[avail_slot].append(atom) |
54 |
> highest_cpv = cp_map.get(avail_pkg.cp) |
55 |
> @@ -487,7 +496,7 @@ def dep_zapdeps(unreduced, reduced, myroot, |
56 |
> use_binaries=0, trees=None): unsat_use_installed.append(this_choice) |
57 |
> else: |
58 |
> unsat_use_non_installed.append(this_choice) |
59 |
> - elif conflict_downgrade: |
60 |
> + elif conflict_downgrade or |
61 |
> installed_downgrade: other.append(this_choice) |
62 |
> else: |
63 |
> all_in_graph = True |
64 |
> diff --git |
65 |
> a/pym/portage/tests/resolver/test_or_downgrade_installed.py |
66 |
> b/pym/portage/tests/resolver/test_or_downgrade_installed.py new file |
67 |
> mode 100644 index 000000000..22307a5bc --- /dev/null |
68 |
> +++ b/pym/portage/tests/resolver/test_or_downgrade_installed.py |
69 |
> @@ -0,0 +1,97 @@ |
70 |
> +# Copyright 2017 Gentoo Foundation |
71 |
> +# Distributed under the terms of the GNU General Public License v2 |
72 |
> + |
73 |
> +from portage.tests import TestCase |
74 |
> +from portage.tests.resolver.ResolverPlayground import ( |
75 |
> + ResolverPlayground, |
76 |
> + ResolverPlaygroundTestCase, |
77 |
> +) |
78 |
> + |
79 |
> +class OrDowngradeInstalledTestCase(TestCase): |
80 |
> + |
81 |
> + def testOrDowngradeInstalled(self): |
82 |
> + ebuilds = { |
83 |
> + 'net-misc/foo-1': { |
84 |
> + 'EAPI': '6', |
85 |
> + 'RDEPEND': '|| |
86 |
> ( sys-libs/glibc[rpc(-)] net-libs/libtirpc )' |
87 |
> + }, |
88 |
> + 'net-libs/libtirpc-1': { |
89 |
> + 'EAPI': '6', |
90 |
> + }, |
91 |
> + 'sys-libs/glibc-2.26': { |
92 |
> + 'EAPI': '6', |
93 |
> + 'IUSE': '' |
94 |
> + }, |
95 |
> + 'sys-libs/glibc-2.24': { |
96 |
> + 'EAPI': '6', |
97 |
> + 'IUSE': '+rpc' |
98 |
> + }, |
99 |
> + } |
100 |
> + |
101 |
> + installed = { |
102 |
> + 'sys-libs/glibc-2.26': { |
103 |
> + 'EAPI': '6', |
104 |
> + 'IUSE': '' |
105 |
> + }, |
106 |
> + } |
107 |
> + |
108 |
> + world = ['sys-libs/glibc'] |
109 |
> + |
110 |
> + test_cases = ( |
111 |
> + # Test bug 635540, where we need to install |
112 |
> libtirpc |
113 |
> + # rather than downgrade glibc. |
114 |
> + ResolverPlaygroundTestCase( |
115 |
> + ['net-misc/foo'], |
116 |
> + success=True, |
117 |
> + mergelist=[ |
118 |
> + 'net-libs/libtirpc-1', |
119 |
> + 'net-misc/foo-1', |
120 |
> + ], |
121 |
> + ), |
122 |
> + ) |
123 |
> + |
124 |
> + playground = ResolverPlayground(debug=False, |
125 |
> + ebuilds=ebuilds, installed=installed, |
126 |
> world=world) + |
127 |
> + try: |
128 |
> + for test_case in test_cases: |
129 |
> + playground.run_TestCase(test_case) |
130 |
> + |
131 |
> self.assertEqual(test_case.test_success, True, |
132 |
> + test_case.fail_msg) |
133 |
> + finally: |
134 |
> + playground.debug = False |
135 |
> + playground.cleanup() |
136 |
> + |
137 |
> + # In some cases it's necessary to downgrade due to |
138 |
> + # the installed package being masked (glibc is a |
139 |
> + # not an ideal example because it's usually not |
140 |
> + # practical to downgrade it). |
141 |
> + user_config = { |
142 |
> + "package.mask" : ( |
143 |
> + ">=sys-libs/glibc-2.26", |
144 |
> + ), |
145 |
> + } |
146 |
> + |
147 |
> + test_cases = ( |
148 |
> + ResolverPlaygroundTestCase( |
149 |
> + ['net-misc/foo'], |
150 |
> + success=True, |
151 |
> + mergelist=[ |
152 |
> + 'sys-libs/glibc-2.24', |
153 |
> + 'net-misc/foo-1', |
154 |
> + ], |
155 |
> + ), |
156 |
> + ) |
157 |
> + |
158 |
> + playground = ResolverPlayground(debug=False, |
159 |
> + ebuilds=ebuilds, installed=installed, |
160 |
> world=world, |
161 |
> + user_config=user_config) |
162 |
> + |
163 |
> + try: |
164 |
> + for test_case in test_cases: |
165 |
> + playground.run_TestCase(test_case) |
166 |
> + |
167 |
> self.assertEqual(test_case.test_success, True, |
168 |
> + test_case.fail_msg) |
169 |
> + finally: |
170 |
> + playground.debug = False |
171 |
> + playground.cleanup() |
172 |
|
173 |
looks good |
174 |
|
175 |
-- |
176 |
Brian Dolbec <dolsen> |