1 |
Author: zmedico |
2 |
Date: 2008-06-28 01:01:42 +0000 (Sat, 28 Jun 2008) |
3 |
New Revision: 10824 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
Bug #226307 - Copy come code from depgraph._iter_atoms_for_pkg() that |
9 |
was used to solve bug #218854, and use it inside unmerge() when |
10 |
matching sets to packages. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/_emerge/__init__.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/_emerge/__init__.py 2008-06-27 23:42:29 UTC (rev 10823) |
16 |
+++ main/trunk/pym/_emerge/__init__.py 2008-06-28 01:01:42 UTC (rev 10824) |
17 |
@@ -6536,6 +6536,19 @@ |
18 |
global_unmerge=0 |
19 |
xterm_titles = "notitles" not in settings.features |
20 |
|
21 |
+ pkg_cache = {} |
22 |
+ |
23 |
+ def _pkg(cpv): |
24 |
+ pkg = pkg_cache.get(cpv) |
25 |
+ if pkg is None: |
26 |
+ pkg = Package(cpv=cpv, installed=True, |
27 |
+ metadata=izip(Package.metadata_keys, |
28 |
+ vartree.dbapi.aux_get(cpv, Package.metadata_keys)), |
29 |
+ root_config=root_config, |
30 |
+ type_name="installed") |
31 |
+ pkg_cache[cpv] = pkg |
32 |
+ return pkg |
33 |
+ |
34 |
vdb_path = os.path.join(settings["ROOT"], portage.VDB_PATH) |
35 |
try: |
36 |
# At least the parent needs to exist for the lock file. |
37 |
@@ -6778,6 +6791,12 @@ |
38 |
# relevant package sets. |
39 |
for cp in xrange(len(pkgmap)): |
40 |
for cpv in pkgmap[cp]["selected"].copy(): |
41 |
+ try: |
42 |
+ pkg = _pkg(cpv) |
43 |
+ except KeyError: |
44 |
+ # It could have been uninstalled |
45 |
+ # by a concurrent process. |
46 |
+ continue |
47 |
parents = [] |
48 |
for s in installed_sets: |
49 |
# skip sets that the user requested to unmerge, and skip world |
50 |
@@ -6788,9 +6807,34 @@ |
51 |
# only check instances of EditablePackageSet as other classes are generally used for |
52 |
# special purposes and can be ignored here (and are usually generated dynamically, so the |
53 |
# user can't do much about them anyway) |
54 |
- elif sets[s].containsCPV(cpv) \ |
55 |
- and isinstance(sets[s], EditablePackageSet): |
56 |
- parents.append(s) |
57 |
+ if isinstance(sets[s], EditablePackageSet): |
58 |
+ |
59 |
+ # This is derived from a snippet of code in the |
60 |
+ # depgraph._iter_atoms_for_pkg() method. |
61 |
+ for atom in sets[s].iterAtomsForPackage(pkg): |
62 |
+ inst_matches = vartree.dbapi.match(atom) |
63 |
+ inst_matches.reverse() # descending order |
64 |
+ higher_slot = None |
65 |
+ for inst_cpv in inst_matches: |
66 |
+ try: |
67 |
+ inst_pkg = _pkg(inst_cpv) |
68 |
+ except KeyError: |
69 |
+ # It could have been uninstalled |
70 |
+ # by a concurrent process. |
71 |
+ continue |
72 |
+ |
73 |
+ if inst_pkg.cp != atom.cp: |
74 |
+ continue |
75 |
+ if pkg >= inst_pkg: |
76 |
+ # This is descending order, and we're not |
77 |
+ # interested in any versions <= pkg given. |
78 |
+ break |
79 |
+ if pkg.slot_atom != inst_pkg.slot_atom: |
80 |
+ higher_slot = inst_pkg |
81 |
+ break |
82 |
+ if higher_slot is None: |
83 |
+ parents.append(s) |
84 |
+ break |
85 |
if parents: |
86 |
#print colorize("WARN", "Package %s is going to be unmerged," % cpv) |
87 |
#print colorize("WARN", "but still listed in the following package sets:") |
88 |
|
89 |
-- |
90 |
gentoo-commits@l.g.o mailing list |