1 |
Author: grobian |
2 |
Date: 2008-04-01 18:27:32 +0000 (Tue, 01 Apr 2008) |
3 |
New Revision: 9668 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/pym/_emerge/__init__.py |
7 |
main/branches/prefix/pym/portage/__init__.py |
8 |
main/branches/prefix/pym/portage/dbapi/bintree.py |
9 |
Log: |
10 |
Merged from trunk 9637:9665 |
11 |
|
12 |
| 9643 | Pass Package instances into visible() so that the package | |
13 |
| zmedico | instance can be used to cache relevant visibility | |
14 |
| | information such as whether or not the package is corrupt or | |
15 |
| | otherwise invalid. | |
16 |
|
17 |
| 9644 | Replace an package tuple with a real Package instance. | |
18 |
| zmedico | | |
19 |
|
20 |
| 9645 | Make depgraph creation more tolerant of missing or masked | |
21 |
| zmedico | packages when the relevant deps are satisfied by installed | |
22 |
| | packages. This kind of friendliness is especially desired in | |
23 |
| | cases such as --emptytree where it might not be possible to | |
24 |
| | reinstall every single package. Also, it allows multislot | |
25 |
| | atoms from the world file (that are necessary to prevent | |
26 |
| | them from being removed by depclean) trigger warning | |
27 |
| | messages while still allowing a --emptytree to proceed. | |
28 |
|
29 |
| 9646 | Bug #197810 - Fix package selection logic so that it will | |
30 |
| zmedico | always fall back to an installed package when necessary. | |
31 |
|
32 |
| 9648 | When selecting packages and there is a mixture of old-style | |
33 |
| zmedico | and new-style virtual matches, filter out the old-style | |
34 |
| | virtual matches. | |
35 |
|
36 |
| 9650 | Remove some redundant and obsolete code for warning about | |
37 |
| zmedico | installed packages pulled into the graph. | |
38 |
|
39 |
| 9652 | Fix package selection logic to always properly reject the | |
40 |
| zmedico | installed package when another is available and the user | |
41 |
| | wants to reinstall. | |
42 |
|
43 |
| 9654 | In the package selection loop, move the installed package | |
44 |
| zmedico | rejection code as early as possible. | |
45 |
|
46 |
| 9656 | When deps are forced to be satisfied by installed packages | |
47 |
| zmedico | due to masking or unavailability, only tolerate it when the | |
48 |
| | atom comes from either the system or world set since | |
49 |
| | otherwise it's a good idea to bail so that the user can | |
50 |
| | correct the problem. | |
51 |
|
52 |
| 9658 | Bug #215308 - Cache the paths of known bad manifests to | |
53 |
| zmedico | ensure that the same broken manifest is never checked twice. | |
54 |
|
55 |
| 9660 | When identifying a sys-apps/portage node, compare category | |
56 |
| zmedico | too (not just "portage". | |
57 |
|
58 |
| 9662 | Handle missing LICENSE in the Packages index since that's | |
59 |
| zmedico | allowed for virtual packages. | |
60 |
|
61 |
| 9665 | Exploid ascending order returned from dbapi.match() calls to | |
62 |
| zmedico | avoid the need to call best(). | |
63 |
|
64 |
|
65 |
Modified: main/branches/prefix/pym/_emerge/__init__.py |
66 |
=================================================================== |
67 |
--- main/branches/prefix/pym/_emerge/__init__.py 2008-04-01 18:22:48 UTC (rev 9667) |
68 |
+++ main/branches/prefix/pym/_emerge/__init__.py 2008-04-01 18:27:32 UTC (rev 9668) |
69 |
@@ -481,8 +481,14 @@ |
70 |
def _visible(self, db, cpv, metadata): |
71 |
installed = db is self.vartree.dbapi |
72 |
built = installed or db is not self._portdb |
73 |
- return visible(self.settings, cpv, metadata, |
74 |
- built=built, installed=installed) |
75 |
+ pkg_type = "ebuild" |
76 |
+ if installed: |
77 |
+ pkg_type = "installed" |
78 |
+ elif built: |
79 |
+ pkg_type = "binary" |
80 |
+ return visible(self.settings, |
81 |
+ Package(type_name=pkg_type, root=self.settings["ROOT"], |
82 |
+ cpv=cpv, built=built, installed=installed, metadata=metadata)) |
83 |
|
84 |
def _xmatch(self, level, atom): |
85 |
""" |
86 |
@@ -1061,7 +1067,7 @@ |
87 |
if updates: |
88 |
mydb.aux_update(mycpv, updates) |
89 |
|
90 |
-def visible(pkgsettings, cpv, metadata, built=False, installed=False): |
91 |
+def visible(pkgsettings, pkg): |
92 |
""" |
93 |
Check if a package is visible. This can raise an InvalidDependString |
94 |
exception if LICENSE is invalid. |
95 |
@@ -1069,26 +1075,30 @@ |
96 |
@rtype: Boolean |
97 |
@returns: True if the package is visible, False otherwise. |
98 |
""" |
99 |
- if not metadata["SLOT"]: |
100 |
+ if not pkg.metadata["SLOT"]: |
101 |
return False |
102 |
- if built and not installed and \ |
103 |
- metadata["CHOST"] != pkgsettings["CHOST"]: |
104 |
+ if pkg.built and not pkg.installed and \ |
105 |
+ pkg.metadata["CHOST"] != pkgsettings["CHOST"]: |
106 |
return False |
107 |
if built and not installed: |
108 |
# we can have an old binary which has no EPREFIX information |
109 |
- if "EPREFIX" not in metadata or not metadata["EPREFIX"]: |
110 |
+ if "EPREFIX" not in pkg.metadata or not pkg.metadata["EPREFIX"]: |
111 |
return False |
112 |
- if len(metadata["EPREFIX"].strip()) < len(pkgsettings["EPREFIX"]): |
113 |
+ if len(pkg.metadata["EPREFIX"].strip()) < len(pkgsettings["EPREFIX"]): |
114 |
return False |
115 |
- if not portage.eapi_is_supported(metadata["EAPI"]): |
116 |
+ if not portage.eapi_is_supported(pkg.metadata["EAPI"]): |
117 |
return False |
118 |
- if not installed and pkgsettings.getMissingKeywords(cpv, metadata): |
119 |
+ if not pkg.installed and \ |
120 |
+ pkgsettings.getMissingKeywords(pkg.cpv, pkg.metadata): |
121 |
return False |
122 |
- if pkgsettings.getMaskAtom(cpv, metadata): |
123 |
+ if pkgsettings.getMaskAtom(pkg.cpv, pkg.metadata): |
124 |
return False |
125 |
- if pkgsettings.getProfileMaskAtom(cpv, metadata): |
126 |
+ if pkgsettings.getProfileMaskAtom(pkg.cpv, pkg.metadata): |
127 |
return False |
128 |
- if pkgsettings.getMissingLicenses(cpv, metadata): |
129 |
+ try: |
130 |
+ if pkgsettings.getMissingLicenses(pkg.cpv, pkg.metadata): |
131 |
+ return False |
132 |
+ except portage.exception.InvalidDependString: |
133 |
return False |
134 |
return True |
135 |
|
136 |
@@ -1201,7 +1211,7 @@ |
137 |
class Package(object): |
138 |
__slots__ = ("__weakref__", "built", "cpv", "depth", |
139 |
"installed", "metadata", "root", "onlydeps", "type_name", |
140 |
- "cpv_slot", "slot_atom", "_digraph_node") |
141 |
+ "cp", "cpv_slot", "slot_atom", "_digraph_node") |
142 |
def __init__(self, **kwargs): |
143 |
for myattr in self.__slots__: |
144 |
if myattr == "__weakref__": |
145 |
@@ -1209,9 +1219,8 @@ |
146 |
myvalue = kwargs.get(myattr, None) |
147 |
setattr(self, myattr, myvalue) |
148 |
|
149 |
- self.slot_atom = "%s:%s" % \ |
150 |
- (portage.cpv_getkey(self.cpv), self.metadata["SLOT"]) |
151 |
- |
152 |
+ self.cp = portage.cpv_getkey(self.cpv) |
153 |
+ self.slot_atom = "%s:%s" % (self.cp, self.metadata["SLOT"]) |
154 |
self.cpv_slot = "%s:%s" % (self.cpv, self.metadata["SLOT"]) |
155 |
|
156 |
status = "merge" |
157 |
@@ -1839,30 +1848,9 @@ |
158 |
return 0 |
159 |
|
160 |
if pkg.installed: |
161 |
- # Warn if all matching ebuilds are masked or |
162 |
- # the installed package itself is masked. Do |
163 |
- # not warn if there are simply no matching |
164 |
- # ebuilds since that would be annoying in some |
165 |
- # cases: |
166 |
- # |
167 |
- # - binary packages installed from an overlay |
168 |
- # that is not listed in PORTDIR_OVERLAY |
169 |
- # |
170 |
- # - multi-slot atoms listed in the world file |
171 |
- # to prevent depclean from removing them |
172 |
- |
173 |
- if arg_atoms: |
174 |
- selective = "selective" in self.myparams |
175 |
- portdb = self.trees[pkg.root]["porttree"].dbapi |
176 |
- for arg, atom in arg_atoms: |
177 |
- all_ebuilds_masked = bool( |
178 |
- portdb.xmatch("match-all", atom) and |
179 |
- not portdb.xmatch("bestmatch-visible", atom)) |
180 |
- if all_ebuilds_masked and not selective: |
181 |
- self._missing_args.append((arg, atom)) |
182 |
- |
183 |
- if not visible(pkgsettings, pkg.cpv, pkg.metadata, |
184 |
- built=pkg.built, installed=pkg.installed): |
185 |
+ # Warn if an installed package is masked and it |
186 |
+ # is pulled into the graph. |
187 |
+ if not visible(pkgsettings, pkg): |
188 |
self._masked_installed.append((pkg, pkgsettings)) |
189 |
|
190 |
if args: |
191 |
@@ -2305,7 +2293,15 @@ |
192 |
if pkg.installed and "selective" not in self.myparams: |
193 |
self._unsatisfied_deps_for_display.append( |
194 |
((myroot, atom), {})) |
195 |
- return 0, myfavorites |
196 |
+ # Previous behavior was to bail out in this case, but |
197 |
+ # since the dep is satisfied by the installed package, |
198 |
+ # it's more friendly to continue building the graph |
199 |
+ # and just show a warning message. Therefore, only bail |
200 |
+ # out here if the atom is not from either the system or |
201 |
+ # world set. |
202 |
+ if not (isinstance(arg, SetArg) and \ |
203 |
+ arg.name in ("system", "world")): |
204 |
+ return 0, myfavorites |
205 |
|
206 |
self._dep_stack.append( |
207 |
Dependency(atom=atom, onlydeps=onlydeps, root=myroot, parent=arg)) |
208 |
@@ -2443,12 +2439,9 @@ |
209 |
else: |
210 |
metadata["USE"] = "" |
211 |
|
212 |
- try: |
213 |
- if not visible(pkgsettings, cpv, metadata, |
214 |
- built=built, installed=installed): |
215 |
- continue |
216 |
- except portage.exception.InvalidDependString: |
217 |
- # masked by corruption |
218 |
+ if not visible(pkgsettings, Package(built=built, |
219 |
+ cpv=cpv, root=myroot, type_name=pkg_type, |
220 |
+ installed=installed, metadata=metadata)): |
221 |
continue |
222 |
|
223 |
filtered_db.cpv_inject(cpv, metadata=metadata) |
224 |
@@ -2591,7 +2584,6 @@ |
225 |
empty = "empty" in self.myparams |
226 |
selective = "selective" in self.myparams |
227 |
noreplace = "--noreplace" in self.myopts |
228 |
- reinstall = False |
229 |
# Behavior of the "selective" parameter depends on |
230 |
# whether or not a package matches an argument atom. |
231 |
# If an installed package provides an old-style |
232 |
@@ -2610,14 +2602,11 @@ |
233 |
for db, pkg_type, built, installed, db_keys in dbs: |
234 |
if existing_node: |
235 |
break |
236 |
- if installed and not find_existing_node and \ |
237 |
- (reinstall or not selective) and \ |
238 |
- (matched_packages or empty): |
239 |
- # We only need to select an installed package in the |
240 |
- # following cases: |
241 |
- # 1) there is no other choice |
242 |
- # 2) selective is True |
243 |
- continue |
244 |
+ if installed and not find_existing_node: |
245 |
+ want_reinstall = empty or \ |
246 |
+ (found_available_arg and not selective) |
247 |
+ if want_reinstall and matched_packages: |
248 |
+ continue |
249 |
if hasattr(db, "xmatch"): |
250 |
cpv_list = db.xmatch("match-all", atom) |
251 |
else: |
252 |
@@ -2656,12 +2645,9 @@ |
253 |
if not installed: |
254 |
if myarg: |
255 |
found_available_arg = True |
256 |
- try: |
257 |
- if not visible(pkgsettings, cpv, metadata, |
258 |
- built=built, installed=installed): |
259 |
- continue |
260 |
- except portage.exception.InvalidDependString: |
261 |
- # masked by corruption |
262 |
+ if not visible(pkgsettings, Package(built=built, |
263 |
+ cpv=cpv, installed=installed, metadata=metadata, |
264 |
+ type_name=pkg_type)): |
265 |
continue |
266 |
# At this point, we've found the highest visible |
267 |
# match from the current repo. Any lower versions |
268 |
@@ -2713,7 +2699,7 @@ |
269 |
if not installed and \ |
270 |
("--newuse" in self.myopts or \ |
271 |
"--reinstall" in self.myopts) and \ |
272 |
- vardb.cpv_exists(cpv): |
273 |
+ cpv in vardb.match(atom): |
274 |
pkgsettings.setcpv(cpv, mydb=metadata) |
275 |
forced_flags = set() |
276 |
forced_flags.update(pkgsettings.useforce) |
277 |
@@ -2728,8 +2714,6 @@ |
278 |
self._reinstall_for_flags( |
279 |
forced_flags, old_use, old_iuse, |
280 |
cur_use, cur_iuse) |
281 |
- if reinstall_for_flags: |
282 |
- reinstall = True |
283 |
if not installed: |
284 |
must_reinstall = empty or \ |
285 |
(myarg and not selective) |
286 |
@@ -2737,11 +2721,6 @@ |
287 |
not must_reinstall and \ |
288 |
cpv in vardb.match(atom): |
289 |
break |
290 |
- if installed: |
291 |
- must_reinstall = empty or \ |
292 |
- (found_available_arg and not selective) |
293 |
- if must_reinstall: |
294 |
- break |
295 |
# Metadata accessed above is cached internally by |
296 |
# each db in order to optimize visibility checks. |
297 |
# Now that all possible checks visibility checks |
298 |
@@ -2754,14 +2733,13 @@ |
299 |
pkgsettings.setcpv(cpv, mydb=metadata) |
300 |
metadata["USE"] = pkgsettings["PORTAGE_USE"] |
301 |
myeb = cpv |
302 |
- matched_packages.append( |
303 |
- Package(type_name=pkg_type, root=root, |
304 |
- cpv=cpv, metadata=metadata, |
305 |
- built=built, installed=installed, |
306 |
- onlydeps=onlydeps)) |
307 |
+ pkg = Package(type_name=pkg_type, root=root, |
308 |
+ cpv=cpv, metadata=metadata, |
309 |
+ built=built, installed=installed, |
310 |
+ onlydeps=onlydeps) |
311 |
+ matched_packages.append(pkg) |
312 |
if reinstall_for_flags: |
313 |
- pkg_node = (pkg_type, root, cpv, "merge") |
314 |
- self._reinstall_nodes[pkg_node] = \ |
315 |
+ self._reinstall_nodes[pkg] = \ |
316 |
reinstall_for_flags |
317 |
break |
318 |
|
319 |
@@ -2772,11 +2750,25 @@ |
320 |
for pkg in matched_packages: |
321 |
print (pkg.type_name + ":").rjust(10), pkg.cpv |
322 |
|
323 |
+ # Filter out any old-style virtual matches if they are |
324 |
+ # mixed with new-style virtual matches. |
325 |
+ cp = portage.dep_getkey(atom) |
326 |
+ if len(matched_packages) > 1 and \ |
327 |
+ "virtual" == portage.catsplit(cp)[0]: |
328 |
+ for pkg in matched_packages: |
329 |
+ if pkg.cp != cp: |
330 |
+ continue |
331 |
+ # Got a new-style virtual, so filter |
332 |
+ # out any old-style virtuals. |
333 |
+ matched_packages = [pkg for pkg in matched_packages \ |
334 |
+ if pkg.cp == cp] |
335 |
+ break |
336 |
+ |
337 |
if len(matched_packages) > 1: |
338 |
bestmatch = portage.best( |
339 |
[pkg.cpv for pkg in matched_packages]) |
340 |
matched_packages = [pkg for pkg in matched_packages \ |
341 |
- if pkg.cpv == bestmatch] |
342 |
+ if portage.dep.cpvequal(pkg.cpv, bestmatch)] |
343 |
|
344 |
# ordered by type preference ("ebuild" type is the last resort) |
345 |
return matched_packages[-1], existing_node |
346 |
@@ -3188,8 +3180,7 @@ |
347 |
get_nodes = mygraph.leaf_nodes |
348 |
for node in mygraph.order: |
349 |
if node.root == "/" and \ |
350 |
- "portage" == portage.catsplit( |
351 |
- portage.cpv_getkey(node.cpv))[-1]: |
352 |
+ "sys-apps/portage" == portage.cpv_getkey(node.cpv): |
353 |
portage_node = node |
354 |
asap_nodes.append(node) |
355 |
break |
356 |
@@ -4073,6 +4064,7 @@ |
357 |
print bold('*'+revision) |
358 |
sys.stdout.write(text) |
359 |
|
360 |
+ sys.stdout.flush() |
361 |
self.display_problems() |
362 |
return os.EX_OK |
363 |
|
364 |
@@ -6641,8 +6633,8 @@ |
365 |
for cpv in reversed(pkgs): |
366 |
metadata = dict(izip(metadata_keys, |
367 |
vardb.aux_get(cpv, metadata_keys))) |
368 |
- if visible(settings, cpv, metadata, |
369 |
- built=True, installed=True): |
370 |
+ if visible(settings, Package(built=True, cpv=cpv, |
371 |
+ installed=True, metadata=metadata, type_name="installed")): |
372 |
pkgs = [cpv] |
373 |
break |
374 |
if len(pkgs) > 1: |
375 |
|
376 |
Modified: main/branches/prefix/pym/portage/__init__.py |
377 |
=================================================================== |
378 |
--- main/branches/prefix/pym/portage/__init__.py 2008-04-01 18:22:48 UTC (rev 9667) |
379 |
+++ main/branches/prefix/pym/portage/__init__.py 2008-04-01 18:27:32 UTC (rev 9668) |
380 |
@@ -4356,6 +4356,7 @@ |
381 |
|
382 |
_doebuild_manifest_exempt_depend = 0 |
383 |
_doebuild_manifest_checked = None |
384 |
+_doebuild_broken_manifests = set() |
385 |
|
386 |
def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, |
387 |
fetchonly=0, cleanup=0, dbkey=None, use_cache=1, fetchall=0, tree=None, |
388 |
@@ -4464,13 +4465,16 @@ |
389 |
# Always verify the ebuild checksums before executing it. |
390 |
pkgdir = os.path.dirname(myebuild) |
391 |
manifest_path = os.path.join(pkgdir, "Manifest") |
392 |
- global _doebuild_manifest_checked |
393 |
+ global _doebuild_manifest_checked, _doebuild_broken_manifests |
394 |
+ if manifest_path in _doebuild_broken_manifests: |
395 |
+ return 1 |
396 |
# Avoid checking the same Manifest several times in a row during a |
397 |
# regen with an empty cache. |
398 |
if _doebuild_manifest_checked != manifest_path: |
399 |
if not os.path.exists(manifest_path): |
400 |
writemsg("!!! Manifest file not found: '%s'\n" % manifest_path, |
401 |
noiselevel=-1) |
402 |
+ _doebuild_broken_manifests.add(manifest_path) |
403 |
return 1 |
404 |
mf = Manifest(pkgdir, mysettings["DISTDIR"]) |
405 |
try: |
406 |
@@ -4478,6 +4482,7 @@ |
407 |
except portage.exception.FileNotFound, e: |
408 |
writemsg("!!! A file listed in the Manifest " + \ |
409 |
"could not be found: %s\n" % str(e), noiselevel=-1) |
410 |
+ _doebuild_broken_manifests.add(manifest_path) |
411 |
return 1 |
412 |
except portage.exception.DigestException, e: |
413 |
writemsg("!!! Digest verification failed:\n", noiselevel=-1) |
414 |
@@ -4485,6 +4490,7 @@ |
415 |
writemsg("!!! Reason: %s\n" % e.value[1], noiselevel=-1) |
416 |
writemsg("!!! Got: %s\n" % e.value[2], noiselevel=-1) |
417 |
writemsg("!!! Expected: %s\n" % e.value[3], noiselevel=-1) |
418 |
+ _doebuild_broken_manifests.add(manifest_path) |
419 |
return 1 |
420 |
# Make sure that all of the ebuilds are actually listed in the |
421 |
# Manifest. |
422 |
@@ -4493,6 +4499,7 @@ |
423 |
writemsg("!!! A file is not listed in the " + \ |
424 |
"Manifest: '%s'\n" % os.path.join(pkgdir, f), |
425 |
noiselevel=-1) |
426 |
+ _doebuild_broken_manifests.add(manifest_path) |
427 |
return 1 |
428 |
_doebuild_manifest_checked = manifest_path |
429 |
|
430 |
@@ -5422,8 +5429,9 @@ |
431 |
all_available = True |
432 |
versions = {} |
433 |
for atom in atoms: |
434 |
- avail_pkg = best(mydbapi.match(atom)) |
435 |
+ avail_pkg = mydbapi.match(atom) |
436 |
if avail_pkg: |
437 |
+ avail_pkg = avail_pkg[-1] # highest (ascending order) |
438 |
avail_slot = "%s:%s" % (dep_getkey(atom), |
439 |
mydbapi.aux_get(avail_pkg, ["SLOT"])[0]) |
440 |
elif not avail_pkg: |
441 |
@@ -5431,8 +5439,9 @@ |
442 |
if hasattr(mydbapi, "xmatch"): |
443 |
has_mask = bool(mydbapi.xmatch("match-all", atom)) |
444 |
if (selective or use_binaries or not has_mask): |
445 |
- avail_pkg = best(vardb.match(atom)) |
446 |
+ avail_pkg = vardb.match(atom) |
447 |
if avail_pkg: |
448 |
+ avail_pkg = avail_pkg[-1] # highest (ascending order) |
449 |
avail_slot = "%s:%s" % (dep_getkey(atom), |
450 |
vardb.aux_get(avail_pkg, ["SLOT"])[0]) |
451 |
if not avail_pkg: |
452 |
|
453 |
Modified: main/branches/prefix/pym/portage/dbapi/bintree.py |
454 |
=================================================================== |
455 |
--- main/branches/prefix/pym/portage/dbapi/bintree.py 2008-04-01 18:22:48 UTC (rev 9667) |
456 |
+++ main/branches/prefix/pym/portage/dbapi/bintree.py 2008-04-01 18:27:32 UTC (rev 9668) |
457 |
@@ -161,6 +161,7 @@ |
458 |
self._pkgindex_default_pkg_data = { |
459 |
"EAPI" : eapi, |
460 |
"IUSE" : "", |
461 |
+ "LICENSE" : "", |
462 |
"PROVIDE" : "", |
463 |
"SLOT" : "0", |
464 |
"USE" : "" |
465 |
|
466 |
-- |
467 |
gentoo-commits@l.g.o mailing list |