unmerge: fix return code for bug #409647
authorZac Medico <zmedico@gentoo.org>
Mon, 26 Mar 2012 03:49:47 +0000 (20:49 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 26 Mar 2012 03:53:40 +0000 (20:53 -0700)
pym/_emerge/actions.py
pym/_emerge/unmerge.py

index 0fb49442a5a5c646add72fbcf6933b037a2bc535..afb62bbc68bf4ee73b74a322e3524074ccbab81c 100644 (file)
@@ -586,12 +586,9 @@ def action_depclean(settings, trees, ldpath_mtimes,
                return rval
 
        if cleanlist:
-               if unmerge(root_config, myopts, "unmerge",
+               rval = unmerge(root_config, myopts, "unmerge",
                        cleanlist, ldpath_mtimes, ordered=ordered,
-                       scheduler=scheduler):
-                       rval = os.EX_OK
-               else:
-                       rval = 1
+                       scheduler=scheduler)
 
        if action == "prune":
                return rval
@@ -2674,10 +2671,9 @@ def action_uninstall(settings, trees, ldpath_mtimes,
                (action == 'prune' and "--nodeps" in opts):
                # When given a list of atoms, unmerge them in the order given.
                ordered = action == 'unmerge'
-               unmerge(trees[settings['EROOT']]['root_config'], opts, action,
+               rval = unmerge(trees[settings['EROOT']]['root_config'], opts, action,
                        valid_atoms, ldpath_mtimes, ordered=ordered,
                        scheduler=sched._sched_iface)
-               rval = os.EX_OK
        else:
                rval = action_depclean(settings, trees, ldpath_mtimes,
                        opts, action, valid_atoms, spinner, scheduler=sched._sched_iface)
index c76afdf738f54ba820a8b6d8539d72e0ce354358..0acdf998c60e012aec2ff792dc424755fff408bd 100644 (file)
@@ -1,9 +1,10 @@
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
 
 import logging
+import signal
 import sys
 import textwrap
 import portage
@@ -503,7 +504,8 @@ def unmerge(root_config, myopts, unmerge_action,
        clean_world=1, clean_delay=1, ordered=0, raise_on_error=0,
        scheduler=None, writemsg_level=portage.util.writemsg_level):
        """
-       Returns 1 if successful, otherwise 0.
+       Returns os.EX_OK if no errors occur, 1 if an error occurs, and
+       130 if interrupted due to a 'no' answer for --ask.
        """
 
        if clean_world:
@@ -515,7 +517,7 @@ def unmerge(root_config, myopts, unmerge_action,
                writemsg_level=writemsg_level)
 
        if rval != os.EX_OK:
-               return 0
+               return rval
 
        enter_invalid = '--ask-enter-invalid' in myopts
        vartree = root_config.trees["vartree"]
@@ -526,7 +528,7 @@ def unmerge(root_config, myopts, unmerge_action,
 
        if "--pretend" in myopts:
                #we're done... return
-               return 1
+               return os.EX_OK
        if "--ask" in myopts:
                if userquery("Would you like to unmerge these packages?",
                        enter_invalid) == "No":
@@ -535,7 +537,7 @@ def unmerge(root_config, myopts, unmerge_action,
                        print()
                        print("Quitting.")
                        print()
-                       return 0
+                       return 128 + signal.SIGINT
        #the real unmerging begins, after a short delay....
        if clean_delay and not autoclean:
                countdown(int(settings["CLEAN_DELAY"]), ">>> Unmerging")
@@ -574,5 +576,5 @@ def unmerge(root_config, myopts, unmerge_action,
                        sets["selected"].remove(SETPREFIX + s)
                sets["selected"].unlock()
 
-       return 1
+       return os.EX_OK