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] depgraph: autounmask for conditional USE deps (bug 566704)
Date: Tue, 24 Nov 2015 09:31:39
Message-Id: 1448357421-10646-1-git-send-email-zmedico@gentoo.org
1 For parents with unsatisfied conditional dependencies, translate
2 USE change suggestions into autounmask changes.
3
4 X-Gentoo-Bug: 566704
5 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=566704
6 ---
7 pym/_emerge/depgraph.py | 36 +++++++++++++++++++-
8 .../tests/resolver/test_autounmask_parent.py | 38 ++++++++++++++++++++++
9 2 files changed, 73 insertions(+), 1 deletion(-)
10 create mode 100644 pym/portage/tests/resolver/test_autounmask_parent.py
11
12 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
13 index 57040ab..0fba4c9 100644
14 --- a/pym/_emerge/depgraph.py
15 +++ b/pym/_emerge/depgraph.py
16 @@ -4075,6 +4075,7 @@ class depgraph(object):
17 # Now that the root packages have been added to the graph,
18 # process the dependencies.
19 if not self._create_graph():
20 + self._apply_parent_use_changes()
21 return 0, myfavorites
22
23 try:
24 @@ -4162,6 +4163,24 @@ class depgraph(object):
25 # We're true here unless we are missing binaries.
26 return (True, myfavorites)
27
28 + def _apply_parent_use_changes(self):
29 + """
30 + For parents with unsatisfied conditional dependencies, translate
31 + USE change suggestions into autounmask changes.
32 + """
33 + if (self._dynamic_config._unsatisfied_deps_for_display and
34 + self._dynamic_config._autounmask):
35 + remaining_items = []
36 + for item in self._dynamic_config._unsatisfied_deps_for_display:
37 + pargs, kwargs = item
38 + kwargs = kwargs.copy()
39 + kwargs['collect_use_changes'] = True
40 + if not self._show_unsatisfied_dep(*pargs,
41 + **portage._native_kwargs(kwargs)):
42 + remaining_items.append(item)
43 + if len(remaining_items) != len(self._dynamic_config._unsatisfied_deps_for_display):
44 + self._dynamic_config._unsatisfied_deps_for_display = remaining_items
45 +
46 def _set_args(self, args):
47 """
48 Create the "__non_set_args__" package set from atoms and packages given as
49 @@ -4718,7 +4737,8 @@ class depgraph(object):
50
51
52 def _show_unsatisfied_dep(self, root, atom, myparent=None, arg=None,
53 - check_backtrack=False, check_autounmask_breakage=False, show_req_use=None):
54 + check_backtrack=False, check_autounmask_breakage=False, show_req_use=None,
55 + collect_use_changes=False):
56 """
57 When check_backtrack=True, no output is produced and
58 the method either returns or raises _backtrack_mask if
59 @@ -4867,6 +4887,7 @@ class depgraph(object):
60 else:
61 return
62
63 + found_use_changes = False
64 missing_use_reasons = []
65 missing_iuse_reasons = []
66 for pkg in missing_use:
67 @@ -4962,15 +4983,28 @@ class depgraph(object):
68 "defined by %s: '%s'" % (myparent.cpv, \
69 human_readable_required_use(required_use))
70
71 + target_use = {}
72 for flag in involved_flags:
73 if flag in self._pkg_use_enabled(myparent):
74 + target_use[flag] = False
75 changes.append(colorize("blue", "-" + flag))
76 else:
77 + target_use[flag] = True
78 changes.append(colorize("red", "+" + flag))
79 +
80 + if collect_use_changes and not required_use_warning:
81 + previous_changes = self._dynamic_config._needed_use_config_changes.get(myparent)
82 + self._pkg_use_enabled(myparent, target_use=target_use)
83 + if previous_changes is not self._dynamic_config._needed_use_config_changes.get(myparent):
84 + return True
85 +
86 mreasons.append("Change USE: %s" % " ".join(changes) + required_use_warning)
87 if (myparent, mreasons) not in missing_use_reasons:
88 missing_use_reasons.append((myparent, mreasons))
89
90 + if collect_use_changes:
91 + return False
92 +
93 unmasked_use_reasons = [(pkg, mreasons) for (pkg, mreasons) \
94 in missing_use_reasons if pkg not in masked_pkg_instances]
95
96 diff --git a/pym/portage/tests/resolver/test_autounmask_parent.py b/pym/portage/tests/resolver/test_autounmask_parent.py
97 new file mode 100644
98 index 0000000..50dff18
99 --- /dev/null
100 +++ b/pym/portage/tests/resolver/test_autounmask_parent.py
101 @@ -0,0 +1,38 @@
102 +# Copyright 2015 Gentoo Foundation
103 +# Distributed under the terms of the GNU General Public License v2
104 +
105 +from portage.tests import TestCase
106 +from portage.tests.resolver.ResolverPlayground import (
107 + ResolverPlayground,
108 + ResolverPlaygroundTestCase,
109 +)
110 +
111 +class AutounmaskParentTestCase(TestCase):
112 +
113 + def testAutounmaskParentUse(self):
114 +
115 + ebuilds = {
116 + "dev-libs/B-1": {
117 + "EAPI": "5",
118 + "DEPEND": "dev-libs/D[foo(-)?]",
119 + "IUSE": "+foo",
120 + },
121 + "dev-libs/D-1": {},
122 + }
123 +
124 + test_cases = (
125 + # Test bug 566704
126 + ResolverPlaygroundTestCase(
127 + ["=dev-libs/B-1"],
128 + options={"--autounmask": True},
129 + success=False,
130 + use_changes={ "dev-libs/B-1": { "foo": False } }),
131 + )
132 +
133 + playground = ResolverPlayground(ebuilds=ebuilds)
134 + try:
135 + for test_case in test_cases:
136 + playground.run_TestCase(test_case)
137 + self.assertEqual(test_case.test_success, True, test_case.fail_msg)
138 + finally:
139 + playground.cleanup()
140 --
141 2.4.10

Replies