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

svn path=/main/trunk/; revision=8577

pym/_emerge/__init__.py
pym/portage/dbapi/vartree.py

index d5c1babdbe954d56f74dd674e6b318dc84dd401b..50cca0513cb477aa48d919a306ef46ce80679043 100644 (file)
@@ -4806,33 +4806,12 @@ def unmerge(root_config, myopts, unmerge_action,
                                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:
                                sets["world"].cleanPackage(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 94f00a8b9a4fca013780e07bc0e51f832a8455b4..89753f39c63b57e10f24c435997eccd1c724ce2b 100644 (file)
@@ -1071,6 +1071,7 @@ class dblink(object):
                # 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"):
@@ -1127,6 +1128,7 @@ class dblink(object):
                        self.vartree.dbapi.plib_registry.unregister(self.mycpv, self.settings["SLOT"], self.settings["COUNTER"])
 
                        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)
@@ -1143,6 +1145,19 @@ class dblink(object):
                        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 portage.elog.messages import eerror
+                                                       from textwrap import wrap
+                                                       for l in wrap(msg, 72):
+                                                               eerror(l, phase=ebuild_phase, key=self.mycpv)
+
                                                # process logs created during pre/postrm
                                                elog_process(self.mycpv, self.settings, phasefilter=filter_unmergephases)
                                                if retval == os.EX_OK: