From: Zac Medico Date: Wed, 21 Nov 2007 08:48:12 +0000 (-0000) Subject: Generate an eerror elog message when an ebuild prerm or X-Git-Tag: v2.1.4~249 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e1a3306d601b5ebcc5e50a5f2c190680a29ffb9e;p=portage.git Generate an eerror elog message when an ebuild prerm or postrm phase fails. (trunk r8577) svn path=/main/branches/2.1.2/; revision=8580 --- diff --git a/bin/emerge b/bin/emerge index bf1f32cd3..bb56f5e5b 100755 --- a/bin/emerge +++ b/bin/emerge @@ -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"): diff --git a/pym/portage.py b/pym/portage.py index 8081737f1..7964e1cdd 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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: