Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11571 - in main/branches/prefix: bin cnf pym/_emerge pym/portage pym/portage/dbapi pym/portage/sets
Date: Sat, 27 Sep 2008 16:08:45
Message-Id: E1KjcLZ-0005Tw-0W@stork.gentoo.org
1 Author: grobian
2 Date: 2008-09-27 16:08:34 +0000 (Sat, 27 Sep 2008)
3 New Revision: 11571
4
5 Added:
6 main/branches/prefix/pym/portage/_selinux.py
7 Removed:
8 main/branches/prefix/pym/portage/selinux.py
9 Modified:
10 main/branches/prefix/bin/ecompress
11 main/branches/prefix/cnf/sets.conf
12 main/branches/prefix/pym/_emerge/__init__.py
13 main/branches/prefix/pym/portage/__init__.py
14 main/branches/prefix/pym/portage/dbapi/vartree.py
15 main/branches/prefix/pym/portage/getbinpkg.py
16 main/branches/prefix/pym/portage/sets/dbapi.py
17 main/branches/prefix/pym/portage/util.py
18 Log:
19 Merged from trunk -r11531:11544
20
21 | 11533 | don't attempt to unmerge a set that doesn't exist anymore |
22 | genone | |
23
24 | 11534 | remove deprecation warnings and compat code for 2.1 changes |
25 | genone | to rsync and action argument syntax |
26
27 | 11535 | Bug #230975 - Rename the portage.selinux module to |
28 | zmedico | portage._selinux in order to avoid a relative import issue |
29 | | which caused portage.selinux to attempt to import itself |
30 | | instead of the real 'selinux' module. Thanks to Michael |
31 | | Edenfield for this patch. |
32
33 | 11536 | Import cPickle as pickle instead of vice versa. Eases 2to3's |
34 | zmedico | job because cPickle won't exist in py3k and 2to3 does |
35 | | s/cPickle/pickle. Thanks to Ali Polatel <hawking@g.o> for |
36 | | this patch. |
37
38 | 11537 | Fix fetch() mirror:// handling in to comply with section |
39 | zmedico | 9.2.8 of PMS. |
40
41 | 11538 | Bug #238550 - Set world-candidate = False for the @system |
42 | zmedico | since the portage ebuild will now automatically add @system |
43 | | to world_sets on upgrade and therefore it should no longer |
44 | | be necessary to add it world_sets via the command line. |
45
46 | 11539 | Fix the case where all arguments are filtered out by |
47 | zmedico | PORTAGE_COMPRESS_EXCLUDE_SUFFIXES, since otherwise 'set' was |
48 | | called with no arguments which caused the environment to be |
49 | | displayed on stdout. |
50
51 | 11540 | Add a new AgeSet class to select installed packages that |
52 | genone | have been installed more/less than n days ago |
53
54 | 11541 | relocate the post_emerge call so it gets called in more |
55 | genone | situations. |
56
57 | 11542 | move set expansion code into its own function |
58 | genone | |
59
60 | 11543 | implement simple expression logic for apckage sets to |
61 | genone | generate unions, intersections and differences of two or |
62 | | more package sets |
63
64 | 11544 | change set expression syntax: operators now have a @ suffix |
65 | genone | (IOW: all operands must be prefixed with @) to maintain |
66 | | compability with existing set names containing hyphens |
67
68
69 Modified: main/branches/prefix/bin/ecompress
70 ===================================================================
71 --- main/branches/prefix/bin/ecompress 2008-09-27 16:03:31 UTC (rev 11570)
72 +++ main/branches/prefix/bin/ecompress 2008-09-27 16:08:34 UTC (rev 11571)
73 @@ -77,7 +77,8 @@
74 filtered_args[$i]=$x
75 (( i++ ))
76 done
77 - set "${filtered_args[@]}"
78 + [ $i -eq 0 ] && exit 0
79 + set -- "${filtered_args[@]}"
80
81 # If a compressed version of the file already exists, simply
82 # delete it so that the compressor doesn't whine (bzip2 will
83
84 Modified: main/branches/prefix/cnf/sets.conf
85 ===================================================================
86 --- main/branches/prefix/cnf/sets.conf 2008-09-27 16:03:31 UTC (rev 11570)
87 +++ main/branches/prefix/cnf/sets.conf 2008-09-27 16:08:34 UTC (rev 11571)
88 @@ -12,6 +12,7 @@
89 # Same as for world, though later portage versions might use a different class
90 [system]
91 class = portage.sets.profiles.PackagesSystemSet
92 +world-candidate = False
93
94 # For security there are multiple classes available, but differences are
95 # rather small (normally there should be no visible difference):
96
97 Modified: main/branches/prefix/pym/_emerge/__init__.py
98 ===================================================================
99 --- main/branches/prefix/pym/_emerge/__init__.py 2008-09-27 16:03:31 UTC (rev 11570)
100 +++ main/branches/prefix/pym/_emerge/__init__.py 2008-09-27 16:08:34 UTC (rev 11571)
101 @@ -88,9 +88,9 @@
102 from UserDict import DictMixin
103
104 try:
105 - import cPickle
106 + import cPickle as pickle
107 except ImportError:
108 - import pickle as cPickle
109 + import pickle
110
111 try:
112 import cStringIO as StringIO
113 @@ -3686,13 +3686,13 @@
114 def _load(self):
115 try:
116 f = open(self._cache_filename)
117 - mypickle = cPickle.Unpickler(f)
118 + mypickle = pickle.Unpickler(f)
119 mypickle.find_global = None
120 self._cache_data = mypickle.load()
121 f.close()
122 del f
123 - except (IOError, OSError, EOFError, cPickle.UnpicklingError), e:
124 - if isinstance(e, cPickle.UnpicklingError):
125 + except (IOError, OSError, EOFError, pickle.UnpicklingError), e:
126 + if isinstance(e, pickle.UnpicklingError):
127 writemsg("!!! Error loading '%s': %s\n" % \
128 (self._cache_filename, str(e)), noiselevel=-1)
129 del e
130 @@ -3772,7 +3772,7 @@
131 secpass >= 2:
132 try:
133 f = portage.util.atomic_ofstream(self._cache_filename)
134 - cPickle.dump(self._cache_data, f, -1)
135 + pickle.dump(self._cache_data, f, -1)
136 f.close()
137 portage.util.apply_secpass_permissions(
138 self._cache_filename, gid=portage.portage_gid, mode=0644)
139 @@ -10581,6 +10581,8 @@
140 stop = True
141 pos = len(installed_sets)
142 for s in installed_sets[pos - 1:]:
143 + if s not in sets:
144 + continue
145 candidates = [x[len(SETPREFIX):] for x in sets[s].getNonAtoms() if x.startswith(SETPREFIX)]
146 if candidates:
147 stop = False
148 @@ -10916,6 +10918,30 @@
149 print "Use " + colorize("GOOD", "eselect news") + " to read news items."
150 print
151
152 +def display_preserved_libs(vardbapi):
153 + MAX_DISPLAY = 3
154 +
155 + if vardbapi.plib_registry.hasEntries():
156 + print
157 + print colorize("WARN", "!!!") + " existing preserved libs:"
158 + plibdata = vardbapi.plib_registry.getPreservedLibs()
159 + linkmap = vardbapi.linkmap
160 + for cpv in plibdata:
161 + print colorize("WARN", ">>>") + " package: %s" % cpv
162 + for f in plibdata[cpv]:
163 + print colorize("WARN", " * ") + " - %s" % f
164 + consumers = list(linkmap.findConsumers(f))
165 + consumers.sort()
166 + owners = vardbapi._owners.getFileOwnerMap(consumers[:MAX_DISPLAY+2])
167 + for c in consumers[:MAX_DISPLAY]:
168 + print colorize("WARN", " * ") + " used by %s (%s)" % (c, ", ".join([x.mycpv for x in owners[c]]))
169 + if len(consumers) > MAX_DISPLAY + 1:
170 + print colorize("WARN", " * ") + " used by %d other files" % (len(consumers) - MAX_DISPLAY)
171 + else:
172 + print colorize("WARN", " * ") + " used by %s (%s)" % (consumers[MAX_DISPLAY], ", ".join([x.mycpv for x in owners[consumers[MAX_DISPLAY]]]))
173 + print "Use " + colorize("GOOD", "emerge @preserved-rebuild") + " to rebuild packages using these libraries"
174 +
175 +
176 def _flush_elog_mod_echo():
177 """
178 Dump the mod_echo output now so that our other
179 @@ -10984,7 +11010,7 @@
180 vdb_path = os.path.join(target_root, portage.VDB_PATH)
181 portage.util.ensure_dirs(vdb_path)
182 vdb_lock = None
183 - if os.access(vdb_path, os.W_OK):
184 + if os.access(vdb_path, os.W_OK) and not "--pretend" in myopts:
185 vdb_lock = portage.locks.lockdir(vdb_path)
186
187 if vdb_lock:
188 @@ -11000,16 +11026,8 @@
189 chk_updated_cfg_files(target_root + EPREFIX, config_protect)
190
191 display_news_notification(root_config, myopts)
192 -
193 - if vardbapi.plib_registry.hasEntries():
194 - print
195 - print colorize("WARN", "!!!") + " existing preserved libs:"
196 - plibdata = vardbapi.plib_registry.getPreservedLibs()
197 - for cpv in plibdata:
198 - print colorize("WARN", ">>>") + " package: %s" % cpv
199 - for f in plibdata[cpv]:
200 - print colorize("WARN", " * ") + " - %s" % f
201 - print "Use " + colorize("GOOD", "emerge @preserved-rebuild") + " to rebuild packages using these libraries"
202 + if retval in (None, os.EX_OK) or (not "--pretend" in myopts):
203 + display_preserved_libs(vardbapi)
204
205 sys.exit(retval)
206
207 @@ -11197,18 +11215,7 @@
208 "PORTAGE_RSYNC_OPTS (can be overridden with --exclude='!')\n")
209 rsync_opts.append(opt)
210
211 - if settings["RSYNC_TIMEOUT"] != "":
212 - portage.writemsg("WARNING: usage of RSYNC_TIMEOUT is deprecated, " + \
213 - "use PORTAGE_RSYNC_EXTRA_OPTS instead\n")
214 - try:
215 - mytimeout = int(settings["RSYNC_TIMEOUT"])
216 - rsync_opts.append("--timeout=%d" % mytimeout)
217 - except ValueError, e:
218 - portage.writemsg("!!! %s\n" % str(e))
219 -
220 - # TODO: determine options required for official servers
221 if syncuri.rstrip("/").endswith(".gentoo.org/gentoo-portage"):
222 -
223 def rsync_opt_startswith(opt_prefix):
224 for x in rsync_opts:
225 if x.startswith(opt_prefix):
226 @@ -11235,24 +11242,6 @@
227 if "--debug" in myopts:
228 rsync_opts.append("--checksum") # Force checksum on all files
229
230 - if settings["RSYNC_EXCLUDEFROM"] != "":
231 - portage.writemsg(yellow("WARNING:") + \
232 - " usage of RSYNC_EXCLUDEFROM is deprecated, use " + \
233 - "PORTAGE_RSYNC_EXTRA_OPTS instead\n")
234 - if os.path.exists(settings["RSYNC_EXCLUDEFROM"]):
235 - rsync_opts.append("--exclude-from=%s" % \
236 - settings["RSYNC_EXCLUDEFROM"])
237 - else:
238 - portage.writemsg("!!! RSYNC_EXCLUDEFROM specified," + \
239 - " but file does not exist.\n")
240 -
241 - if settings["RSYNC_RATELIMIT"] != "":
242 - portage.writemsg(yellow("WARNING:") + \
243 - " usage of RSYNC_RATELIMIT is deprecated, use " + \
244 - "PORTAGE_RSYNC_EXTRA_OPTS instead")
245 - rsync_opts.append("--bwlimit=%s" % \
246 - settings["RSYNC_RATELIMIT"])
247 -
248 # Real local timestamp file.
249 servertimestampfile = os.path.join(
250 myportdir, "metadata", "timestamp.chk")
251 @@ -11274,11 +11263,7 @@
252 rsync_initial_timeout = 15
253
254 try:
255 - if "RSYNC_RETRIES" in settings:
256 - print yellow("WARNING:")+" usage of RSYNC_RETRIES is deprecated, use PORTAGE_RSYNC_RETRIES instead"
257 - maxretries=int(settings["RSYNC_RETRIES"])
258 - else:
259 - maxretries=int(settings["PORTAGE_RSYNC_RETRIES"])
260 + maxretries=int(settings["PORTAGE_RSYNC_RETRIES"])
261 except SystemExit, e:
262 raise # Needed else can't exit
263 except:
264 @@ -13088,9 +13073,6 @@
265 + " problems due to overlapping packages.\n")
266 trees[settings["ROOT"]]["vartree"].dbapi.plib_registry.pruneNonExisting()
267
268 - if merge_count and not (buildpkgonly or fetchonly or pretend):
269 - root_config = trees[settings["ROOT"]]["root_config"]
270 - post_emerge(root_config, myopts, mtimedb, retval)
271 return retval
272
273 def multiple_actions(action1, action2):
274 @@ -13280,25 +13262,8 @@
275 sys.exit(1)
276 myaction = action_opt
277
278 - for x in myargs:
279 - if x in actions and myaction != "search":
280 - if not silent:
281 - print red("*** Deprecated use of action '%s', use '--%s' instead" % (x,x))
282 - # special case "search" so people can search for action terms, e.g. emerge -s sync
283 - if myaction:
284 - multiple_actions(myaction, x)
285 - sys.exit(1)
286 - myaction = x
287 - else:
288 - myfiles.append(x)
289 + myfiles += myargs
290
291 - if "--nocolor" in myopts:
292 - if not silent:
293 - sys.stderr.write("*** Deprecated use of '--nocolor', " + \
294 - "use '--color=n' instead.\n")
295 - del myopts["--nocolor"]
296 - myopts["--color"] = "n"
297 -
298 return myaction, myopts, myfiles
299
300 def validate_ebuild_environment(trees):
301 @@ -13478,6 +13443,110 @@
302 writemsg_level("".join("%s\n" % l for l in msg),
303 level=logging.ERROR, noiselevel=-1)
304
305 +def expand_set_arguments(myfiles, myaction, root_config):
306 + retval = os.EX_OK
307 + setconfig = root_config.setconfig
308 +
309 + # display errors that occured while loading the SetConfig instance
310 + for e in setconfig.errors:
311 + print colorize("BAD", "Error during set creation: %s" % e)
312 +
313 + sets = setconfig.getSets()
314 +
315 + # emerge relies on the existance of sets with names "world" and "system"
316 + required_sets = ("world", "system")
317 +
318 + for s in required_sets:
319 + if s not in sets:
320 + msg = ["emerge: incomplete set configuration, " + \
321 + "no \"%s\" set defined" % s]
322 + msg.append(" sets defined: %s" % ", ".join(sets))
323 + for line in msg:
324 + sys.stderr.write(line + "\n")
325 + retval = 1
326 + unmerge_actions = ("unmerge", "prune", "clean", "depclean")
327 +
328 + # In order to know exactly which atoms/sets should be added to the
329 + # world file, the depgraph performs set expansion later. It will get
330 + # confused about where the atoms came from if it's not allowed to
331 + # expand them itself.
332 + do_not_expand = (None, )
333 + newargs = []
334 + for a in myfiles:
335 + if a in ("system", "world"):
336 + newargs.append(SETPREFIX+a)
337 + else:
338 + newargs.append(a)
339 + myfiles = newargs
340 + del newargs
341 + newargs = []
342 +
343 + # WARNING: all operators must be of equal length
344 + IS_OPERATOR = "/@"
345 + DIFF_OPERATOR = "-@"
346 + UNION_OPERATOR = "+@"
347 +
348 + for a in myfiles:
349 + if a.startswith(SETPREFIX):
350 + # support simple set operations (intersection, difference and union)
351 + # on the commandline. Expressions are evaluated strictly left-to-right
352 + if IS_OPERATOR in a or DIFF_OPERATOR in a or UNION_OPERATOR in a:
353 + expression = a[len(SETPREFIX):]
354 + expr_sets = []
355 + expr_ops = []
356 + while IS_OPERATOR in expression or DIFF_OPERATOR in expression or UNION_OPERATOR in expression:
357 + is_pos = expression.rfind(IS_OPERATOR)
358 + diff_pos = expression.rfind(DIFF_OPERATOR)
359 + union_pos = expression.rfind(UNION_OPERATOR)
360 + op_pos = max(is_pos, diff_pos, union_pos)
361 + s1 = expression[:op_pos]
362 + s2 = expression[op_pos+len(IS_OPERATOR):]
363 + op = expression[op_pos:op_pos+len(IS_OPERATOR)]
364 + if not s2 in sets:
365 + display_missing_pkg_set(root_config, s2)
366 + return (None, 1)
367 + expr_sets.insert(0, s2)
368 + expr_ops.insert(0, op)
369 + expression = s1
370 + if not expression in sets:
371 + display_missing_pkg_set(root_config, expression)
372 + return (None, 1)
373 + expr_sets.insert(0, expression)
374 + result = set(setconfig.getSetAtoms(expression))
375 + for i in range(0, len(expr_ops)):
376 + s2 = setconfig.getSetAtoms(expr_sets[i+1])
377 + if expr_ops[i] == IS_OPERATOR:
378 + result.intersection_update(s2)
379 + elif expr_ops[i] == DIFF_OPERATOR:
380 + result.difference_update(s2)
381 + elif expr_ops[i] == UNION_OPERATOR:
382 + result.update(s2)
383 + else:
384 + raise NotImplementedError("unknown set operator %s" % expr_ops[i])
385 + newargs.extend(result)
386 + else:
387 + s = a[len(SETPREFIX):]
388 + if s not in sets:
389 + display_missing_pkg_set(root_config, s)
390 + return (None, 1)
391 + setconfig.active.append(s)
392 + if myaction in unmerge_actions and \
393 + not sets[s].supportsOperation("unmerge"):
394 + sys.stderr.write("emerge: the given set '%s' does " % s + \
395 + "not support unmerge operations\n")
396 + retval = 1
397 + elif not setconfig.getSetAtoms(s):
398 + print "emerge: '%s' is an empty set" % s
399 + elif myaction not in do_not_expand:
400 + newargs.extend(setconfig.getSetAtoms(s))
401 + else:
402 + newargs.append(SETPREFIX+s)
403 + for e in sets[s].errors:
404 + print e
405 + else:
406 + newargs.append(a)
407 + return (newargs, retval)
408 +
409 def emerge_main():
410 global portage # NFC why this is necessary now - genone
411 portage._disable_legacy_globals()
412 @@ -13617,62 +13686,10 @@
413 # only expand sets for actions taking package arguments
414 oldargs = myfiles[:]
415 if myaction in ("clean", "config", "depclean", "info", "prune", "unmerge", None):
416 - setconfig = root_config.setconfig
417 - # display errors that occured while loading the SetConfig instance
418 - for e in setconfig.errors:
419 - print colorize("BAD", "Error during set creation: %s" % e)
420 -
421 - sets = setconfig.getSets()
422 - # emerge relies on the existance of sets with names "world" and "system"
423 - required_sets = ("world", "system")
424 - for s in required_sets:
425 - if s not in sets:
426 - msg = ["emerge: incomplete set configuration, " + \
427 - "no \"%s\" set defined" % s]
428 - msg.append(" sets defined: %s" % ", ".join(sets))
429 - for line in msg:
430 - sys.stderr.write(line + "\n")
431 - return 1
432 - unmerge_actions = ("unmerge", "prune", "clean", "depclean")
433 -
434 - # In order to know exactly which atoms/sets should be added to the
435 - # world file, the depgraph performs set expansion later. It will get
436 - # confused about where the atoms came from if it's not allowed to
437 - # expand them itself.
438 - do_not_expand = (None, )
439 - newargs = []
440 - for a in myfiles:
441 - if a in ("system", "world"):
442 - newargs.append(SETPREFIX+a)
443 - else:
444 - newargs.append(a)
445 - myfiles = newargs
446 - del newargs
447 - newargs = []
448 - for a in myfiles:
449 - if a.startswith(SETPREFIX):
450 - s = a[len(SETPREFIX):]
451 - if s not in sets:
452 - display_missing_pkg_set(root_config, s)
453 - return 1
454 - setconfig.active.append(s)
455 - if myaction in unmerge_actions and \
456 - not sets[s].supportsOperation("unmerge"):
457 - sys.stderr.write("emerge: the given set '%s' does " % s + \
458 - "not support unmerge operations\n")
459 - return 1
460 - if not setconfig.getSetAtoms(s):
461 - print "emerge: '%s' is an empty set" % s
462 - elif myaction not in do_not_expand:
463 - newargs.extend(setconfig.getSetAtoms(s))
464 - else:
465 - newargs.append(SETPREFIX+s)
466 - for e in sets[s].errors:
467 - print e
468 - else:
469 - newargs.append(a)
470 - myfiles = newargs
471 - del newargs
472 + myfiles, retval = expand_set_arguments(myfiles, myaction, root_config)
473 + if retval != os.EX_OK:
474 + return retval
475 +
476 # Need to handle empty sets specially, otherwise emerge will react
477 # with the help message for empty argument lists
478 if oldargs and not myfiles:
479 @@ -13948,8 +13965,7 @@
480 display_news_notification(root_config, myopts)
481 retval = action_build(settings, trees, mtimedb,
482 myopts, myaction, myfiles, spinner)
483 - # if --pretend was not enabled then display_news_notification
484 - # was already called by post_emerge
485 - if "--pretend" in myopts:
486 - display_news_notification(root_config, myopts)
487 + root_config = trees[settings["ROOT"]]["root_config"]
488 + post_emerge(root_config, myopts, mtimedb, retval)
489 +
490 return retval
491
492 Modified: main/branches/prefix/pym/portage/__init__.py
493 ===================================================================
494 --- main/branches/prefix/pym/portage/__init__.py 2008-09-27 16:03:31 UTC (rev 11570)
495 +++ main/branches/prefix/pym/portage/__init__.py 2008-09-27 16:08:34 UTC (rev 11571)
496 @@ -20,9 +20,9 @@
497 import shutil
498 import time
499 try:
500 - import cPickle
501 + import cPickle as pickle
502 except ImportError:
503 - import pickle as cPickle
504 + import pickle
505
506 import stat
507 import commands
508 @@ -141,7 +141,7 @@
509
510
511 try:
512 - import portage.selinux as selinux
513 + import portage._selinux as selinux
514 except OSError, e:
515 writemsg("!!! SELinux not loaded: %s\n" % str(e), noiselevel=-1)
516 del e
517 @@ -3528,11 +3528,19 @@
518 eidx = myuri.find("/", 9)
519 if eidx != -1:
520 mirrorname = myuri[9:eidx]
521 + if myfile != os.path.basename(myuri):
522 + # If a SRC_URI arrow is used together with
523 + # mirror://, preserve the remote path that's
524 + # specified within the uri.
525 + path = myuri[eidx+1:]
526 + else:
527 + path = myfile
528
529 # Try user-defined mirrors first
530 if mirrorname in custommirrors:
531 for cmirr in custommirrors[mirrorname]:
532 - filedict[myfile].append(cmirr+"/"+myuri[eidx+1:])
533 + filedict[myfile].append(
534 + cmirr.rstrip("/") + "/" + path)
535 # remove the mirrors we tried from the list of official mirrors
536 if cmirr.strip() in thirdpartymirrors[mirrorname]:
537 thirdpartymirrors[mirrorname].remove(cmirr)
538 @@ -3541,7 +3549,8 @@
539 shuffle(thirdpartymirrors[mirrorname])
540
541 for locmirr in thirdpartymirrors[mirrorname]:
542 - filedict[myfile].append(locmirr+"/"+myuri[eidx+1:])
543 + filedict[myfile].append(
544 + locmirr.rstrip("/") + "/" + path)
545
546 if not filedict[myfile]:
547 writemsg("No known mirror by the name: %s\n" % (mirrorname))
548 @@ -7110,7 +7119,7 @@
549 d.update(mydict)
550 try:
551 f = atomic_ofstream(filename)
552 - cPickle.dump(d, f, -1)
553 + pickle.dump(d, f, -1)
554 f.close()
555 portage.util.apply_secpass_permissions(filename, uid=uid, gid=portage_gid, mode=0664)
556 except (IOError, OSError), e:
557 @@ -7264,13 +7273,13 @@
558 def _load(self, filename):
559 try:
560 f = open(filename)
561 - mypickle = cPickle.Unpickler(f)
562 + mypickle = pickle.Unpickler(f)
563 mypickle.find_global = None
564 d = mypickle.load()
565 f.close()
566 del f
567 - except (IOError, OSError, EOFError, cPickle.UnpicklingError), e:
568 - if isinstance(e, cPickle.UnpicklingError):
569 + except (IOError, OSError, EOFError, pickle.UnpicklingError), e:
570 + if isinstance(e, pickle.UnpicklingError):
571 writemsg("!!! Error loading '%s': %s\n" % \
572 (filename, str(e)), noiselevel=-1)
573 del e
574
575 Copied: main/branches/prefix/pym/portage/_selinux.py (from rev 11544, main/trunk/pym/portage/_selinux.py)
576 ===================================================================
577 --- main/branches/prefix/pym/portage/_selinux.py (rev 0)
578 +++ main/branches/prefix/pym/portage/_selinux.py 2008-09-27 16:08:34 UTC (rev 11571)
579 @@ -0,0 +1,8 @@
580 +# Copyright 1999-2006 Gentoo Foundation
581 +# Distributed under the terms of the GNU General Public License v2
582 +# $Header: $
583 +
584 +import selinux
585 +from selinux import is_selinux_enabled
586 +from selinux_aux import setexec, secure_symlink, secure_rename, \
587 + secure_copy, secure_mkdir, getcontext, get_sid, get_lsid
588
589 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
590 ===================================================================
591 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2008-09-27 16:03:31 UTC (rev 11570)
592 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2008-09-27 16:08:34 UTC (rev 11571)
593 @@ -37,9 +37,9 @@
594 from itertools import izip
595
596 try:
597 - import cPickle
598 + import cPickle as pickle
599 except ImportError:
600 - import pickle as cPickle
601 + import pickle
602
603 class PreservedLibsRegistry(object):
604 """ This class handles the tracking of preserved library objects """
605 @@ -57,7 +57,7 @@
606 def load(self):
607 """ Reload the registry data from file """
608 try:
609 - self._data = cPickle.load(open(self._filename, "r"))
610 + self._data = pickle.load(open(self._filename, "r"))
611 except (EOFError, IOError), e:
612 if isinstance(e, EOFError) or e.errno == errno.ENOENT:
613 self._data = {}
614 @@ -74,7 +74,7 @@
615 return
616 try:
617 f = atomic_ofstream(self._filename)
618 - cPickle.dump(self._data, f)
619 + pickle.dump(self._data, f)
620 f.close()
621 except EnvironmentError, e:
622 if e.errno != PermissionDenied.errno:
623 @@ -1394,7 +1394,7 @@
624 del self._aux_cache["modified"]
625 try:
626 f = atomic_ofstream(self._aux_cache_filename)
627 - cPickle.dump(self._aux_cache, f, -1)
628 + pickle.dump(self._aux_cache, f, -1)
629 f.close()
630 apply_secpass_permissions(
631 self._aux_cache_filename, gid=portage_gid, mode=0644)
632 @@ -1412,13 +1412,13 @@
633 aux_cache = None
634 try:
635 f = open(self._aux_cache_filename)
636 - mypickle = cPickle.Unpickler(f)
637 + mypickle = pickle.Unpickler(f)
638 mypickle.find_global = None
639 aux_cache = mypickle.load()
640 f.close()
641 del f
642 - except (IOError, OSError, EOFError, cPickle.UnpicklingError), e:
643 - if isinstance(e, cPickle.UnpicklingError):
644 + except (IOError, OSError, EOFError, pickle.UnpicklingError), e:
645 + if isinstance(e, pickle.UnpicklingError):
646 writemsg("!!! Error loading '%s': %s\n" % \
647 (self._aux_cache_filename, str(e)), noiselevel=-1)
648 del e
649
650 Modified: main/branches/prefix/pym/portage/getbinpkg.py
651 ===================================================================
652 --- main/branches/prefix/pym/portage/getbinpkg.py 2008-09-27 16:03:31 UTC (rev 11570)
653 +++ main/branches/prefix/pym/portage/getbinpkg.py 2008-09-27 16:08:34 UTC (rev 11571)
654 @@ -16,9 +16,9 @@
655 from portage.const import CACHE_PATH
656
657 try:
658 - import cPickle
659 + import cPickle as pickle
660 except ImportError:
661 - import pickle as cPickle
662 + import pickle
663
664 try:
665 import ftplib
666 @@ -474,11 +474,11 @@
667 out = sys.stdout
668 try:
669 metadatafile = open(CACHE_PATH+"/remote_metadata.pickle")
670 - metadata = cPickle.load(metadatafile)
671 + metadata = pickle.load(metadatafile)
672 out.write("Loaded metadata pickle.\n")
673 out.flush()
674 metadatafile.close()
675 - except (cPickle.UnpicklingError, OSError, IOError, EOFError):
676 + except (pickle.UnpicklingError, OSError, IOError, EOFError):
677 metadata = {}
678 if baseurl not in metadata:
679 metadata[baseurl]={}
680 @@ -547,7 +547,7 @@
681 sys.stderr.flush()
682 mytempfile.close()
683 try:
684 - metadata[baseurl]["data"] = cPickle.loads(data)
685 + metadata[baseurl]["data"] = pickle.loads(data)
686 del data
687 metadata[baseurl]["indexname"] = mfile
688 metadata[baseurl]["timestamp"] = int(time.time())
689 @@ -563,7 +563,7 @@
690 sys.stderr.flush()
691 try:
692 metadatafile = open(CACHE_PATH+"/remote_metadata.pickle", "w+")
693 - cPickle.dump(metadata,metadatafile)
694 + pickle.dump(metadata,metadatafile)
695 metadatafile.close()
696 except SystemExit, e:
697 raise
698 @@ -653,11 +653,11 @@
699 if "modified" in metadata[baseurl] and metadata[baseurl]["modified"]:
700 metadata[baseurl]["timestamp"] = int(time.time())
701 metadatafile = open(CACHE_PATH+"/remote_metadata.pickle", "w+")
702 - cPickle.dump(metadata,metadatafile)
703 + pickle.dump(metadata,metadatafile)
704 metadatafile.close()
705 if makepickle:
706 metadatafile = open(makepickle, "w")
707 - cPickle.dump(metadata[baseurl]["data"],metadatafile)
708 + pickle.dump(metadata[baseurl]["data"],metadatafile)
709 metadatafile.close()
710 except SystemExit, e:
711 raise
712
713 Deleted: main/branches/prefix/pym/portage/selinux.py
714 ===================================================================
715 --- main/branches/prefix/pym/portage/selinux.py 2008-09-27 16:03:31 UTC (rev 11570)
716 +++ main/branches/prefix/pym/portage/selinux.py 2008-09-27 16:08:34 UTC (rev 11571)
717 @@ -1,8 +0,0 @@
718 -# Copyright 1999-2006 Gentoo Foundation
719 -# Distributed under the terms of the GNU General Public License v2
720 -# $Header: $
721 -
722 -import selinux
723 -from selinux import is_selinux_enabled
724 -from selinux_aux import setexec, secure_symlink, secure_rename, \
725 - secure_copy, secure_mkdir, getcontext, get_sid, get_lsid
726
727 Modified: main/branches/prefix/pym/portage/sets/dbapi.py
728 ===================================================================
729 --- main/branches/prefix/pym/portage/sets/dbapi.py 2008-09-27 16:03:31 UTC (rev 11570)
730 +++ main/branches/prefix/pym/portage/sets/dbapi.py 2008-09-27 16:08:34 UTC (rev 11571)
731 @@ -248,3 +248,34 @@
732 return rValue
733 multiBuilder = classmethod(multiBuilder)
734
735 +class AgeSet(EverythingSet):
736 + _operations = ["merge", "unmerge"]
737 +
738 + def __init__(self, vardb, mode="older", age=7):
739 + super(AgeSet, self).__init__(vardb)
740 + self._mode = mode
741 + self._age = age
742 +
743 + def _filter(self, atom):
744 + import time, os
745 +
746 + cpv = self._db.match(atom)[0]
747 + path = self._db.getpath(cpv, filename="COUNTER")
748 + age = (time.time() - os.stat(path).st_mtime) / (3600 * 24)
749 + if ((self._mode == "older" and age <= self._age) \
750 + or (self._mode == "newer" and age >= self._age)):
751 + return False
752 + else:
753 + return True
754 +
755 + def singleBuilder(cls, options, settings, trees):
756 + mode = options.get("mode", "older")
757 + if str(mode).lower() not in ["newer", "older"]:
758 + raise SetConfigError("invalid 'mode' value %s (use either 'newer' or 'older')" % mode)
759 + try:
760 + age = int(options.get("age", "7"))
761 + except ValueError, e:
762 + raise SetConfigError("value of option 'age' is not an integer")
763 + return AgeSet(vardb=trees["vartree"].dbapi, mode=mode, age=age)
764 +
765 + singleBuilder = classmethod(singleBuilder)
766
767 Modified: main/branches/prefix/pym/portage/util.py
768 ===================================================================
769 --- main/branches/prefix/pym/portage/util.py 2008-09-27 16:03:31 UTC (rev 11570)
770 +++ main/branches/prefix/pym/portage/util.py 2008-09-27 16:08:34 UTC (rev 11571)
771 @@ -18,9 +18,9 @@
772 from portage.const import EPREFIX, EPREFIX_LSTRIP
773
774 try:
775 - import cPickle
776 + import cPickle as pickle
777 except ImportError:
778 - import pickle as cPickle
779 + import pickle
780
781 try:
782 import cStringIO as StringIO
783 @@ -569,7 +569,7 @@
784 import os
785 try:
786 myf=open(filename,"w")
787 - cPickle.dump(data,myf,-1)
788 + pickle.dump(data,myf,-1)
789 myf.flush()
790 myf.close()
791 writemsg("Wrote pickle: "+str(filename)+"\n",1)
792 @@ -589,7 +589,7 @@
793 data = None
794 try:
795 myf = open(filename)
796 - mypickle = cPickle.Unpickler(myf)
797 + mypickle = pickle.Unpickler(myf)
798 mypickle.find_global = None
799 data = mypickle.load()
800 myf.close()