1 |
Author: zmedico |
2 |
Date: 2008-04-13 18:01:35 +0000 (Sun, 13 Apr 2008) |
3 |
New Revision: 9870 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
Make _dep_check_composite_db match() return multiple slots so that |
9 |
it behaves more like other dbapi instances would, and also make it |
10 |
inherit from dbapi. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/_emerge/__init__.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/_emerge/__init__.py 2008-04-13 10:44:49 UTC (rev 9869) |
16 |
+++ main/trunk/pym/_emerge/__init__.py 2008-04-13 18:01:35 UTC (rev 9870) |
17 |
@@ -4328,7 +4328,7 @@ |
18 |
fakedb[myroot].cpv_inject(pkg) |
19 |
self.spinner.update() |
20 |
|
21 |
- class _dep_check_composite_db(object): |
22 |
+ class _dep_check_composite_db(portage.dbapi): |
23 |
""" |
24 |
A dbapi-like interface that is optimized for use in dep_check() calls. |
25 |
This is built on top of the existing depgraph package selection logic. |
26 |
@@ -4337,6 +4337,7 @@ |
27 |
via dep_check(). |
28 |
""" |
29 |
def __init__(self, depgraph, root): |
30 |
+ portage.dbapi.__init__(self) |
31 |
self._depgraph = depgraph |
32 |
self._root = root |
33 |
self._match_cache = {} |
34 |
@@ -4353,21 +4354,41 @@ |
35 |
if not pkg: |
36 |
ret = [] |
37 |
else: |
38 |
- if pkg.installed and "selective" not in self._depgraph.myparams: |
39 |
- try: |
40 |
- arg = self._depgraph._iter_atoms_for_pkg(pkg).next() |
41 |
- except (StopIteration, portage.exception.InvalidDependString): |
42 |
- arg = None |
43 |
- if arg: |
44 |
- ret = [] |
45 |
- if ret is None and pkg.installed and \ |
46 |
- not visible(self._depgraph.pkgsettings[pkg.root], pkg): |
47 |
- # For disjunctive || deps, this will cause alternative |
48 |
- # atoms or packages to be selected if available. |
49 |
- ret = [] |
50 |
- if ret is None: |
51 |
+ # Return the highest available from select_package() as well as |
52 |
+ # any matching slots in the graph db. |
53 |
+ slots = set() |
54 |
+ slots.add(pkg.metadata["SLOT"]) |
55 |
+ atom_cp = portage.dep_getkey(atom) |
56 |
+ if atom_cp == pkg.cp: |
57 |
+ graph_db = self._depgraph.mydbapi[self._root] |
58 |
+ for cpv in graph_db.match(atom): |
59 |
+ if portage.cpv_getkey(cpv) != pkg.cp: |
60 |
+ continue |
61 |
+ slots.add(graph_db.aux_get(cpv, ["SLOT"])[0]) |
62 |
+ ret = [] |
63 |
+ slots.remove(pkg.metadata["SLOT"]) |
64 |
+ self._cpv_pkg_map[pkg.cpv] = pkg |
65 |
+ ret.append(pkg.cpv) |
66 |
+ while slots: |
67 |
+ slot_atom = "%s:%s" % (atom_cp, slots.pop()) |
68 |
+ pkg, existing = self._depgraph._select_package( |
69 |
+ self._root, slot_atom) |
70 |
+ if not pkg: |
71 |
+ continue |
72 |
+ if pkg.installed and "selective" not in self._depgraph.myparams: |
73 |
+ try: |
74 |
+ arg = self._depgraph._iter_atoms_for_pkg(pkg).next() |
75 |
+ except (StopIteration, portage.exception.InvalidDependString): |
76 |
+ arg = None |
77 |
+ if arg: |
78 |
+ continue |
79 |
+ if pkg.installed and \ |
80 |
+ not visible(self._depgraph.pkgsettings[pkg.root], pkg): |
81 |
+ continue |
82 |
self._cpv_pkg_map[pkg.cpv] = pkg |
83 |
- ret = [pkg.cpv] |
84 |
+ ret.append(pkg.cpv) |
85 |
+ if ret: |
86 |
+ self._cpv_sort_ascending(ret) |
87 |
self._match_cache[orig_atom] = ret |
88 |
return ret[:] |
89 |
|
90 |
|
91 |
-- |
92 |
gentoo-commits@l.g.o mailing list |