Gentoo Archives: gentoo-commits

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