mergecount += 1
pkg = x
metadata = pkg.metadata
+
if pkg.installed:
if not (buildpkgonly or fetchonly or pretend):
- unmerge(root_config.settings, self.myopts,
- root_config.trees["vartree"], "unmerge",
- [pkg.cpv], mtimedb["ldpath"], clean_world=0)
+ try:
+ unmerge(root_config.settings, self.myopts,
+ root_config.trees["vartree"], "unmerge",
+ [pkg.cpv], mtimedb["ldpath"], clean_world=0,
+ raise_on_error=1)
+ except UninstallFailure, e:
+ return e.status
continue
if x[0]=="blocks":
sys.exit(0)
return os.EX_OK
-def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
- ldpath_mtimes, autoclean=0, clean_world=1, ordered=0):
+class UninstallFailure(portage_exception.PortageException):
+ """
+ An instance of this class is raised by unmerge() when
+ an uninstallation fails.
+ """
+ status = 1
+ def __init__(self, *pargs):
+ portage_exception.PortageException.__init__(self, pargs)
+ if pargs:
+ self.status = pargs[0]
+
+def unmerge(settings, myopts, vartree, unmerge_action,
+ unmerge_files, ldpath_mtimes, autoclean=0,
+ clean_world=1, ordered=0, raise_on_error=0):
candidate_catpkgs=[]
global_unmerge=0
xterm_titles = "notitles" not in settings.features
vartree=vartree, ldpath_mtimes=ldpath_mtimes)
if retval != os.EX_OK:
emergelog(xterm_titles, " !!! unmerge FAILURE: "+y)
+ if raise_on_error:
+ raise UninstallFailure(retval)
sys.exit(retval)
else:
if clean_world: