When a removal phase fails, tell the user where the ebuild is and advise them that...
authorZac Medico <zmedico@gentoo.org>
Thu, 21 Dec 2006 00:32:10 +0000 (00:32 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 21 Dec 2006 00:32:10 +0000 (00:32 -0000)
svn path=/main/trunk/; revision=5340

bin/emerge
pym/portage.py

index 744db7b9e51e5ef150162a54f0d69307f28d9a31..8d310da480719752ac7de95f16128b0f59aeb68d 100755 (executable)
@@ -3230,11 +3230,32 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
                                vartree=vartree, ldpath_mtimes=ldpath_mtimes)
                        if retval != os.EX_OK:
                                emergelog(xterm_titles, " !!! unmerge FAILURE: "+y)
+                               ebuild = vartree.dbapi.findname(y)
+                               show_unmerge_failure_message(y, ebuild, retval)
+                               sys.exit(retval)
                        else:
                                clean_world(vartree.dbapi, y)
                                emergelog(xterm_titles, " >>> unmerge success: "+y)
        return 1
 
+def show_unmerge_failure_message(pkg, ebuild, retval):
+
+       from formatter import AbstractFormatter, DumbWriter
+       f = AbstractFormatter(DumbWriter(maxcol=72))
+
+       msg = []
+       msg.append("A removal phase of the '%s' package " % pkg)
+       msg.append("has failed with exit value %s.  " % retval)
+       msg.append("The problem occurred while executing ")
+       msg.append("the ebuild located at '%s'.  " % ebuild)
+       msg.append("If necessary, manually remove the ebuild " )
+       msg.append("in order to skip the execution of removal phases.")
+
+       print
+       for x in msg:
+               f.add_flowing_data(x)
+       f.end_paragraph(1)
+
 def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
 
        print
index 3de43de21942b60c2db664dee91a9eaf0f8e6fa6..40cb232465ccba7b60827a4808d2dc9a6622980d 100644 (file)
@@ -3581,11 +3581,12 @@ def unmerge(cat, pkg, myroot, mysettings, mytrimworld=1, vartree=None, ldpath_mt
        try:
                mylink.lockdb()
                if mylink.exists():
-                       mylink.unmerge(trimworld=mytrimworld, cleanup=1,
+                       retval = mylink.unmerge(trimworld=mytrimworld, cleanup=1,
                                ldpath_mtimes=ldpath_mtimes)
-                       mylink.delete()
-                       return 0
-               return 1
+                       if retval == os.EX_OK:
+                               mylink.delete()
+                       return retval
+               return os.EX_OK
        finally:
                mylink.unlockdb()
 
@@ -6380,7 +6381,7 @@ class dblink:
                                # XXX: Decide how to handle failures here.
                                if retval != os.EX_OK:
                                        writemsg("!!! FAILED prerm: %s\n" % retval, noiselevel=-1)
-                                       sys.exit(123)
+                                       return retval
 
                        self._unmerge_pkgfiles(pkgfiles)
 
@@ -6395,7 +6396,7 @@ class dblink:
                                # XXX: Decide how to handle failures here.
                                if retval != os.EX_OK:
                                        writemsg("!!! FAILED postrm: %s\n" % retval, noiselevel=-1)
-                                       sys.exit(123)
+                                       return retval
                                doebuild(myebuildpath, "cleanrm", self.myroot, self.settings,
                                        tree="vartree", mydbapi=self.vartree.dbapi,
                                        vartree=self.vartree)
@@ -6418,6 +6419,7 @@ class dblink:
                                        portage_locks.unlockdir(catdir_lock)
                env_update(target_root=self.myroot, prev_mtimes=ldpath_mtimes,
                        contents=contents)
+               return os.EX_OK
 
        def _unmerge_pkgfiles(self, pkgfiles):