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: avoid use.mask/force changes (515584)
Date: Wed, 12 Nov 2014 01:55:51
Message-Id: 1415757335-17025-1-git-send-email-zmedico@gentoo.org
1 This patch causes dep_zapdeps to check which USE flags cause a match
2 to fail, and uses that information to prioritize choices that do not
3 require changes to use.mask or use.force.
4
5 X-Gentoo-Bug: 515584
6 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=515584
7 ---
8 pym/portage/dep/dep_check.py | 36 ++++++++++++++++-
9 pym/portage/tests/resolver/test_or_choices.py | 58 ++++++++++++++++++++++++++-
10 2 files changed, 91 insertions(+), 3 deletions(-)
11
12 diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
13 index 62f42ac..ccdda59 100644
14 --- a/pym/portage/dep/dep_check.py
15 +++ b/pym/portage/dep/dep_check.py
16 @@ -317,6 +317,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
17 priority = trees[myroot].get("priority")
18 graph_db = trees[myroot].get("graph_db")
19 graph = trees[myroot].get("graph")
20 + pkg_use_enabled = trees[myroot].get("pkg_use_enabled")
21 want_update_pkg = trees[myroot].get("want_update_pkg")
22 vardb = None
23 if "vartree" in trees[myroot]:
24 @@ -349,6 +350,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
25
26 all_available = True
27 all_use_satisfied = True
28 + all_use_unmasked = True
29 slot_map = {}
30 cp_map = {}
31 for atom in atoms:
32 @@ -369,6 +371,32 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
33 avail_pkg_use = mydbapi_match_pkgs(atom)
34 if not avail_pkg_use:
35 all_use_satisfied = False
36 +
37 + if pkg_use_enabled is not None:
38 + # Check which USE flags cause the match to fail,
39 + # so we can prioritize choices that do not
40 + # require changes to use.mask or use.force
41 + # (see bug #515584).
42 + violated_atom = atom.violated_conditionals(
43 + pkg_use_enabled(avail_pkg),
44 + avail_pkg.iuse.is_valid_flag)
45 +
46 + # Note that violated_atom.use can be None here,
47 + # since evaluation can collapse conditional USE
48 + # deps that cause the match to fail due to
49 + # missing IUSE (match uses atom.unevaluated_atom
50 + # to detect such missing IUSE).
51 + if violated_atom.use is not None:
52 + for flag in violated_atom.use.enabled:
53 + if flag in avail_pkg.use.mask:
54 + all_use_unmasked = False
55 + break
56 + else:
57 + for flag in violated_atom.use.disabled:
58 + if flag in avail_pkg.use.force and \
59 + flag not in avail_pkg.use.mask:
60 + all_use_unmasked = False
61 + break
62 else:
63 # highest (ascending order)
64 avail_pkg_use = avail_pkg_use[-1]
65 @@ -416,7 +444,9 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
66 else:
67 preferred_non_installed.append(this_choice)
68 else:
69 - if all_installed_slots:
70 + if not all_use_unmasked:
71 + other.append(this_choice)
72 + elif all_installed_slots:
73 unsat_use_installed.append(this_choice)
74 else:
75 unsat_use_non_installed.append(this_choice)
76 @@ -490,7 +520,9 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
77 else:
78 preferred_non_installed.append(this_choice)
79 else:
80 - if all_in_graph:
81 + if not all_use_unmasked:
82 + other.append(this_choice)
83 + elif all_in_graph:
84 unsat_use_in_graph.append(this_choice)
85 elif all_installed_slots:
86 unsat_use_installed.append(this_choice)
87 diff --git a/pym/portage/tests/resolver/test_or_choices.py b/pym/portage/tests/resolver/test_or_choices.py
88 index d9d14f0..bdf1f5c 100644
89 --- a/pym/portage/tests/resolver/test_or_choices.py
90 +++ b/pym/portage/tests/resolver/test_or_choices.py
91 @@ -1,4 +1,4 @@
92 -# Copyright 2013 Gentoo Foundation
93 +# Copyright 2013-2014 Gentoo Foundation
94 # Distributed under the terms of the GNU General Public License v2
95
96 from portage.tests import TestCase
97 @@ -205,3 +205,59 @@ class OrChoicesTestCase(TestCase):
98 self.assertEqual(test_case.test_success, True, test_case.fail_msg)
99 finally:
100 playground.cleanup()
101 +
102 +
103 + def testUseMask(self):
104 +
105 + profile = {
106 + "use.mask":
107 + (
108 + "abi_ppc_32",
109 + ),
110 + }
111 +
112 + ebuilds = {
113 +
114 + "sys-libs/A-1" : {
115 + "EAPI": "5",
116 + "RDEPEND": "|| ( sys-libs/zlib[abi_ppc_32(-)] " + \
117 + "sys-libs/zlib[abi_x86_32(-)] )"
118 + },
119 +
120 + "sys-libs/zlib-1.2.8-r1" : {
121 + "EAPI": "5",
122 + "IUSE": "abi_ppc_32 abi_x86_32"
123 + },
124 +
125 + "sys-libs/zlib-1.2.8" : {
126 + "EAPI": "5",
127 + "IUSE": ""
128 + },
129 + }
130 +
131 + test_cases = (
132 +
133 + # bug #515584: We want to prefer choices that do
134 + # not require changes to use.mask or use.force.
135 + # In this case, abi_ppc_32 is use.masked in the
136 + # profile, so we want to avoid that choice.
137 + ResolverPlaygroundTestCase(
138 + ["sys-libs/A"],
139 + options = {},
140 + success = False,
141 + use_changes = {
142 + 'sys-libs/zlib-1.2.8-r1': {'abi_x86_32': True}
143 + },
144 + mergelist = ["sys-libs/zlib-1.2.8-r1", "sys-libs/A-1"]
145 + ),
146 +
147 + )
148 +
149 + playground = ResolverPlayground(ebuilds=ebuilds,
150 + profile=profile, debug=False)
151 + try:
152 + for test_case in test_cases:
153 + playground.run_TestCase(test_case)
154 + self.assertEqual(test_case.test_success, True, test_case.fail_msg)
155 + finally:
156 + playground.cleanup()
157 --
158 2.0.4

Replies