1 |
Author: zmedico |
2 |
Date: 2008-04-13 22:13:59 +0000 (Sun, 13 Apr 2008) |
3 |
New Revision: 9876 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/bin/emerge |
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. (trunk r9869:9872) |
11 |
|
12 |
|
13 |
Modified: main/branches/2.1.2/bin/emerge |
14 |
=================================================================== |
15 |
--- main/branches/2.1.2/bin/emerge 2008-04-13 22:07:18 UTC (rev 9875) |
16 |
+++ main/branches/2.1.2/bin/emerge 2008-04-13 22:13:59 UTC (rev 9876) |
17 |
@@ -4482,7 +4482,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 |
@@ -4491,6 +4491,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 |
@@ -4507,24 +4508,50 @@ |
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 |
+ if self._visible(pkg): |
64 |
self._cpv_pkg_map[pkg.cpv] = pkg |
65 |
- ret = [pkg.cpv] |
66 |
+ ret.append(pkg.cpv) |
67 |
+ slots.remove(pkg.metadata["SLOT"]) |
68 |
+ while slots: |
69 |
+ slot_atom = "%s:%s" % (atom_cp, slots.pop()) |
70 |
+ pkg, existing = self._depgraph._select_package( |
71 |
+ self._root, slot_atom) |
72 |
+ if not pkg: |
73 |
+ continue |
74 |
+ if not self._visible(pkg): |
75 |
+ continue |
76 |
+ self._cpv_pkg_map[pkg.cpv] = pkg |
77 |
+ ret.append(pkg.cpv) |
78 |
+ if ret: |
79 |
+ self._cpv_sort_ascending(ret) |
80 |
self._match_cache[orig_atom] = ret |
81 |
return ret[:] |
82 |
|
83 |
+ def _visible(self, pkg): |
84 |
+ if pkg.installed and "selective" not in self._depgraph.myparams: |
85 |
+ try: |
86 |
+ arg = self._depgraph._iter_atoms_for_pkg(pkg).next() |
87 |
+ except (StopIteration, portage_exception.InvalidDependString): |
88 |
+ arg = None |
89 |
+ if arg: |
90 |
+ return False |
91 |
+ if pkg.installed and \ |
92 |
+ not visible(self._depgraph.pkgsettings[pkg.root], pkg): |
93 |
+ return False |
94 |
+ return True |
95 |
+ |
96 |
def _dep_expand(self, atom): |
97 |
""" |
98 |
This is only needed for old installed packages that may |
99 |
|
100 |
-- |
101 |
gentoo-commits@l.g.o mailing list |