summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-10-30 22:18:55 +0000
committerZac Medico <zmedico@gentoo.org>2008-10-30 22:18:55 +0000
commit62781abb763a380a32b1841311a0ceed4430569d (patch)
tree13ae2da95121e3a440962f296c9648c9a4361739
parentd366c229c9542ed328c158a4ccb22e065ed22930 (diff)
downloadportage-62781abb763a380a32b1841311a0ceed4430569d.tar.gz
portage-62781abb763a380a32b1841311a0ceed4430569d.tar.bz2
portage-62781abb763a380a32b1841311a0ceed4430569d.zip
Bug #244975 - Don't allow the user to make portage unmerge itself since
there's never any valid reason to do so. svn path=/main/trunk/; revision=11756
-rw-r--r--pym/_emerge/__init__.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 8e2df4d58..bbfd07397 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -10489,7 +10489,7 @@ def unmerge(root_config, myopts, unmerge_action,
candidate_catpkgs=[]
global_unmerge=0
xterm_titles = "notitles" not in settings.features
-
+ out = portage.output.EOutput()
pkg_cache = {}
db_keys = list(vartree.dbapi._aux_cache_keys)
@@ -10754,6 +10754,21 @@ def unmerge(root_config, myopts, unmerge_action,
# It could have been uninstalled
# by a concurrent process.
continue
+
+ if unmerge_action != "clean" and \
+ root_config.root == "/" and \
+ portage.match_from_list(
+ portage.const.PORTAGE_PACKAGE_ATOM, [pkg]):
+ msg = ("Not unmerging package %s since there is no valid " + \
+ "reason for portage to unmerge itself.") % (pkg.cpv,)
+ for line in textwrap.wrap(msg, 75):
+ out.eerror(line)
+ # adjust pkgmap so the display output is correct
+ pkgmap[cp]["selected"].remove(cpv)
+ all_selected.remove(cpv)
+ pkgmap[cp]["protected"].add(cpv)
+ continue
+
parents = []
for s in installed_sets:
# skip sets that the user requested to unmerge, and skip world
@@ -10812,10 +10827,18 @@ def unmerge(root_config, myopts, unmerge_action,
print " %s\n" % ", ".join(parents)
# adjust pkgmap so the display output is correct
pkgmap[cp]["selected"].remove(cpv)
+ all_selected.remove(cpv)
pkgmap[cp]["protected"].add(cpv)
del installed_sets
+ numselected = len(all_selected)
+ if not numselected:
+ writemsg_level(
+ "\n>>> No packages selected for removal by " + \
+ unmerge_action + "\n")
+ return 0
+
# Unmerge order only matters in some cases
if not ordered:
unordered = {}