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] dep_zapdeps: prefer choices with fewer new slots (bug 645002)
Date: Sat, 20 Jan 2018 00:44:29
Message-Id: 20180120004341.179598-1-zmedico@gentoo.org
1 Prefer choices with fewer new slots, rather than choices with the lowest
2 total number of slots. This fixes a case triggered by the catalyst stage1
3 build, where paludis was selected to satisfy perl-cleaner dependencies
4 because that choice happened to have a smaller number of slots:
5
6 || (
7 ( sys-apps/portage app-portage/portage-utils )
8 sys-apps/pkgcore
9 sys-apps/paludis
10 )
11
12 Bug: https://bugs.gentoo.org/645002
13 Fixes: 9fdaf9bdbdf5 ("dep_check: use DNF to optimize overlapping virtual || deps (bug 632026)")
14 ---
15 pym/portage/dep/dep_check.py | 12 ++++++++----
16 1 file changed, 8 insertions(+), 4 deletions(-)
17
18 diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
19 index 291626f56..f9b671ac1 100644
20 --- a/pym/portage/dep/dep_check.py
21 +++ b/pym/portage/dep/dep_check.py
22 @@ -296,7 +296,7 @@ def dep_eval(deplist):
23
24 class _dep_choice(SlotObject):
25 __slots__ = ('atoms', 'slot_map', 'cp_map', 'all_available',
26 - 'all_installed_slots')
27 + 'all_installed_slots', 'new_slot_count')
28
29 def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
30 """
31 @@ -498,9 +498,13 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
32 if current_higher or (all_match_current and not all_match_previous):
33 cp_map[avail_pkg.cp] = avail_pkg
34
35 + new_slot_count = (len(slot_map) if graph_db is None else
36 + sum(not graph_db.match_pkgs(slot_atom) for slot_atom in slot_map))
37 +
38 this_choice = _dep_choice(atoms=atoms, slot_map=slot_map,
39 cp_map=cp_map, all_available=all_available,
40 - all_installed_slots=False)
41 + all_installed_slots=False,
42 + new_slot_count=new_slot_count)
43 if all_available:
44 # The "all installed" criterion is not version or slot specific.
45 # If any version of a package is already in the graph then we
46 @@ -655,8 +659,8 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
47 if len(choices) < 2:
48 continue
49 # Prefer choices with all_installed_slots for bug #480736, and
50 - # choices with a smaller number of packages for bug #632026.
51 - choices.sort(key=lambda x: (not x.all_installed_slots, len(x.slot_map)))
52 + # choices with a smaller number of new slots for bug #632026.
53 + choices.sort(key=lambda x: (not x.all_installed_slots, x.new_slot_count))
54 for choice_1 in choices[1:]:
55 cps = set(choice_1.cp_map)
56 for choice_2 in choices:
57 --
58 2.13.6