1 |
Author: grobian |
2 |
Date: 2008-05-27 15:30:44 +0000 (Tue, 27 May 2008) |
3 |
New Revision: 10457 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/bin/ebuild.sh |
7 |
main/branches/prefix/pym/_emerge/__init__.py |
8 |
main/branches/prefix/pym/portage/__init__.py |
9 |
main/branches/prefix/pym/portage/dbapi/vartree.py |
10 |
main/branches/prefix/pym/portage/dep.py |
11 |
main/branches/prefix/pym/portage/sets/base.py |
12 |
Log: |
13 |
Merged from trunk 10418:10438 |
14 |
|
15 |
| 10419 | * Add support for Package instances and USE deps in | |
16 |
| zmedico | match_from_list(). * Add USE dep matching support to | |
17 |
| | depgraph._iter_atoms_for_pkg(). | |
18 |
|
19 |
| 10420 | Remove the Package.cpv_slot attribute. | |
20 |
| zmedico | | |
21 |
|
22 |
| 10421 | Use the metadata wrapper to initialize Package slot and use | |
23 |
| zmedico | attributes. | |
24 |
|
25 |
| 10422 | Remove unused code. | |
26 |
| zmedico | | |
27 |
|
28 |
| 10423 | Fix breakage in Package constructor attribute | |
29 |
| zmedico | initialization. | |
30 |
|
31 |
| 10425 | Fix a broken reference to the Package.cpv_slot attribute. | |
32 |
| zmedico | | |
33 |
|
34 |
| 10427 | * Enable config.setcpv() to use a Package instance in place | |
35 |
| zmedico | of a cpv. * Make depgraph._select_package() pass Package | |
36 |
| | instances into setcpv() calls. * Enable the Package | |
37 |
| | constructor to use an iterable for metadata items. | |
38 |
|
39 |
| 10429 | Skip source_all_bashrcs() when $EBUILD_PHASE is not set. | |
40 |
| zmedico | | |
41 |
|
42 |
| 10431 | Avoid triggering "cPickle.UnpicklingError: Global and | |
43 |
| zmedico | instance pickles are not supported." errors that are | |
44 |
| | triggered when the pickle contains custom classes. | |
45 |
|
46 |
| 10433 | Don't silently swallow instances of UnpicklingError since | |
47 |
| zmedico | they are easily triggered by storing instances of custom | |
48 |
| | classes in a pickle. | |
49 |
|
50 |
| 10434 | Don't silently swallow instances of UnpicklingError since | |
51 |
| zmedico | they are easily triggered by storing instances of custom | |
52 |
| | classes in a pickle. | |
53 |
|
54 |
| 10436 | Add some debug output for arguments and their associated | |
55 |
| zmedico | atoms, to help in debugging problems similar to bug #223735. | |
56 |
|
57 |
| 10438 | Bug #223685 - Use the finally clause to collect elog | |
58 |
| zmedico | messages just before releasing the build dir lock, so they | |
59 |
| | never get missed. | |
60 |
|
61 |
|
62 |
Modified: main/branches/prefix/bin/ebuild.sh |
63 |
=================================================================== |
64 |
--- main/branches/prefix/bin/ebuild.sh 2008-05-27 10:20:38 UTC (rev 10456) |
65 |
+++ main/branches/prefix/bin/ebuild.sh 2008-05-27 15:30:44 UTC (rev 10457) |
66 |
@@ -1356,6 +1356,7 @@ |
67 |
} |
68 |
|
69 |
source_all_bashrcs() { |
70 |
+ [ -n "$EBUILD_PHASE" ] || return |
71 |
local OCC="${CC}" OCXX="${CXX}" |
72 |
# source the existing profile.bashrc's. |
73 |
save_IFS |
74 |
|
75 |
Modified: main/branches/prefix/pym/_emerge/__init__.py |
76 |
=================================================================== |
77 |
--- main/branches/prefix/pym/_emerge/__init__.py 2008-05-27 10:20:38 UTC (rev 10456) |
78 |
+++ main/branches/prefix/pym/_emerge/__init__.py 2008-05-27 15:30:44 UTC (rev 10457) |
79 |
@@ -1295,7 +1295,8 @@ |
80 |
__slots__ = ("built", "cpv", "depth", |
81 |
"installed", "metadata", "onlydeps", "operation", |
82 |
"root", "type_name", |
83 |
- "category", "cp", "cpv_slot", "pf", "pv_split", "slot_atom") |
84 |
+ "category", "cp", "cpv_split", |
85 |
+ "pf", "pv_split", "slot", "slot_atom", "use") |
86 |
|
87 |
metadata_keys = [ |
88 |
"CHOST", "COUNTER", "DEPEND", "EAPI", "IUSE", "KEYWORDS", |
89 |
@@ -1304,12 +1305,39 @@ |
90 |
|
91 |
def __init__(self, **kwargs): |
92 |
Task.__init__(self, **kwargs) |
93 |
+ self.metadata = self._metadata_wrapper(self, self.metadata) |
94 |
self.cp = portage.cpv_getkey(self.cpv) |
95 |
- self.slot_atom = "%s:%s" % (self.cp, self.metadata["SLOT"]) |
96 |
- self.cpv_slot = "%s:%s" % (self.cpv, self.metadata["SLOT"]) |
97 |
+ self.slot_atom = portage.dep.Atom("%s:%s" % (self.cp, self.slot)) |
98 |
self.category, self.pf = portage.catsplit(self.cpv) |
99 |
- self.pv_split = portage.catpkgsplit(self.cpv)[1:] |
100 |
+ self.cpv_split = portage.catpkgsplit(self.cpv) |
101 |
+ self.pv_split = self.cpv_split[1:] |
102 |
|
103 |
+ class _use(object): |
104 |
+ def __init__(self, use): |
105 |
+ self.enabled = frozenset(use) |
106 |
+ |
107 |
+ class _metadata_wrapper(dict): |
108 |
+ """ |
109 |
+ Detect metadata updates and synchronize Package attributes. |
110 |
+ """ |
111 |
+ def __init__(self, pkg, metadata): |
112 |
+ dict.__init__(self) |
113 |
+ self._pkg = pkg |
114 |
+ i = getattr(metadata, "iteritems", None) |
115 |
+ if i is None: |
116 |
+ i = metadata |
117 |
+ else: |
118 |
+ i = i() |
119 |
+ for k, v in i: |
120 |
+ self[k] = v |
121 |
+ |
122 |
+ def __setitem__(self, k, v): |
123 |
+ dict.__setitem__(self, k, v) |
124 |
+ if k == "USE": |
125 |
+ self._pkg.use = self._pkg._use(v.split()) |
126 |
+ elif k == "SLOT": |
127 |
+ self._pkg.slot = v |
128 |
+ |
129 |
def _get_hash_key(self): |
130 |
hash_key = getattr(self, "_hash_key", None) |
131 |
if hash_key is None: |
132 |
@@ -1422,8 +1450,12 @@ |
133 |
self._cache_data = mypickle.load() |
134 |
f.close() |
135 |
del f |
136 |
- except (IOError, OSError, EOFError, cPickle.UnpicklingError): |
137 |
- pass |
138 |
+ except (IOError, OSError, EOFError, cPickle.UnpicklingError), e: |
139 |
+ if isinstance(e, cPickle.UnpicklingError): |
140 |
+ writemsg("!!! Error loading '%s': %s\n" % \ |
141 |
+ (self._cache_filename, str(e)), noiselevel=-1) |
142 |
+ del e |
143 |
+ |
144 |
cache_valid = self._cache_data and \ |
145 |
isinstance(self._cache_data, dict) and \ |
146 |
self._cache_data.get("version") == self._cache_version and \ |
147 |
@@ -1451,7 +1483,7 @@ |
148 |
if not isinstance(counter, (int, long)): |
149 |
invalid_items.add(k) |
150 |
continue |
151 |
- if not isinstance(atoms, list): |
152 |
+ if not isinstance(atoms, (list, tuple)): |
153 |
invalid_items.add(k) |
154 |
continue |
155 |
invalid_atom = False |
156 |
@@ -1518,7 +1550,7 @@ |
157 |
@type blocker_data: BlockerData |
158 |
""" |
159 |
self._cache_data["blockers"][cpv] = \ |
160 |
- (blocker_data.counter, blocker_data.atoms) |
161 |
+ (blocker_data.counter, tuple(str(x) for x in blocker_data.atoms)) |
162 |
self._modified = True |
163 |
|
164 |
def __iter__(self): |
165 |
@@ -2466,6 +2498,7 @@ |
166 |
def select_files(self, myfiles): |
167 |
"""Given a list of .tbz2s, .ebuilds sets, and deps, create the |
168 |
appropriate depgraph and return a favorite list.""" |
169 |
+ debug = "--debug" in self.myopts |
170 |
root_config = self.roots[self.target_root] |
171 |
sets = root_config.sets |
172 |
getSetAtoms = root_config.setconfig.getSetAtoms |
173 |
@@ -2692,6 +2725,8 @@ |
174 |
if arg not in refs: |
175 |
refs.append(arg) |
176 |
pprovideddict = pkgsettings.pprovideddict |
177 |
+ if debug: |
178 |
+ portage.writemsg("\n", noiselevel=-1) |
179 |
# Order needs to be preserved since a feature of --nodeps |
180 |
# is to allow the user to force a specific merge order. |
181 |
args.reverse() |
182 |
@@ -2713,6 +2748,9 @@ |
183 |
"dependencies for %s\n") % arg.arg) |
184 |
return 0, myfavorites |
185 |
continue |
186 |
+ if debug: |
187 |
+ portage.writemsg(" Arg: %s\n Atom: %s\n" % \ |
188 |
+ (arg, atom), noiselevel=-1) |
189 |
pkg, existing_node = self._select_package( |
190 |
myroot, atom, onlydeps=onlydeps) |
191 |
if not pkg: |
192 |
@@ -3050,34 +3088,24 @@ |
193 |
if pkg is None: |
194 |
calculated_use = False |
195 |
try: |
196 |
- metadata = dict(izip(self._mydbapi_keys, |
197 |
- db.aux_get(cpv, self._mydbapi_keys))) |
198 |
+ metadata = zip(self._mydbapi_keys, |
199 |
+ db.aux_get(cpv, self._mydbapi_keys)) |
200 |
except KeyError: |
201 |
continue |
202 |
+ pkg = Package(built=built, cpv=cpv, |
203 |
+ installed=installed, metadata=metadata, |
204 |
+ onlydeps=onlydeps, root=root, type_name=pkg_type) |
205 |
+ metadata = pkg.metadata |
206 |
if not built and ("?" in metadata["LICENSE"] or \ |
207 |
"?" in metadata["PROVIDE"]): |
208 |
# This is avoided whenever possible because |
209 |
# it's expensive. It only needs to be done here |
210 |
# if it has an effect on visibility. |
211 |
- pkgsettings.setcpv(cpv, mydb=metadata) |
212 |
+ pkgsettings.setcpv(pkg) |
213 |
metadata["USE"] = pkgsettings["PORTAGE_USE"] |
214 |
calculated_use = True |
215 |
- pkg = Package(built=built, cpv=cpv, |
216 |
- installed=installed, metadata=metadata, |
217 |
- onlydeps=onlydeps, root=root, type_name=pkg_type) |
218 |
self._pkg_cache[pkg] = pkg |
219 |
- myarg = None |
220 |
- if root == self.target_root: |
221 |
- try: |
222 |
- myarg = self._iter_atoms_for_pkg(pkg).next() |
223 |
- except StopIteration: |
224 |
- pass |
225 |
- except portage.exception.InvalidDependString: |
226 |
- if not installed: |
227 |
- # masked by corruption |
228 |
- continue |
229 |
- if not installed and myarg: |
230 |
- found_available_arg = True |
231 |
+ |
232 |
if not installed or (installed and matched_packages): |
233 |
# Only enforce visibility on installed packages |
234 |
# if there is at least one other visible package |
235 |
@@ -3114,8 +3142,24 @@ |
236 |
if not pkg.built and not calculated_use: |
237 |
# This is avoided whenever possible because |
238 |
# it's expensive. |
239 |
- pkgsettings.setcpv(cpv, mydb=pkg.metadata) |
240 |
+ pkgsettings.setcpv(pkg) |
241 |
pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"] |
242 |
+ |
243 |
+ myarg = None |
244 |
+ if root == self.target_root: |
245 |
+ try: |
246 |
+ # Ebuild USE must have been calculated prior |
247 |
+ # to this point, in case atoms have USE deps. |
248 |
+ myarg = self._iter_atoms_for_pkg(pkg).next() |
249 |
+ except StopIteration: |
250 |
+ pass |
251 |
+ except portage.exception.InvalidDependString: |
252 |
+ if not installed: |
253 |
+ # masked by corruption |
254 |
+ continue |
255 |
+ if not installed and myarg: |
256 |
+ found_available_arg = True |
257 |
+ |
258 |
if atom.use and not pkg.built: |
259 |
use = pkg.metadata["USE"].split() |
260 |
if atom.use.enabled.difference(use): |
261 |
@@ -3136,9 +3180,7 @@ |
262 |
e_pkg = self._slot_pkg_map[root].get(pkg.slot_atom) |
263 |
if not e_pkg: |
264 |
break |
265 |
- cpv_slot = "%s:%s" % \ |
266 |
- (e_pkg.cpv, e_pkg.metadata["SLOT"]) |
267 |
- if portage.dep.match_from_list(atom, [cpv_slot]): |
268 |
+ if portage.dep.match_from_list(atom, [e_pkg]): |
269 |
if highest_version and \ |
270 |
e_pkg.cp == atom_cp and \ |
271 |
e_pkg < highest_version and \ |
272 |
@@ -3158,14 +3200,11 @@ |
273 |
"--reinstall" in self.myopts): |
274 |
iuses = set(filter_iuse_defaults( |
275 |
pkg.metadata["IUSE"].split())) |
276 |
- old_use = pkg.metadata["USE"].split() |
277 |
- mydb = pkg.metadata |
278 |
- if myeb and not usepkgonly: |
279 |
- mydb = portdb |
280 |
+ old_use = pkg.use.enabled |
281 |
if myeb: |
282 |
- pkgsettings.setcpv(myeb, mydb=mydb) |
283 |
+ pkgsettings.setcpv(myeb) |
284 |
else: |
285 |
- pkgsettings.setcpv(cpv, mydb=mydb) |
286 |
+ pkgsettings.setcpv(pkg) |
287 |
now_use = pkgsettings["PORTAGE_USE"].split() |
288 |
forced_flags = set() |
289 |
forced_flags.update(pkgsettings.useforce) |
290 |
@@ -3173,8 +3212,7 @@ |
291 |
cur_iuse = iuses |
292 |
if myeb and not usepkgonly: |
293 |
cur_iuse = set(filter_iuse_defaults( |
294 |
- portdb.aux_get(myeb, |
295 |
- ["IUSE"])[0].split())) |
296 |
+ myeb.metadata["IUSE"].split())) |
297 |
if self._reinstall_for_flags(forced_flags, |
298 |
old_use, iuses, |
299 |
now_use, cur_iuse): |
300 |
@@ -3185,7 +3223,7 @@ |
301 |
("--newuse" in self.myopts or \ |
302 |
"--reinstall" in self.myopts) and \ |
303 |
cpv in vardb.match(atom): |
304 |
- pkgsettings.setcpv(cpv, mydb=pkg.metadata) |
305 |
+ pkgsettings.setcpv(pkg) |
306 |
forced_flags = set() |
307 |
forced_flags.update(pkgsettings.useforce) |
308 |
forced_flags.update(pkgsettings.usemask) |
309 |
@@ -3202,7 +3240,7 @@ |
310 |
if reinstall_for_flags: |
311 |
reinstall = True |
312 |
if not built: |
313 |
- myeb = cpv |
314 |
+ myeb = pkg |
315 |
matched_packages.append(pkg) |
316 |
if reinstall_for_flags: |
317 |
self._reinstall_nodes[pkg] = \ |
318 |
@@ -3214,7 +3252,8 @@ |
319 |
|
320 |
if "--debug" in self.myopts: |
321 |
for pkg in matched_packages: |
322 |
- print (pkg.type_name + ":").rjust(10), pkg.cpv |
323 |
+ portage.writemsg("%s %s\n" % \ |
324 |
+ ((pkg.type_name + ":").rjust(10), pkg.cpv), noiselevel=-1) |
325 |
|
326 |
# Filter out any old-style virtual matches if they are |
327 |
# mixed with new-style virtual matches. |
328 |
@@ -5195,23 +5234,23 @@ |
329 |
continue |
330 |
mydb = trees[myroot][self.pkg_tree_map[pkg_type]].dbapi |
331 |
try: |
332 |
- metadata = dict(izip(self._mydbapi_keys, |
333 |
- mydb.aux_get(pkg_key, self._mydbapi_keys))) |
334 |
+ metadata = zip(self._mydbapi_keys, |
335 |
+ mydb.aux_get(pkg_key, self._mydbapi_keys)) |
336 |
except KeyError: |
337 |
# It does no exist or it is corrupt. |
338 |
if action == "uninstall": |
339 |
continue |
340 |
raise portage.exception.PackageNotFound(pkg_key) |
341 |
- if pkg_type == "ebuild": |
342 |
- pkgsettings = self.pkgsettings[myroot] |
343 |
- pkgsettings.setcpv(pkg_key, mydb=metadata) |
344 |
- metadata["USE"] = pkgsettings["PORTAGE_USE"] |
345 |
installed = action == "uninstall" |
346 |
built = pkg_type != "ebuild" |
347 |
pkg = Package(built=built, cpv=pkg_key, |
348 |
installed=installed, metadata=metadata, |
349 |
operation=action, root=myroot, |
350 |
type_name=pkg_type) |
351 |
+ if pkg_type == "ebuild": |
352 |
+ pkgsettings = self.pkgsettings[myroot] |
353 |
+ pkgsettings.setcpv(pkg) |
354 |
+ pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"] |
355 |
self._pkg_cache[pkg] = pkg |
356 |
|
357 |
root_config = self.roots[pkg.root] |
358 |
@@ -5957,9 +5996,6 @@ |
359 |
pkgsettings, self.edebug, mydbapi=portdb, |
360 |
tree="porttree") |
361 |
del pkgsettings["PORTAGE_BINPKG_TMPFILE"] |
362 |
- if retval != os.EX_OK or \ |
363 |
- "--buildpkgonly" in self.myopts: |
364 |
- elog_process(pkg_key, pkgsettings, phasefilter=filter_mergephases) |
365 |
if retval != os.EX_OK: |
366 |
return retval |
367 |
bintree = self.trees[myroot]["bintree"] |
368 |
@@ -6011,6 +6047,8 @@ |
369 |
return retval |
370 |
finally: |
371 |
if builddir_lock: |
372 |
+ elog_process(pkg.cpv, pkgsettings, |
373 |
+ phasefilter=filter_mergephases) |
374 |
portage.locks.unlockdir(builddir_lock) |
375 |
try: |
376 |
if not catdir_lock: |
377 |
@@ -8534,7 +8572,17 @@ |
378 |
# XXX: Stored as a list for backward compatibility. |
379 |
mtimedb["resume"]["myopts"] = \ |
380 |
[k for k in myopts if myopts[k] is True] |
381 |
- mtimedb["resume"]["favorites"]=favorites |
382 |
+ |
383 |
+ # Convert Atom instances to plain str since the mtimedb loader |
384 |
+ # sets unpickler.find_global = None which causes unpickler.load() |
385 |
+ # to raise the following exception: |
386 |
+ # |
387 |
+ # cPickle.UnpicklingError: Global and instance pickles are not supported. |
388 |
+ # |
389 |
+ # TODO: Maybe stop setting find_global = None, or find some other |
390 |
+ # way to avoid accidental triggering of the above UnpicklingError. |
391 |
+ mtimedb["resume"]["favorites"] = [str(x) for x in favorites] |
392 |
+ |
393 |
if ("--digest" in myopts) and not ("--fetchonly" in myopts or "--fetch-all-uri" in myopts): |
394 |
for pkgline in mydepgraph.altlist(): |
395 |
if pkgline[0]=="ebuild" and pkgline[3]=="merge": |
396 |
|
397 |
Modified: main/branches/prefix/pym/portage/__init__.py |
398 |
=================================================================== |
399 |
--- main/branches/prefix/pym/portage/__init__.py 2008-05-27 10:20:38 UTC (rev 10456) |
400 |
+++ main/branches/prefix/pym/portage/__init__.py 2008-05-27 15:30:44 UTC (rev 10457) |
401 |
@@ -1924,6 +1924,13 @@ |
402 |
""" |
403 |
|
404 |
self.modifying() |
405 |
+ |
406 |
+ pkg = None |
407 |
+ if not isinstance(mycpv, basestring): |
408 |
+ pkg = mycpv |
409 |
+ mycpv = pkg.cpv |
410 |
+ mydb = pkg.metadata |
411 |
+ |
412 |
if self.mycpv == mycpv: |
413 |
return |
414 |
ebuild_phase = self.get("EBUILD_PHASE") |
415 |
@@ -1939,7 +1946,10 @@ |
416 |
iuse = mydb["IUSE"] |
417 |
else: |
418 |
slot, iuse = mydb.aux_get(self.mycpv, ["SLOT", "IUSE"]) |
419 |
- cpv_slot = "%s:%s" % (self.mycpv, slot) |
420 |
+ if pkg is None: |
421 |
+ cpv_slot = "%s:%s" % (self.mycpv, slot) |
422 |
+ else: |
423 |
+ cpv_slot = pkg |
424 |
pkginternaluse = [] |
425 |
for x in iuse.split(): |
426 |
if x.startswith("+"): |
427 |
@@ -5696,7 +5706,7 @@ |
428 |
# Check if the atom would result in a direct circular |
429 |
# dependency and try to avoid that if it seems likely |
430 |
# to be unresolvable. |
431 |
- cpv_slot_list = [parent.cpv_slot] |
432 |
+ cpv_slot_list = [parent] |
433 |
circular_atom = None |
434 |
for atom in atoms: |
435 |
if "!" == atom[:1]: |
436 |
@@ -6625,7 +6635,11 @@ |
437 |
d = mypickle.load() |
438 |
f.close() |
439 |
del f |
440 |
- except (IOError, OSError, EOFError, cPickle.UnpicklingError): |
441 |
+ except (IOError, OSError, EOFError, cPickle.UnpicklingError), e: |
442 |
+ if isinstance(e, cPickle.UnpicklingError): |
443 |
+ writemsg("!!! Error loading '%s': %s\n" % \ |
444 |
+ (filename, str(e)), noiselevel=-1) |
445 |
+ del e |
446 |
d = {} |
447 |
|
448 |
if "old" in d: |
449 |
|
450 |
Modified: main/branches/prefix/pym/portage/dbapi/vartree.py |
451 |
=================================================================== |
452 |
--- main/branches/prefix/pym/portage/dbapi/vartree.py 2008-05-27 10:20:38 UTC (rev 10456) |
453 |
+++ main/branches/prefix/pym/portage/dbapi/vartree.py 2008-05-27 15:30:44 UTC (rev 10457) |
454 |
@@ -705,8 +705,11 @@ |
455 |
self._aux_cache = mypickle.load() |
456 |
f.close() |
457 |
del f |
458 |
- except (IOError, OSError, EOFError, cPickle.UnpicklingError): |
459 |
- pass |
460 |
+ except (IOError, OSError, EOFError, cPickle.UnpicklingError), e: |
461 |
+ if isinstance(e, cPickle.UnpicklingError): |
462 |
+ writemsg("!!! Error loading '%s': %s\n" % \ |
463 |
+ (self._aux_cache_filename, str(e)), noiselevel=-1) |
464 |
+ del e |
465 |
if not self._aux_cache or \ |
466 |
not isinstance(self._aux_cache, dict) or \ |
467 |
self._aux_cache.get("version") != self._aux_cache_version or \ |
468 |
|
469 |
Modified: main/branches/prefix/pym/portage/dep.py |
470 |
=================================================================== |
471 |
--- main/branches/prefix/pym/portage/dep.py 2008-05-27 10:20:38 UTC (rev 10456) |
472 |
+++ main/branches/prefix/pym/portage/dep.py 2008-05-27 15:30:44 UTC (rev 10457) |
473 |
@@ -759,6 +759,9 @@ |
474 |
@return: A list of package atoms that match the given package atom |
475 |
""" |
476 |
|
477 |
+ if not candidate_list: |
478 |
+ return [] |
479 |
+ |
480 |
from portage.util import writemsg |
481 |
if "!" == mydep[:1]: |
482 |
mydep = mydep[1:] |
483 |
@@ -791,13 +794,21 @@ |
484 |
|
485 |
if operator is None: |
486 |
for x in candidate_list: |
487 |
- if dep_getkey(x) != mycpv: |
488 |
+ cp = getattr(x, "cp", None) |
489 |
+ if cp is None: |
490 |
+ cp = dep_getkey(x) |
491 |
+ if cp != mycpv: |
492 |
continue |
493 |
mylist.append(x) |
494 |
|
495 |
elif operator == "=": # Exact match |
496 |
- mylist = [cpv for cpv in candidate_list if \ |
497 |
- cpvequal(remove_slot(cpv), mycpv)] |
498 |
+ for x in candidate_list: |
499 |
+ xcpv = getattr(x, "cpv", None) |
500 |
+ if xcpv is None: |
501 |
+ xcpv = dep_getcpv(x) |
502 |
+ if not cpvequal(xcpv, mycpv): |
503 |
+ continue |
504 |
+ mylist.append(x) |
505 |
|
506 |
elif operator == "=*": # glob match |
507 |
# XXX: Nasty special casing for leading zeros |
508 |
@@ -809,7 +820,9 @@ |
509 |
myver = "0"+myver |
510 |
mycpv = mysplit[0]+"/"+mysplit[1]+"-"+myver |
511 |
for x in candidate_list: |
512 |
- xs = catpkgsplit(remove_slot(x)) |
513 |
+ xs = getattr(x, "cpv_split", None) |
514 |
+ if xs is None: |
515 |
+ xs = catpkgsplit(remove_slot(x)) |
516 |
myver = xs[2].lstrip("0") |
517 |
if not myver or not myver[0].isdigit(): |
518 |
myver = "0"+myver |
519 |
@@ -819,8 +832,10 @@ |
520 |
|
521 |
elif operator == "~": # version, any revision, match |
522 |
for x in candidate_list: |
523 |
- xs = catpkgsplit(remove_slot(x)) |
524 |
+ xs = getattr(x, "cpv_split", None) |
525 |
if xs is None: |
526 |
+ xs = catpkgsplit(remove_slot(x)) |
527 |
+ if xs is None: |
528 |
raise InvalidData(x) |
529 |
if not cpvequal(xs[0]+"/"+xs[1]+"-"+xs[2], mycpv_cps[0]+"/"+mycpv_cps[1]+"-"+mycpv_cps[2]): |
530 |
continue |
531 |
@@ -831,8 +846,13 @@ |
532 |
elif operator in [">", ">=", "<", "<="]: |
533 |
mysplit = ["%s/%s" % (cat, pkg), ver, rev] |
534 |
for x in candidate_list: |
535 |
+ xs = getattr(x, "cpv_split", None) |
536 |
+ if xs is None: |
537 |
+ xs = catpkgsplit(remove_slot(x)) |
538 |
+ xcat, xpkg, xver, xrev = xs |
539 |
+ xs = ["%s/%s" % (xcat, xpkg), xver, xrev] |
540 |
try: |
541 |
- result = pkgcmp(pkgsplit(remove_slot(x)), mysplit) |
542 |
+ result = pkgcmp(xs, mysplit) |
543 |
except ValueError: # pkgcmp may return ValueError during int() conversion |
544 |
writemsg("\nInvalid package name: %s\n" % x, noiselevel=-1) |
545 |
raise |
546 |
@@ -859,9 +879,26 @@ |
547 |
candidate_list = mylist |
548 |
mylist = [] |
549 |
for x in candidate_list: |
550 |
- xslot = dep_getslot(x) |
551 |
+ xslot = getattr(x, "slot", None) |
552 |
+ if xslot is None and isinstance(x, basestring): |
553 |
+ xslot = dep_getslot(x) |
554 |
if xslot is not None and xslot != slot: |
555 |
continue |
556 |
mylist.append(x) |
557 |
|
558 |
+ if mydep.use: |
559 |
+ candidate_list = mylist |
560 |
+ mylist = [] |
561 |
+ for x in candidate_list: |
562 |
+ # Note: IUSE intersection is neglected here since there |
563 |
+ # is currently no way to access implicit IUSE. However, IUSE |
564 |
+ # filtering can be added elsewhere in the chain. |
565 |
+ use = getattr(x, "use", None) |
566 |
+ if use is not None: |
567 |
+ if mydep.use.enabled.difference(use.enabled): |
568 |
+ continue |
569 |
+ if mydep.use.disabled.intersection(use.enabled): |
570 |
+ continue |
571 |
+ mylist.append(x) |
572 |
+ |
573 |
return mylist |
574 |
|
575 |
Modified: main/branches/prefix/pym/portage/sets/base.py |
576 |
=================================================================== |
577 |
--- main/branches/prefix/pym/portage/sets/base.py 2008-05-27 10:20:38 UTC (rev 10456) |
578 |
+++ main/branches/prefix/pym/portage/sets/base.py 2008-05-27 15:30:44 UTC (rev 10457) |
579 |
@@ -108,7 +108,7 @@ |
580 |
atoms = list(self.iterAtomsForPackage(pkg)) |
581 |
if not atoms: |
582 |
return None |
583 |
- return best_match_to_list(pkg.cpv_slot, atoms) |
584 |
+ return best_match_to_list(pkg, atoms) |
585 |
|
586 |
def iterAtomsForPackage(self, pkg): |
587 |
""" |
588 |
@@ -116,7 +116,7 @@ |
589 |
arguments against the PROVIDE metadata. This will raise an |
590 |
InvalidDependString exception if PROVIDE is invalid. |
591 |
""" |
592 |
- cpv_slot_list = ["%s:%s" % (pkg.cpv, pkg.metadata["SLOT"])] |
593 |
+ cpv_slot_list = [pkg] |
594 |
cp = cpv_getkey(pkg.cpv) |
595 |
self._load() # make sure the atoms are loaded |
596 |
atoms = self._atommap.get(cp) |
597 |
|
598 |
-- |
599 |
gentoo-commits@l.g.o mailing list |