summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>2011-03-09 03:57:23 +0100
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>2011-03-09 03:57:23 +0100
commitcab19378be406d18a80114d00007e12b3310586d (patch)
tree0821a4b74e258234c108db622780bff21cf16ad9
parentdee9b51ee32e9d49794f737d6e3d014ec8a3d683 (diff)
downloadportage-cab19378be406d18a80114d00007e12b3310586d.tar.gz
portage-cab19378be406d18a80114d00007e12b3310586d.tar.bz2
portage-cab19378be406d18a80114d00007e12b3310586d.zip
Bug #357009: Disallow uninstallation of currently used Python interpreter.
-rw-r--r--pym/_emerge/unmerge.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index df95f699a..a6a330cd3 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -7,6 +7,7 @@ import logging
import sys
import textwrap
import portage
+import portage.dbapi.vartree
from portage import os
from portage.output import bold, colorize, darkgreen, green
from portage._sets import SETPREFIX
@@ -314,19 +315,26 @@ def unmerge(root_config, myopts, unmerge_action,
# 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
+ if unmerge_action != "clean" and root_config.root == "/":
+ skip_pkg = False
+ if 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,)
+ skip_pkg = True
+ elif portage.dbapi.vartree.dblink(pkg.category, pkg.pf,
+ settings=settings, treetype="vartree", vartree=vartree,
+ scheduler=scheduler).isowner(portage._python_interpreter):
+ msg = ("Not unmerging package %s since there is no valid reason "
+ "for Portage to unmerge currently used Python interpreter.") % (pkg.cpv,)
+ skip_pkg = True
+ if skip_pkg:
+ 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: