Generate an eerror elog message when an ebuild prerm or
authorZac Medico <zmedico@gentoo.org>
Wed, 21 Nov 2007 08:48:12 +0000 (08:48 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 21 Nov 2007 08:48:12 +0000 (08:48 -0000)
postrm phase fails. (trunk r8577)

svn path=/main/branches/2.1.2/; revision=8580

bin/emerge
pym/portage.py

index bf1f32cd357724b1b12b88dec93398da1d6a9927..bb56f5e5b1256f065ba61fc77e87222498216652 100755 (executable)
@@ -4391,33 +4391,12 @@ 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(sys.stderr, 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.")
-
-       f.end_paragraph(1)
-       for x in msg:
-               f.add_flowing_data(x)
-       f.end_paragraph(1)
-       f.writer.flush()
-
 def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
 
        if os.path.exists("/usr/bin/install-info"):
index 8081737f1d70fe9eb474a5b96e419e8bdbafa385..7964e1cddbc8aebba3542e58531eddb5d0656cc1 100644 (file)
@@ -7672,6 +7672,7 @@ class dblink:
                # Now, don't assume that the name of the ebuild is the same as the
                # name of the dir; the package may have been moved.
                myebuildpath = None
+               ebuild_phase = "prerm"
                mystuff = listdir(self.dbdir, EmptyOnError=1)
                for x in mystuff:
                        if x.endswith(".ebuild"):
@@ -7725,6 +7726,7 @@ class dblink:
                        self._unmerge_pkgfiles(pkgfiles, others_in_slot)
 
                        if myebuildpath:
+                               ebuild_phase = "postrm"
                                retval = doebuild(myebuildpath, "postrm", self.myroot,
                                         self.settings, use_cache=0, tree="vartree",
                                         mydbapi=self.vartree.dbapi, vartree=self.vartree)
@@ -7738,6 +7740,22 @@ class dblink:
                        if builddir_lock:
                                try:
                                        if myebuildpath:
+                                               if retval != os.EX_OK:
+                                                       msg = ("The '%s' " % ebuild_phase) + \
+                                                       ("phase of the '%s' package " % self.mycpv) + \
+                                                       ("has failed with exit value %s. " % retval) + \
+                                                       "The problem occurred while executing " + \
+                                                       ("the ebuild located at '%s'. " % myebuildpath) + \
+                                                       "If necessary, manually remove the ebuild " + \
+                                                       "in order to skip the execution of removal phases."
+                                                       from textwrap import wrap
+                                                       cmd = "source '%s/isolated-functions.sh' ; " % \
+                                                               PORTAGE_BIN_PATH
+                                                       for l in wrap(msg, 72):
+                                                               cmd += "eerror \"%s\" ; " % l
+                                                       portage_exec.spawn(["bash", "-c", cmd],
+                                                               env=self.settings.environ())
+
                                                # process logs created during pre/postrm
                                                elog_process(self.mycpv, self.settings)
                                                if retval == os.EX_OK: