Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] dep_zapdeps: install new package, allow upgrade (bug 643974)
Date: Wed, 10 Jan 2018 17:00:20
Message-Id: CAAr7Pr-BSM-LWtaXwqm6kLGUucogd2Bu-FmA=AqwTN+Cab792w@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH] dep_zapdeps: install new package, allow upgrade (bug 643974) by Zac Medico
1 The code lgtm.
2
3 Slightly unsure if we need an entirely new test, as opposed to just
4 generalizing the test cases (like you did the code). But either way is
5 probably fine.
6
7 -A
8
9 On Tue, Jan 9, 2018 at 2:55 PM, Zac Medico <zmedico@g.o> wrote:
10
11 > Prefer to install a new package in order to allow upgrade of an
12 > installed package. This generalizes the code from bug 635540 so
13 > that it both allows desirable upgrades and prevents unwanted
14 > downgrades.
15 >
16 > Fixes: 7c58e3737616 ("dep_zapdeps: install new package, avoid downgrade
17 > (bug 635540)")
18 > Bug: https://bugs.gentoo.org/643974
19 > ---
20 > pym/portage/dep/dep_check.py | 11 ++-
21 > .../tests/resolver/test_or_upgrade_installed.py | 94
22 > ++++++++++++++++++++++
23 > 2 files changed, 99 insertions(+), 6 deletions(-)
24 > create mode 100644 pym/portage/tests/resolver/
25 > test_or_upgrade_installed.py
26 >
27 > diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
28 > index 2bb9dc339..291626f56 100644
29 > --- a/pym/portage/dep/dep_check.py
30 > +++ b/pym/portage/dep/dep_check.py
31 > @@ -366,10 +366,8 @@ def dep_zapdeps(unreduced, reduced, myroot,
32 > use_binaries=0, trees=None):
33 > want_update_pkg = trees[myroot].get("want_update_pkg")
34 > downgrade_probe = trees[myroot].get("downgrade_probe")
35 > vardb = None
36 > - vardb_match_pkgs = None
37 > if "vartree" in trees[myroot]:
38 > vardb = trees[myroot]["vartree"].dbapi
39 > - vardb_match_pkgs = getattr(vardb, 'match_pkgs', None)
40 > if use_binaries:
41 > mydbapi = trees[myroot]["bintree"].dbapi
42 > else:
43 > @@ -465,10 +463,11 @@ def dep_zapdeps(unreduced, reduced, myroot,
44 > use_binaries=0, trees=None):
45 > avail_pkg = avail_pkg_use
46 > avail_slot = Atom("%s:%s" %
47 > (atom.cp, avail_pkg.slot))
48 >
49 > - if vardb_match_pkgs is not None and
50 > downgrade_probe is not None:
51 > - inst_pkg = vardb_match_pkgs(avail_slot)
52 > - if (inst_pkg and avail_pkg < inst_pkg[-1]
53 > and
54 > - not downgrade_probe(inst_pkg[-1]))
55 > :
56 > + if downgrade_probe is not None:
57 > + highest_in_slot =
58 > mydbapi_match_pkgs(avail_slot)
59 > + if (avail_pkg and highest_in_slot and
60 > + avail_pkg < highest_in_slot[-1] and
61 > + not downgrade_probe(avail_pkg)):
62 > installed_downgrade = True
63 >
64 > slot_map[avail_slot] = avail_pkg
65 > diff --git a/pym/portage/tests/resolver/test_or_upgrade_installed.py
66 > b/pym/portage/tests/resolver/test_or_upgrade_installed.py
67 > new file mode 100644
68 > index 000000000..70703a614
69 > --- /dev/null
70 > +++ b/pym/portage/tests/resolver/test_or_upgrade_installed.py
71 > @@ -0,0 +1,94 @@
72 > +# Copyright 2018 Gentoo Foundation
73 > +# Distributed under the terms of the GNU General Public License v2
74 > +
75 > +from portage.tests import TestCase
76 > +from portage.tests.resolver.ResolverPlayground import (
77 > + ResolverPlayground,
78 > + ResolverPlaygroundTestCase,
79 > +)
80 > +
81 > +class OrUpgradeInstalledTestCase(TestCase):
82 > +
83 > + def testOrUpgradeInstalled(self):
84 > + ebuilds = {
85 > + 'net-misc/foo-1': {
86 > + 'EAPI': '6',
87 > + 'RDEPEND': '|| ( sys-libs/glibc[rpc(-)]
88 > 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.24': {
105 > + 'EAPI': '6',
106 > + 'IUSE': '+rpc',
107 > + 'USE': 'rpc',
108 > + },
109 > + }
110 > +
111 > + world = ['sys-libs/glibc']
112 > +
113 > + test_cases = (
114 > + # Test bug 643974, where we need to install
115 > libtirpc
116 > + # in order to upgrade glibc.
117 > + ResolverPlaygroundTestCase(
118 > + ['net-misc/foo', '@world'],
119 > + options={'--update': True, '--deep': True},
120 > + success=True,
121 > + mergelist=['net-libs/libtirpc-1',
122 > 'sys-libs/glibc-2.26', 'net-misc/foo-1']
123 > + ),
124 > + )
125 > +
126 > + playground = ResolverPlayground(debug=False,
127 > + ebuilds=ebuilds, installed=installed, world=world)
128 > +
129 > + try:
130 > + for test_case in test_cases:
131 > + playground.run_TestCase(test_case)
132 > + self.assertEqual(test_case.test_success,
133 > True,
134 > + test_case.fail_msg)
135 > + finally:
136 > + playground.debug = False
137 > + playground.cleanup()
138 > +
139 > + # In some cases it's necessary to avoid upgrade due to
140 > + # the package being masked.
141 > + user_config = {
142 > + "package.mask" : (
143 > + ">=sys-libs/glibc-2.26",
144 > + ),
145 > + }
146 > +
147 > + test_cases = (
148 > + ResolverPlaygroundTestCase(
149 > + ['net-misc/foo', '@world'],
150 > + options={'--update': True, '--deep': True},
151 > + success=True,
152 > + mergelist=[
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,
166 > True,
167 > + test_case.fail_msg)
168 > + finally:
169 > + playground.debug = False
170 > + playground.cleanup()
171 > --
172 > 2.13.6
173 >
174 >
175 >

Replies