Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] _add_dep: less aggressive backtracking (bug 693836)
Date: Wed, 11 Sep 2019 08:53:22
Message-Id: 20190911085255.31116-1-zmedico@gentoo.org
1 In order to suppress the sort of aggressive backtracking that can
2 trigger undesirable downgrades as in bug 693836, do not backtrack
3 for an unsatisfied dependency if there's an available package in
4 the runtime package mask which was involved in a slot conflict and
5 satisfied all involved parent atoms. Instead, discard the current
6 depgraph in favor of other backtracking configurations that may
7 exist. This case would not have been encountered prior to the fix
8 for bug 692746 which enabled backtracking for the type of slot
9 conflict that is detected here.
10
11 Fixes: 994ac00aa764 ("_slot_confict_backtrack: consider masking a package matched by all parent atoms (bug 692746)")
12 Bug: https://bugs.gentoo.org/693836
13 Signed-off-by: Zac Medico <zmedico@g.o>
14 ---
15 lib/_emerge/depgraph.py | 13 +++
16 .../test_aggressive_backtrack_downgrade.py | 91 +++++++++++++++++++
17 2 files changed, 104 insertions(+)
18 create mode 100644 lib/portage/tests/resolver/test_aggressive_backtrack_downgrade.py
19
20 diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
21 index 6be1b3ec7..ab9f89cc2 100644
22 --- a/lib/_emerge/depgraph.py
23 +++ b/lib/_emerge/depgraph.py
24 @@ -2888,6 +2888,19 @@ class depgraph(object):
25 dep.atom.without_use if dep.atom.package
26 else dep.atom, onlydeps=dep.onlydeps)
27 if dep_pkg is None:
28 +
29 + # In order to suppress the sort of aggressive
30 + # backtracking that can trigger undesirable downgrades
31 + # as in bug 693836, do not backtrack if there's an
32 + # available package which was involved in a slot
33 + # conflict and satisfied all involved parent atoms.
34 + for dep_pkg, reasons in self._dynamic_config._runtime_pkg_mask.items():
35 + if (dep.atom.match(dep_pkg) and
36 + len(reasons) == 1 and "slot conflict" in reasons and
37 + not reasons["slot conflict"]):
38 + self._dynamic_config._skip_restart = True
39 + return 0
40 +
41 self._dynamic_config._backtrack_infos["missing dependency"] = dep
42 self._dynamic_config._need_restart = True
43 if debug:
44 diff --git a/lib/portage/tests/resolver/test_aggressive_backtrack_downgrade.py b/lib/portage/tests/resolver/test_aggressive_backtrack_downgrade.py
45 new file mode 100644
46 index 000000000..ab4a83ee5
47 --- /dev/null
48 +++ b/lib/portage/tests/resolver/test_aggressive_backtrack_downgrade.py
49 @@ -0,0 +1,91 @@
50 +# Copyright 2019 Gentoo Authors
51 +# Distributed under the terms of the GNU General Public License v2
52 +
53 +from portage.tests import TestCase
54 +from portage.tests.resolver.ResolverPlayground import (ResolverPlayground,
55 + ResolverPlaygroundTestCase)
56 +
57 +class AgressiveBacktrackDowngradeTestCase(TestCase):
58 +
59 + def testAgressiveBacktrackDowngrade(self):
60 +
61 + ebuilds = {
62 + "www-client/firefox-69.0" : {
63 + "EAPI": "7",
64 + "RDEPEND": "=media-libs/libvpx-1.7*:0=[postproc] media-video/ffmpeg"
65 + },
66 +
67 + "www-client/firefox-60.9.0" : {
68 + "EAPI": "7",
69 + "RDEPEND": ""
70 + },
71 +
72 + "media-libs/libvpx-1.8.0" : {
73 + "EAPI": "7",
74 + "SLOT" : "0/6",
75 + "IUSE": "postproc",
76 + },
77 +
78 + "media-libs/libvpx-1.7.0" : {
79 + "EAPI": "7",
80 + "SLOT" : "0/5",
81 + "IUSE": "+postproc",
82 + },
83 +
84 + "media-libs/libvpx-1.5.0" : {
85 + "EAPI": "7",
86 + "SLOT" : "0/4",
87 + "IUSE": "postproc",
88 + },
89 +
90 + "media-video/ffmpeg-4.2" : {
91 + "EAPI": "7",
92 + "RDEPEND": "media-libs/libvpx:=",
93 + },
94 + }
95 +
96 + installed = {
97 + "www-client/firefox-69.0" : {
98 + "EAPI": "7",
99 + "RDEPEND": "=media-libs/libvpx-1.7*:0/5=[postproc] media-video/ffmpeg"
100 + },
101 +
102 + "media-libs/libvpx-1.7.0" : {
103 + "EAPI": "7",
104 + "SLOT" : "0/5",
105 + "IUSE": "+postproc",
106 + "USE": "postproc",
107 + },
108 +
109 + "media-video/ffmpeg-4.2" : {
110 + "EAPI": "7",
111 + "RDEPEND": "media-libs/libvpx:0/5=",
112 + },
113 + }
114 +
115 + world = ["media-video/ffmpeg", "www-client/firefox"]
116 +
117 + test_cases = (
118 + # Test bug 693836, where an attempt to upgrade libvpx lead
119 + # to aggressive backtracking which ultimately triggered an
120 + # undesirable firefox downgrade like this:
121 + # [ebuild U ] media-libs/libvpx-1.8.0 [1.7.0]
122 + # [ebuild UD ] www-client/firefox-60.9.0 [69.0]
123 + # [ebuild rR ] media-video/ffmpeg-4.2
124 + ResolverPlaygroundTestCase(
125 + ['@world'],
126 + options = {"--update": True, "--deep": True},
127 + success = True,
128 + mergelist = [],
129 + ),
130 + )
131 +
132 + playground = ResolverPlayground(ebuilds=ebuilds,
133 + installed=installed, world=world, debug=False)
134 + try:
135 + for test_case in test_cases:
136 + playground.run_TestCase(test_case)
137 + self.assertEqual(test_case.test_success, True, test_case.fail_msg)
138 + finally:
139 + playground.debug = False
140 + playground.cleanup()
141 --
142 2.21.0