1 |
Author: zmedico |
2 |
Date: 2008-03-31 20:06:10 +0000 (Mon, 31 Mar 2008) |
3 |
New Revision: 9649 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/bin/emerge |
7 |
Log: |
8 |
Make depgraph creation more tolerant of missing or masked packages when |
9 |
the relevant deps are satisfied by installed packages. This kind of |
10 |
friendliness is especially desired in cases such as --emptytree where |
11 |
it might not be possible to reinstall every single package. Also, it |
12 |
allows multislot atoms from the world file (that are necessary to prevent |
13 |
them from being removed by depclean) trigger warning messages while |
14 |
still allowing a --emptytree to proceed. (trunk r9643:9648) |
15 |
|
16 |
|
17 |
Modified: main/branches/2.1.2/bin/emerge |
18 |
=================================================================== |
19 |
--- main/branches/2.1.2/bin/emerge 2008-03-31 19:55:56 UTC (rev 9648) |
20 |
+++ main/branches/2.1.2/bin/emerge 2008-03-31 20:06:10 UTC (rev 9649) |
21 |
@@ -1269,7 +1269,7 @@ |
22 |
class Package(object): |
23 |
__slots__ = ("__weakref__", "built", "cpv", "depth", |
24 |
"installed", "metadata", "root", "onlydeps", "type_name", |
25 |
- "cpv_slot", "slot_atom", "_digraph_node") |
26 |
+ "cp", "cpv_slot", "slot_atom", "_digraph_node") |
27 |
def __init__(self, **kwargs): |
28 |
for myattr in self.__slots__: |
29 |
if myattr == "__weakref__": |
30 |
@@ -1277,9 +1277,8 @@ |
31 |
myvalue = kwargs.get(myattr, None) |
32 |
setattr(self, myattr, myvalue) |
33 |
|
34 |
- self.slot_atom = "%s:%s" % \ |
35 |
- (portage.cpv_getkey(self.cpv), self.metadata["SLOT"]) |
36 |
- |
37 |
+ self.cp = portage.cpv_getkey(self.cpv) |
38 |
+ self.slot_atom = "%s:%s" % (self.cp, self.metadata["SLOT"]) |
39 |
self.cpv_slot = "%s:%s" % (self.cpv, self.metadata["SLOT"]) |
40 |
|
41 |
status = "merge" |
42 |
@@ -2087,9 +2086,12 @@ |
43 |
return False, myfavorites |
44 |
|
45 |
if pkg.installed and "selective" not in self.myparams: |
46 |
+ # Previous behavior was to bail out in this case, but |
47 |
+ # since the dep is satisfied by the installed package, |
48 |
+ # it's more friendly to continue building the graph |
49 |
+ # and just show a warning message. |
50 |
self._unsatisfied_deps_for_display.append( |
51 |
((myroot, myatom), {"myparent":None})) |
52 |
- return 0, myfavorites |
53 |
|
54 |
try: |
55 |
self.mysd = self.create(pkg, None) |
56 |
@@ -2212,7 +2214,6 @@ |
57 |
empty = "empty" in self.myparams |
58 |
selective = "selective" in self.myparams |
59 |
noreplace = "--noreplace" in self.myopts |
60 |
- reinstall = False |
61 |
# Behavior of the "selective" parameter depends on |
62 |
# whether or not a package matches an argument atom. |
63 |
# If an installed package provides an old-style |
64 |
@@ -2231,14 +2232,6 @@ |
65 |
for db, pkg_type, built, installed, db_keys in dbs: |
66 |
if existing_node: |
67 |
break |
68 |
- if installed and not find_existing_node and \ |
69 |
- (reinstall or not selective) and \ |
70 |
- (matched_packages or empty): |
71 |
- # We only need to select an installed package in the |
72 |
- # following cases: |
73 |
- # 1) there is no other choice |
74 |
- # 2) selective is True |
75 |
- continue |
76 |
if hasattr(db, "xmatch"): |
77 |
cpv_list = db.xmatch("match-all", atom) |
78 |
else: |
79 |
@@ -2328,7 +2321,7 @@ |
80 |
if not installed and \ |
81 |
("--newuse" in self.myopts or \ |
82 |
"--reinstall" in self.myopts) and \ |
83 |
- vardb.cpv_exists(cpv): |
84 |
+ cpv in vardb.match(atom): |
85 |
pkgsettings.setcpv(cpv, mydb=metadata) |
86 |
forced_flags = set() |
87 |
forced_flags.update(pkgsettings.useforce) |
88 |
@@ -2343,8 +2336,6 @@ |
89 |
self._reinstall_for_flags( |
90 |
forced_flags, old_use, old_iuse, |
91 |
cur_use, cur_iuse) |
92 |
- if reinstall_for_flags: |
93 |
- reinstall = True |
94 |
if not installed: |
95 |
must_reinstall = empty or \ |
96 |
(myarg and not selective) |
97 |
@@ -2352,11 +2343,6 @@ |
98 |
not must_reinstall and \ |
99 |
cpv in vardb.match(atom): |
100 |
break |
101 |
- if installed: |
102 |
- must_reinstall = empty or \ |
103 |
- (found_available_arg and not selective) |
104 |
- if must_reinstall: |
105 |
- break |
106 |
# Metadata accessed above is cached internally by |
107 |
# each db in order to optimize visibility checks. |
108 |
# Now that all possible checks visibility checks |
109 |
@@ -2369,14 +2355,20 @@ |
110 |
pkgsettings.setcpv(cpv, mydb=metadata) |
111 |
metadata["USE"] = pkgsettings["PORTAGE_USE"] |
112 |
myeb = cpv |
113 |
- matched_packages.append( |
114 |
- Package(type_name=pkg_type, root=root, |
115 |
- cpv=cpv, metadata=metadata, |
116 |
- built=built, installed=installed, |
117 |
- onlydeps=onlydeps)) |
118 |
+ want_reinstall = False |
119 |
+ if installed: |
120 |
+ want_reinstall = empty or \ |
121 |
+ (found_available_arg and not selective) |
122 |
+ pkg = Package(type_name=pkg_type, root=root, |
123 |
+ cpv=cpv, metadata=metadata, |
124 |
+ built=built, installed=installed, |
125 |
+ onlydeps=onlydeps) |
126 |
+ if installed and want_reinstall: |
127 |
+ matched_packages.insert(0, pkg) |
128 |
+ else: |
129 |
+ matched_packages.append(pkg) |
130 |
if reinstall_for_flags: |
131 |
- pkg_node = (pkg_type, root, cpv, "merge") |
132 |
- self._reinstall_nodes[pkg_node] = \ |
133 |
+ self._reinstall_nodes[pkg] = \ |
134 |
reinstall_for_flags |
135 |
break |
136 |
|
137 |
@@ -2387,11 +2379,25 @@ |
138 |
for pkg in matched_packages: |
139 |
print (pkg.type_name + ":").rjust(10), pkg.cpv |
140 |
|
141 |
+ # Filter out any old-style virtual matches if they are |
142 |
+ # mixed with new-style virtual matches. |
143 |
+ cp = portage.dep_getkey(atom) |
144 |
+ if len(matched_packages) > 1 and \ |
145 |
+ "virtual" == portage.catsplit(cp)[0]: |
146 |
+ for pkg in matched_packages: |
147 |
+ if pkg.cp != cp: |
148 |
+ continue |
149 |
+ # Got a new-style virtual, so filter |
150 |
+ # out any old-style virtuals. |
151 |
+ matched_packages = [pkg for pkg in matched_packages \ |
152 |
+ if pkg.cp == cp] |
153 |
+ break |
154 |
+ |
155 |
if len(matched_packages) > 1: |
156 |
bestmatch = portage.best( |
157 |
[pkg.cpv for pkg in matched_packages]) |
158 |
matched_packages = [pkg for pkg in matched_packages \ |
159 |
- if pkg.cpv == bestmatch] |
160 |
+ if portage_dep.cpvequal(pkg.cpv, bestmatch)] |
161 |
|
162 |
# ordered by type preference ("ebuild" type is the last resort) |
163 |
return matched_packages[-1], existing_node |
164 |
@@ -3106,6 +3112,14 @@ |
165 |
self._missing_args.append(mydep) |
166 |
continue |
167 |
|
168 |
+ if pkg.installed and "selective" not in self.myparams: |
169 |
+ # Previous behavior was to bail out in this case, but |
170 |
+ # since the dep is satisfied by the installed package, |
171 |
+ # it's more friendly to continue building the graph |
172 |
+ # and just show a warning message. |
173 |
+ self._unsatisfied_deps_for_display.append( |
174 |
+ ((myroot, mydep), {"myparent":None})) |
175 |
+ |
176 |
if not self.create(pkg, None): |
177 |
print >> sys.stderr, "\n\n!!! Problem resolving dependencies for", mydep |
178 |
return 0 |
179 |
@@ -3746,6 +3760,7 @@ |
180 |
print bold('*'+revision) |
181 |
sys.stdout.write(text) |
182 |
|
183 |
+ sys.stdout.flush() |
184 |
self.display_problems() |
185 |
return os.EX_OK |
186 |
|
187 |
|
188 |
-- |
189 |
gentoo-commits@l.g.o mailing list |