summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-07-18 06:26:44 +0000
committerZac Medico <zmedico@gentoo.org>2007-07-18 06:26:44 +0000
commit9c76be0fb2a7a75fd66e44ea57aedfe3952bb628 (patch)
tree5de2076c45fd5893a112ed9e3b902e324c59fe99
parent9676a2aa192bf640d70fe4a9aff6005996659057 (diff)
downloadportage-9c76be0fb2a7a75fd66e44ea57aedfe3952bb628.tar.gz
portage-9c76be0fb2a7a75fd66e44ea57aedfe3952bb628.tar.bz2
portage-9c76be0fb2a7a75fd66e44ea57aedfe3952bb628.zip
Allow atoms to be specified for --depclean so that it can be used to safely unmerge packages if nothing depends on them.
svn path=/main/trunk/; revision=7306
-rw-r--r--pym/emerge/__init__.py43
1 files changed, 38 insertions, 5 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index a5fc25543..a66244e65 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -5258,7 +5258,7 @@ def action_depclean(settings, trees, ldpath_mtimes,
msg.append("consequence, it is often necessary to run\n")
msg.append(good("`emerge --update --newuse --deep world`") + " prior to depclean.\n")
- if action == "depclean":
+ if action == "depclean" and "--quiet" not in myopts and not myfiles:
portage.writemsg_stdout("\n")
for x in msg:
portage.writemsg_stdout(colorize("BAD", "*** WARNING *** ") + x)
@@ -5296,7 +5296,7 @@ def action_depclean(settings, trees, ldpath_mtimes,
if action == "depclean":
emergelog(xterm_titles, " >>> depclean")
- elif action == "prune":
+ if myfiles:
for x in myfiles:
if not is_valid_package_atom(x):
portage.writemsg("!!! '%s' is not a valid package atom.\n" % x,
@@ -5343,6 +5343,26 @@ def action_depclean(settings, trees, ldpath_mtimes,
if not atom.startswith("!") and priority == hard:
unresolveable.setdefault(atom, []).append(parent)
continue
+ if action == "depclean" and parent == "world" and myfiles:
+ # Filter out packages given as arguments since the user wants
+ # to remove those.
+ filtered_pkgs = []
+ for pkg in pkgs:
+ metadata = dict(izip(metadata_keys,
+ vardb.aux_get(pkg, metadata_keys)))
+ arg_atom = None
+ try:
+ arg_atom = args_set.findAtomForPackage(pkg, metadata)
+ except portage.exception.InvalidDependString, e:
+ file_path = os.path.join(myroot, VDB_PATH, pkg, "PROVIDE")
+ portage.writemsg("\n\nInvalid PROVIDE: %s\n" % str(s),
+ noiselevel=-1)
+ portage.writemsg("See '%s'\n" % file_path,
+ noiselevel=-1)
+ del e
+ if not arg_atom:
+ filtered_pkgs.append(pkg)
+ pkgs = filtered_pkgs
prune_this = False
if action == "prune":
for pkg in pkgs:
@@ -5439,9 +5459,22 @@ def action_depclean(settings, trees, ldpath_mtimes,
cleanlist = []
if action == "depclean":
- for pkg in vardb.cpv_all():
- if not fakedb.cpv_exists(pkg):
- cleanlist.append(pkg)
+ if myfiles:
+ for pkg in vardb.cpv_all():
+ metadata = dict(izip(metadata_keys,
+ vardb.aux_get(pkg, metadata_keys)))
+ arg_atom = None
+ try:
+ arg_atom = args_set.findAtomForPackage(pkg, metadata)
+ except portage.exception.InvalidDependString:
+ # this error has already been displayed by now
+ continue
+ if arg_atom and not fakedb.cpv_exists(pkg):
+ cleanlist.append(pkg)
+ else:
+ for pkg in vardb.cpv_all():
+ if not fakedb.cpv_exists(pkg):
+ cleanlist.append(pkg)
elif action == "prune":
for atom in args_set:
for pkg in vardb.match(atom):