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] depgraph: fix backtracking for slot operator rebuilds (bug 612042)
Date: Wed, 08 Mar 2017 11:09:30
Message-Id: 20170308110906.31107-1-zmedico@gentoo.org
1 Fix package selection logic to avoid pulling in undesirable
2 rebuilds/updates during backtracking for slot operator rebuilds.
3 The undesirable rebuilds/updates have sent some calculations off
4 course, by triggering more and more rebuilds/updates with each
5 backtracking run.
6
7 In order to solve the problem, make various adjustments to the
8 package selection logic so that installed packages are preferred
9 over rebuilds/updates when appropriate. Also update unit tests
10 to work with these adjustments.
11
12 Fixes: 5842e87872fd ("Fix slot operator handling bug")
13 X-Gentoo-bug: 612042
14 X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=612042
15 ---
16 pym/_emerge/depgraph.py | 11 +++++++++--
17 .../resolver/soname/test_slot_conflict_reinstall.py | 16 +++++++++++++++-
18 pym/portage/tests/resolver/test_slot_abi.py | 12 +++++-------
19 pym/portage/tests/resolver/test_slot_conflict_rebuild.py | 8 +++++++-
20 4 files changed, 36 insertions(+), 11 deletions(-)
21
22 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
23 index ce0fde1..3ba631e 100644
24 --- a/pym/_emerge/depgraph.py
25 +++ b/pym/_emerge/depgraph.py
26 @@ -2304,7 +2304,7 @@ class depgraph(object):
27 # Check for slot update first, since we don't want to
28 # trigger reinstall of the child package when a newer
29 # slot will be used instead.
30 - if rebuild_if_new_slot:
31 + if rebuild_if_new_slot and dep.want_update:
32 new_dep = self._slot_operator_update_probe(dep,
33 new_child_slot=True)
34 if new_dep is not None:
35 @@ -6241,7 +6241,7 @@ class depgraph(object):
36 if highest_installed is None or pkg.version > highest_installed.version:
37 highest_installed = pkg
38
39 - if highest_installed:
40 + if highest_installed and self._want_update_pkg(parent, highest_installed):
41 non_installed = [pkg for pkg in matched_packages \
42 if not pkg.installed and pkg.version > highest_installed.version]
43
44 @@ -6285,11 +6285,18 @@ class depgraph(object):
45 built_timestamp != installed_timestamp:
46 return built_pkg, existing_node
47
48 + inst_pkg = None
49 for pkg in matched_packages:
50 + if pkg.installed:
51 + inst_pkg = pkg
52 if pkg.installed and pkg.invalid:
53 matched_packages = [x for x in \
54 matched_packages if x is not pkg]
55
56 + if (inst_pkg is not None and parent is not None and
57 + not self._want_update_pkg(parent, inst_pkg)):
58 + return inst_pkg, existing_node
59 +
60 if avoid_update:
61 for pkg in matched_packages:
62 if pkg.installed and self._pkg_visibility_check(pkg, autounmask_level):
63 diff --git a/pym/portage/tests/resolver/soname/test_slot_conflict_reinstall.py b/pym/portage/tests/resolver/soname/test_slot_conflict_reinstall.py
64 index f474761..f715444 100644
65 --- a/pym/portage/tests/resolver/soname/test_slot_conflict_reinstall.py
66 +++ b/pym/portage/tests/resolver/soname/test_slot_conflict_reinstall.py
67 @@ -251,13 +251,27 @@ class SonameSlotConflictReinstallTestCase(TestCase):
68 success = True,
69 mergelist = [
70 '[binary]app-misc/B-2',
71 + '[binary]app-misc/A-2',
72 + ]
73 + ),
74 + ResolverPlaygroundTestCase(
75 + ["@world"],
76 + options = {
77 + "--ignore-soname-deps": "n",
78 + "--usepkgonly": True,
79 + "--update": True,
80 + "--deep": True,
81 + },
82 + success = True,
83 + mergelist = [
84 + '[binary]app-misc/B-2',
85 '[binary]app-misc/C-1',
86 '[binary]app-misc/A-2',
87 ]
88 ),
89 )
90
91 - world = []
92 + world = ['app-misc/A']
93
94 playground = ResolverPlayground(binpkgs=binpkgs,
95 installed=installed, world=world, debug=False)
96 diff --git a/pym/portage/tests/resolver/test_slot_abi.py b/pym/portage/tests/resolver/test_slot_abi.py
97 index 7263504..7dbbebe 100644
98 --- a/pym/portage/tests/resolver/test_slot_abi.py
99 +++ b/pym/portage/tests/resolver/test_slot_abi.py
100 @@ -170,23 +170,21 @@ class SlotAbiTestCase(TestCase):
101
102 test_cases = (
103
104 + # The first 2 test cases don't trigger a libreoffice rebuild
105 + # because sys-libs/db is the only package requested, and a
106 + # rebuild is not necessary because the sys-libs/db:4.7 slot
107 + # remains installed.
108 ResolverPlaygroundTestCase(
109 ["sys-libs/db"],
110 options = {"--oneshot": True},
111 success = True,
112 - mergelist = ["sys-libs/db-4.8", "app-office/libreoffice-3.5.4.2"]),
113 -
114 - ResolverPlaygroundTestCase(
115 - ["sys-libs/db"],
116 - options = {"--oneshot": True, "--ignore-built-slot-operator-deps": "y"},
117 - success = True,
118 mergelist = ["sys-libs/db-4.8"]),
119
120 ResolverPlaygroundTestCase(
121 ["sys-libs/db"],
122 options = {"--oneshot": True, "--usepkg": True},
123 success = True,
124 - mergelist = ["[binary]sys-libs/db-4.8", "app-office/libreoffice-3.5.4.2"]),
125 + mergelist = ["[binary]sys-libs/db-4.8"]),
126
127 ResolverPlaygroundTestCase(
128 ["sys-libs/db"],
129 diff --git a/pym/portage/tests/resolver/test_slot_conflict_rebuild.py b/pym/portage/tests/resolver/test_slot_conflict_rebuild.py
130 index 2dfa79c..95b6396 100644
131 --- a/pym/portage/tests/resolver/test_slot_conflict_rebuild.py
132 +++ b/pym/portage/tests/resolver/test_slot_conflict_rebuild.py
133 @@ -165,7 +165,7 @@ class SlotConflictRebuildTestCase(TestCase):
134 ["app-misc/A"],
135 ignore_mergelist_order=True,
136 all_permutations=True,
137 - options = {"--backtrack": 3, '--deep': True},
138 + options = {"--backtrack": 3, '--update': True, '--deep': True},
139 success = True,
140 mergelist = expected_mergelist),
141 )
142 @@ -229,6 +229,12 @@ class SlotConflictRebuildTestCase(TestCase):
143 ResolverPlaygroundTestCase(
144 ["app-misc/A"],
145 success = True,
146 + mergelist = ['app-misc/A-2']),
147 +
148 + ResolverPlaygroundTestCase(
149 + ["app-misc/A"],
150 + options={"--update": True, "--deep": True},
151 + success = True,
152 mergelist = ['app-misc/B-2', 'app-misc/C-1', 'app-misc/A-2']),
153 )
154
155 --
156 2.10.2

Replies