Gentoo Archives: gentoo-commits

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