diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-05-09 03:41:41 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-05-09 03:41:41 +0000 |
commit | d69b84db1e14cb16e1f038636120c73bab56e45a (patch) | |
tree | 40ab5d337634f4b0b7a211a0fc43de690e31d2f0 | |
parent | ae3bc17ac0f6007ead53196ece48c673dfe46350 (diff) | |
download | portage-d69b84db1e14cb16e1f038636120c73bab56e45a.tar.gz portage-d69b84db1e14cb16e1f038636120c73bab56e45a.tar.bz2 portage-d69b84db1e14cb16e1f038636120c73bab56e45a.zip |
If an uninstall task fails inside MergeTask.merge(), use an UninstallFailure
exception to handle it instead of allowing unmerge() to call exit().
svn path=/main/trunk/; revision=10262
-rw-r--r-- | pym/_emerge/__init__.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index ca0126f34..06d1fab26 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -5703,10 +5703,15 @@ class MergeTask(object): mergecount += 1 pkg = x metadata = pkg.metadata + if pkg.installed: if not (buildpkgonly or fetchonly or pretend): - unmerge(root_config, self.myopts, "unmerge", - [pkg.cpv], mtimedb["ldpath"], clean_world=0) + try: + unmerge(root_config, self.myopts, "unmerge", + [pkg.cpv], mtimedb["ldpath"], clean_world=0, + raise_on_error=1) + except UninstallFailure, e: + return e.status continue if x[0]=="blocks": @@ -6028,8 +6033,20 @@ class MergeTask(object): sys.exit(0) return os.EX_OK +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(root_config, myopts, unmerge_action, - unmerge_files, ldpath_mtimes, autoclean=0, clean_world=1, ordered=0): + unmerge_files, ldpath_mtimes, autoclean=0, + clean_world=1, ordered=0, raise_on_error=0): settings = root_config.settings sets = root_config.sets vartree = root_config.trees["vartree"] @@ -6407,6 +6424,8 @@ def unmerge(root_config, myopts, unmerge_action, 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: |