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: exclude virtuals from new_slot_count (bug 645190)
Date: Sun, 21 Jan 2018 00:23:59
Message-Id: CAAr7Pr8Jg7wD=QHxn_A1uN3gecC-K81Ws30wRKZQ6ZCVGA_T4g@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH] dep_zapdeps: exclude virtuals from new_slot_count (bug 645190) by Zac Medico
1 On Sat, Jan 20, 2018 at 7:10 PM, Zac Medico <zmedico@g.o> wrote:
2
3 > Fix new_slot_count to exclude virtual packages, since they are considered
4 > to have zero-cost. This solves an issue where the catalyst stage1 build
5 > would unexpectedly pull in static-dev to satisfy virtual/dev-manager,
6 > but eudev is the preferred choice.
7 >
8
9 > Bug: https://bugs.gentoo.org/645190
10 > Fixes: 9fdaf9bdbdf5 ("dep_check: use DNF to optimize overlapping virtual
11 > || deps (bug 632026)")
12 > Reported-by: Ben Kohler <bkohler@×××××.com>
13 > ---
14 > pym/portage/dep/dep_check.py | 3 +-
15 > .../resolver/test_virtual_minimize_children.py | 61
16 > ++++++++++++++++++++++
17 > 2 files changed, 63 insertions(+), 1 deletion(-)
18 >
19 > diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
20 > index 7cf338819..c56f545ec 100644
21 > --- a/pym/portage/dep/dep_check.py
22 > +++ b/pym/portage/dep/dep_check.py
23 > @@ -499,7 +499,8 @@ def dep_zapdeps(unreduced, reduced, myroot,
24 > use_binaries=0, trees=None):
25 > cp_map[avail_pkg.cp] = avail_pkg
26 >
27 > new_slot_count = (len(slot_map) if graph_db is None else
28 > - sum(not graph_db.match_pkgs(slot_atom) for
29 > slot_atom in slot_map))
30 > + sum(not graph_db.match_pkgs(slot_atom) for
31 > slot_atom in slot_map
32 > + if not slot_atom.cp.startswith("virtual/")))
33 >
34
35 I see this logic all over dep_zapdeps. But AFAIK its already using
36 instances of Atom here.
37 Can't we encode the cost inside of Atom, so that we don't need to carve out
38 that virtual atoms are 0 cost?
39
40 Then we could write something like:
41
42 new_slot_count = len(slot_map) if graph_db is None else
43 sum(slot_atom.cost() for slot_atom in slot_map if not
44 graph_db.match_pkgs(slot_atom))
45
46 Then virtuals would just have a cost() of 0. And others could have other
47 costs (or just 1.)
48
49
50 >
51 > this_choice = _dep_choice(atoms=atoms, slot_map=slot_map,
52 > cp_map=cp_map, all_available=all_available,
53 > diff --git a/pym/portage/tests/resolver/test_virtual_minimize_children.py
54 > b/pym/portage/tests/resolver/test_virtual_minimize_children.py
55 > index 6eb0409f2..287445e58 100644
56 > --- a/pym/portage/tests/resolver/test_virtual_minimize_children.py
57 > +++ b/pym/portage/tests/resolver/test_virtual_minimize_children.py
58 > @@ -226,3 +226,64 @@ class VirtualMinimizeChildrenTestCase(TestCase):
59 > finally:
60 > playground.debug = False
61 > playground.cleanup()
62 > +
63 > + def testVirtualDevManager(self):
64 > + ebuilds = {
65 > + 'sys-fs/eudev-3.1.5': {},
66 > + 'sys-fs/static-dev-0.1': {},
67 > + 'sys-fs/udev-233': {},
68 > + 'virtual/dev-manager-0': {
69 > + 'RDEPEND': '''
70 > + || (
71 > + virtual/udev
72 > + sys-fs/static-dev
73 > + )'''
74 > + },
75 > + 'virtual/udev-0': {
76 > + 'RDEPEND': '''
77 > + || (
78 > + >=sys-fs/eudev-2.1.1
79 > + >=sys-fs/udev-217
80 > + )'''
81 > + },
82 > + }
83 > +
84 > + test_cases = (
85 > + # Test bug 645190, where static-dev was pulled in
86 > instead
87 > + # of eudev.
88 > + ResolverPlaygroundTestCase(
89 > + [
90 > + 'virtual/dev-manager',
91 > + ],
92 > + success=True,
93 > + mergelist=(
94 > + 'sys-fs/eudev-3.1.5',
95 > + 'virtual/udev-0',
96 > + 'virtual/dev-manager-0',
97 > + ),
98 > + ),
99 > + # Test static-dev preference.
100 > + ResolverPlaygroundTestCase(
101 > + [
102 > + 'sys-fs/static-dev',
103 > + 'virtual/dev-manager',
104 > + ],
105 > + all_permutations=True,
106 > + success=True,
107 > + mergelist=(
108 > + 'sys-fs/static-dev-0.1',
109 > + 'virtual/dev-manager-0',
110 > + ),
111 > + ),
112 > + )
113 > +
114 > + playground = ResolverPlayground(debug=False,
115 > ebuilds=ebuilds)
116 > +
117 > + try:
118 > + for test_case in test_cases:
119 > + playground.run_TestCase(test_case)
120 > + self.assertEqual(test_case.test_success,
121 > True,
122 > + test_case.fail_msg)
123 > + finally:
124 > + playground.debug = False
125 > + playground.cleanup()
126 > --
127 > 2.13.6
128 >
129 >
130 >

Replies