From 26b08c85ebfdefd7ab1fdb547a562808efba67c0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 21 Nov 2007 08:26:19 +0000 Subject: Generate an eerror elog message when an ebuild prerm or postrm phase fails. svn path=/main/trunk/; revision=8577 --- pym/_emerge/__init__.py | 21 --------------------- pym/portage/dbapi/vartree.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 21 deletions(-) (limited to 'pym') diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index d5c1babdb..50cca0513 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -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"): diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 94f00a8b9..89753f39c 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -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: -- cgit v1.2.3-1-g7c22