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] _expand_new_virtuals: constrain output for dep_zapdeps (bug 597752)
Date: Mon, 31 Oct 2016 06:17:44
Message-Id: 1477894504-11525-1-git-send-email-zmedico@gentoo.org
1 Constrain _expand_new_virtuals output in order to avoid incorrect
2 re-ordering of || deps in the dep_zapdeps function, as reported in
3 bug 597752.
4
5 The incorrect dep_zapdeps behavior involved a problem in the
6 construction of the _dep_choice.cp_map dictionary inside the
7 dep_zapdeps function, with this input:
8
9 || ( dev-java/icedtea-bin:8 =virtual/jdk-1.8.0-r3 >=virtual/jdk-1.5 )
10 ( dev-java/icedtea-bin:7 =virtual/jdk-1.7.0-r2 >=virtual/jdk-1.5 )
11
12 The cp_map for virtual/jdk-1.7.0-r2 erroneously contained
13 virtual/jdk-1.8.0-r3 because that was the highest virtual/jdk matched
14 by the >=virtual/jdk-1.5 atom. This patch removes the >=virtual/jdk-1.5
15 atom from the _expand_new_virtuals output, in order to avoid triggering
16 the erroneous dep_zapdeps behavior. The >=virtual/jdk-1.5 atom is not
17 completely discarded, since the depgraph is able to access it via the
18 virt_atom._orig_atom attribute.
19
20 In order to demonstrate that this patch solves the problem, run the
21 command `emerge ant-core` from inside a stage3 chroot, and see that
22 virtual/jdk:1.8 is favored over virtual/jdk:1.7.
23
24 X-Gentoo-Bug: 597752
25 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=597752
26 ---
27 pym/_emerge/depgraph.py | 6 +++++-
28 pym/portage/dep/dep_check.py | 13 +++++++------
29 2 files changed, 12 insertions(+), 7 deletions(-)
30
31 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
32 index 26037ad..9161914 100644
33 --- a/pym/_emerge/depgraph.py
34 +++ b/pym/_emerge/depgraph.py
35 @@ -4453,7 +4453,11 @@ class depgraph(object):
36 # _UNREACHABLE_DEPTH for complete mode.
37 virt_depth = parent.depth
38
39 - chosen_atom_ids = frozenset(id(atom) for atom in mycheck[1])
40 + chosen_atom_ids = frozenset(chain(
41 + (id(atom) for atom in mycheck[1]),
42 + (id(atom._orig_atom) for atom in mycheck[1]
43 + if hasattr(atom, '_orig_atom')),
44 + ))
45 selected_atoms = OrderedDict()
46 node_stack = [(parent, None, None)]
47 traversed_nodes = set()
48 diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
49 index 9af4e65..9d2ca4b 100644
50 --- a/pym/portage/dep/dep_check.py
51 +++ b/pym/portage/dep/dep_check.py
52 @@ -188,13 +188,14 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
53 raise ParseError("%s: %s '%s'" % \
54 (pkg, mycheck[1], depstring))
55
56 - # Pull in virt_atom which refers to the specific version
57 - # of the virtual whose deps we're expanding. Also pull
58 - # in the original input atom, so that callers can reliably
59 - # check to see if a given input atom has been selected,
60 - # as in depgraph._slot_operator_update_probe.
61 + # Replace the original atom "x" with "virt_atom" which refers
62 + # to the specific version of the virtual whose deps we're
63 + # expanding. The virt_atom._orig_atom attribute is used
64 + # by depgraph to map virt_atom back to the original atom.
65 + # We specifically exclude the original atom "x" from the
66 + # the expanded output here, since otherwise it could trigger
67 + # incorrect dep_zapdeps behavior (see bug #597752).
68 mycheck[1].append(virt_atom)
69 - mycheck[1].append(x)
70 a.append(mycheck[1])
71 if atom_graph is not None:
72 virt_atom_node = (virt_atom, id(virt_atom))
73 --
74 2.7.4

Replies