1 |
Fix the --use-ebuild-visibility option to reject binary packages for |
2 |
which ebuilds are either masked or unavailable. The included test case |
3 |
fails with out this fix. |
4 |
|
5 |
X-Gentoo-bug: 612960 |
6 |
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=612960 |
7 |
--- |
8 |
pym/_emerge/depgraph.py | 32 +++++++- |
9 |
.../resolver/test_binary_pkg_ebuild_visibility.py | 94 ++++++++++++++++++++++ |
10 |
2 files changed, 123 insertions(+), 3 deletions(-) |
11 |
create mode 100644 pym/portage/tests/resolver/test_binary_pkg_ebuild_visibility.py |
12 |
|
13 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
14 |
index e94b96c..3834983 100644 |
15 |
--- a/pym/_emerge/depgraph.py |
16 |
+++ b/pym/_emerge/depgraph.py |
17 |
@@ -4889,6 +4889,9 @@ class depgraph(object): |
18 |
vardb = self._frozen_config.roots[root].trees["vartree"].dbapi |
19 |
bindb = self._frozen_config.roots[root].trees["bintree"].dbapi |
20 |
dbs = self._dynamic_config._filtered_trees[root]["dbs"] |
21 |
+ use_ebuild_visibility = self._frozen_config.myopts.get( |
22 |
+ '--use-ebuild-visibility', 'n') != 'n' |
23 |
+ |
24 |
for db, pkg_type, built, installed, db_keys in dbs: |
25 |
if installed: |
26 |
continue |
27 |
@@ -4975,6 +4978,7 @@ class depgraph(object): |
28 |
eapi=pkg.eapi): |
29 |
required_use_unsatisfied.append(pkg) |
30 |
continue |
31 |
+ |
32 |
root_slot = (pkg.root, pkg.slot_atom) |
33 |
if pkg.built and root_slot in self._rebuild.rebuild_list: |
34 |
mreasons = ["need to rebuild from source"] |
35 |
@@ -4988,6 +4992,19 @@ class depgraph(object): |
36 |
self._dynamic_config.ignored_binaries.get( |
37 |
pkg, {}).get("changed_deps")): |
38 |
mreasons = ["changed deps"] |
39 |
+ elif (pkg.built and use_ebuild_visibility and |
40 |
+ not self._equiv_ebuild_visible(pkg)): |
41 |
+ equiv_ebuild = self._equiv_ebuild(pkg) |
42 |
+ if equiv_ebuild is None: |
43 |
+ mreasons = ["ebuild not unavailable"] |
44 |
+ elif not mreasons: |
45 |
+ metadata, mreasons = get_mask_info( |
46 |
+ root_config, equiv_ebuild.cpv, pkgsettings, |
47 |
+ portdb, equiv_ebuild.pkg_type, |
48 |
+ equiv_ebuild.built, equiv_ebuild.installed, |
49 |
+ db_keys, myrepo=equiv_ebuild.repo, |
50 |
+ _pkg_use_enabled=self._pkg_use_enabled) |
51 |
+ |
52 |
masked_packages.append( |
53 |
(root_config, pkgsettings, cpv, repo, metadata, mreasons)) |
54 |
|
55 |
@@ -5548,6 +5565,14 @@ class depgraph(object): |
56 |
""" |
57 |
return depth + n if isinstance(depth, int) else depth |
58 |
|
59 |
+ def _equiv_ebuild(self, pkg): |
60 |
+ try: |
61 |
+ return self._pkg( |
62 |
+ pkg.cpv, "ebuild", pkg.root_config, myrepo=pkg.repo) |
63 |
+ except portage.exception.PackageNotFound: |
64 |
+ return next(self._iter_match_pkgs(pkg.root_config, |
65 |
+ "ebuild", Atom("=%s" % (pkg.cpv,))), None) |
66 |
+ |
67 |
def _equiv_ebuild_visible(self, pkg, autounmask_level=None): |
68 |
try: |
69 |
pkg_eb = self._pkg( |
70 |
@@ -6021,11 +6046,11 @@ class depgraph(object): |
71 |
# reinstall the same exact version only due |
72 |
# to a KEYWORDS mask. See bug #252167. |
73 |
|
74 |
+ identical_binary = False |
75 |
if pkg.type_name != "ebuild" and matched_packages: |
76 |
# Don't re-install a binary package that is |
77 |
# identical to the currently installed package |
78 |
# (see bug #354441). |
79 |
- identical_binary = False |
80 |
if usepkg and pkg.installed: |
81 |
for selected_pkg in matched_packages: |
82 |
if selected_pkg.type_name == "binary" and \ |
83 |
@@ -6035,12 +6060,13 @@ class depgraph(object): |
84 |
identical_binary = True |
85 |
break |
86 |
|
87 |
- if not identical_binary: |
88 |
+ if not identical_binary: |
89 |
# If the ebuild no longer exists or it's |
90 |
# keywords have been dropped, reject built |
91 |
# instances (installed or binary). |
92 |
# If --usepkgonly is enabled, assume that |
93 |
- # the ebuild status should be ignored. |
94 |
+ # the ebuild status should be ignored unless |
95 |
+ # --use-ebuild-visibility has been specified. |
96 |
if not use_ebuild_visibility and (usepkgonly or useoldpkg): |
97 |
if pkg.installed and pkg.masks: |
98 |
continue |
99 |
diff --git a/pym/portage/tests/resolver/test_binary_pkg_ebuild_visibility.py b/pym/portage/tests/resolver/test_binary_pkg_ebuild_visibility.py |
100 |
new file mode 100644 |
101 |
index 0000000..0d0a8c7 |
102 |
--- /dev/null |
103 |
+++ b/pym/portage/tests/resolver/test_binary_pkg_ebuild_visibility.py |
104 |
@@ -0,0 +1,94 @@ |
105 |
+# Copyright 2017 Gentoo Foundation |
106 |
+# Distributed under the terms of the GNU General Public License v2 |
107 |
+ |
108 |
+from portage.tests import TestCase |
109 |
+from portage.tests.resolver.ResolverPlayground import ( |
110 |
+ ResolverPlayground, |
111 |
+ ResolverPlaygroundTestCase, |
112 |
+) |
113 |
+ |
114 |
+class BinaryPkgEbuildVisibilityTestCase(TestCase): |
115 |
+ |
116 |
+ def testBinaryPkgEbuildVisibility(self): |
117 |
+ |
118 |
+ binpkgs = { |
119 |
+ "app-misc/foo-3" : {}, |
120 |
+ "app-misc/foo-2" : {}, |
121 |
+ "app-misc/foo-1" : {}, |
122 |
+ } |
123 |
+ |
124 |
+ ebuilds = { |
125 |
+ "app-misc/foo-2" : {}, |
126 |
+ "app-misc/foo-1" : {}, |
127 |
+ } |
128 |
+ |
129 |
+ installed = { |
130 |
+ "app-misc/foo-1" : {}, |
131 |
+ } |
132 |
+ |
133 |
+ world = ["app-misc/foo"] |
134 |
+ |
135 |
+ test_cases = ( |
136 |
+ |
137 |
+ # Test bug #612960, where --use-ebuild-visibility failed |
138 |
+ # to reject binary packages for which ebuilds were not |
139 |
+ # available. |
140 |
+ ResolverPlaygroundTestCase( |
141 |
+ ["@world"], |
142 |
+ options = { |
143 |
+ "--update": True, |
144 |
+ "--deep": True, |
145 |
+ "--use-ebuild-visibility": 'y', |
146 |
+ "--usepkg": True, |
147 |
+ }, |
148 |
+ success = True, |
149 |
+ mergelist = [ |
150 |
+ '[binary]app-misc/foo-2', |
151 |
+ ], |
152 |
+ ), |
153 |
+ |
154 |
+ ResolverPlaygroundTestCase( |
155 |
+ ["@world"], |
156 |
+ options = { |
157 |
+ "--update": True, |
158 |
+ "--deep": True, |
159 |
+ "--use-ebuild-visibility": 'y', |
160 |
+ "--usepkgonly": True, |
161 |
+ }, |
162 |
+ success = True, |
163 |
+ mergelist = [ |
164 |
+ '[binary]app-misc/foo-2', |
165 |
+ ], |
166 |
+ ), |
167 |
+ |
168 |
+ ResolverPlaygroundTestCase( |
169 |
+ ["=app-misc/foo-3"], |
170 |
+ options = { |
171 |
+ "--use-ebuild-visibility": 'y', |
172 |
+ "--usepkgonly": True, |
173 |
+ }, |
174 |
+ success = False, |
175 |
+ ), |
176 |
+ |
177 |
+ ResolverPlaygroundTestCase( |
178 |
+ ["app-misc/foo"], |
179 |
+ options = { |
180 |
+ "--usepkgonly": True, |
181 |
+ }, |
182 |
+ success = True, |
183 |
+ mergelist = [ |
184 |
+ '[binary]app-misc/foo-3', |
185 |
+ ], |
186 |
+ ), |
187 |
+ ) |
188 |
+ |
189 |
+ playground = ResolverPlayground(binpkgs=binpkgs, ebuilds=ebuilds, |
190 |
+ installed=installed, world=world) |
191 |
+ try: |
192 |
+ for test_case in test_cases: |
193 |
+ playground.run_TestCase(test_case) |
194 |
+ self.assertEqual(test_case.test_success, True, |
195 |
+ test_case.fail_msg) |
196 |
+ finally: |
197 |
+ playground.cleanup() |
198 |
+ |
199 |
-- |
200 |
2.10.2 |