summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2015-05-03 14:15:01 -0700
committerZac Medico <zmedico@gentoo.org>2015-05-03 23:15:43 -0700
commit601fc103087bcecf46d34d26aad5a939a1cb087c (patch)
tree008e1c9cc2b5e2d76c048f86f343c679fcb24b4b
parentemake: refresh comments/docs/style (diff)
downloadportage-601fc103087bcecf46d34d26aad5a939a1cb087c.tar.gz
portage-601fc103087bcecf46d34d26aad5a939a1cb087c.tar.bz2
portage-601fc103087bcecf46d34d26aad5a939a1cb087c.zip
Scheduler: increase visiblity of postinst failures (bug 547778)
This makes postinst failures behave more like "real" failures in terms of output and the final emerge return code. However, in other respects, these packages will be treated as successful installations. This means that they will not cause emerge to immediately exit, and they will not trigger recalculation of dependencies when --keep-going is enabled. X-Gentoo-Bug: 547778 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=547778 Acked-by: Brian Dolbec <dolsen@gentoo.org>
-rw-r--r--pym/_emerge/EbuildMerge.py3
-rw-r--r--pym/_emerge/PackageMerge.py9
-rw-r--r--pym/_emerge/Scheduler.py20
-rw-r--r--pym/portage/const.py2
-rw-r--r--pym/portage/dbapi/_MergeProcess.py9
-rw-r--r--pym/portage/dbapi/vartree.py6
6 files changed, 42 insertions, 7 deletions
diff --git a/pym/_emerge/EbuildMerge.py b/pym/_emerge/EbuildMerge.py
index df0778c6c..07d9134c3 100644
--- a/pym/_emerge/EbuildMerge.py
+++ b/pym/_emerge/EbuildMerge.py
@@ -8,7 +8,7 @@ from portage.dbapi._MergeProcess import MergeProcess
class EbuildMerge(CompositeTask):
__slots__ = ("exit_hook", "find_blockers", "logger", "ldpath_mtimes",
- "pkg", "pkg_count", "pkg_path", "pretend",
+ "pkg", "pkg_count", "pkg_path", "postinst_failure", "pretend",
"settings", "tree", "world_atom")
def _start(self):
@@ -39,6 +39,7 @@ class EbuildMerge(CompositeTask):
self.wait()
return
+ self.postinst_failure = merge_task.postinst_failure
pkg = self.pkg
self.world_atom(pkg)
pkg_count = self.pkg_count
diff --git a/pym/_emerge/PackageMerge.py b/pym/_emerge/PackageMerge.py
index fa2102fe1..1e7b58ba3 100644
--- a/pym/_emerge/PackageMerge.py
+++ b/pym/_emerge/PackageMerge.py
@@ -5,7 +5,7 @@ from _emerge.CompositeTask import CompositeTask
from portage.dep import _repo_separator
from portage.output import colorize
class PackageMerge(CompositeTask):
- __slots__ = ("merge",)
+ __slots__ = ("merge", "postinst_failure")
def _start(self):
@@ -41,4 +41,9 @@ class PackageMerge(CompositeTask):
self.merge.statusMessage(msg)
task = self.merge.create_install_task()
- self._start_task(task, self._default_final_exit)
+ self._start_task(task, self._install_exit)
+
+ def _install_exit(self, task):
+ self.postinst_failure = getattr(task, 'postinst_failure', None)
+ self._final_exit(task)
+ self.wait()
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 6b39e3b30..13abc92c4 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -115,7 +115,8 @@ class Scheduler(PollScheduler):
emergelog(self.xterm_titles, *pargs, **kwargs)
class _failed_pkg(SlotObject):
- __slots__ = ("build_dir", "build_log", "pkg", "returncode")
+ __slots__ = ("build_dir", "build_log", "pkg",
+ "postinst_failure", "returncode")
class _ConfigPool(object):
"""Interface for a task to temporarily allocate a config
@@ -1155,10 +1156,10 @@ class Scheduler(PollScheduler):
if len(self._failed_pkgs_all) > 1:
msg = "The following %d packages have " % \
len(self._failed_pkgs_all) + \
- "failed to build or install:"
+ "failed to build, install, or execute postinst:"
else:
msg = "The following package has " + \
- "failed to build or install:"
+ "failed to build, install, or execute postinst:"
printer.eerror("")
for line in textwrap.wrap(msg, 72):
@@ -1168,6 +1169,8 @@ class Scheduler(PollScheduler):
# Use unicode_literals to force unicode format string so
# that Package.__unicode__() is called in python2.
msg = " %s" % (failed_pkg.pkg,)
+ if failed_pkg.postinst_failure:
+ msg += " (postinst failed)"
log_path = self._locate_failure_log(failed_pkg)
if log_path is not None:
msg += ", Log file:"
@@ -1289,6 +1292,17 @@ class Scheduler(PollScheduler):
self._status_display.failed = len(self._failed_pkgs)
return
+ if merge.postinst_failure:
+ # Append directly to _failed_pkgs_all for non-critical errors.
+ self._failed_pkgs_all.append(self._failed_pkg(
+ build_dir=merge.merge.settings.get("PORTAGE_BUILDDIR"),
+ build_log=merge.merge.settings.get("PORTAGE_LOG_FILE"),
+ pkg=pkg,
+ postinst_failure=True,
+ returncode=merge.returncode))
+ self._failed_pkg_msg(self._failed_pkgs_all[-1],
+ "execute postinst for", "for")
+
self._task_complete(pkg)
pkg_to_replace = merge.merge.pkg_to_replace
if pkg_to_replace is not None:
diff --git a/pym/portage/const.py b/pym/portage/const.py
index c7ecda2c3..6c1201dc5 100644
--- a/pym/portage/const.py
+++ b/pym/portage/const.py
@@ -277,6 +277,8 @@ TIMESTAMP_FORMAT = "%a, %d %b %Y %H:%M:%S +0000" # to be used with time.gmtime()
# Top-level names of Python packages installed by Portage.
PORTAGE_PYM_PACKAGES = ("_emerge", "portage", "repoman")
+RETURNCODE_POSTINST_FAILURE = 5
+
# ===========================================================================
# END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANT
# ===========================================================================
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
index 956dbb9e6..35591af16 100644
--- a/pym/portage/dbapi/_MergeProcess.py
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -23,7 +23,8 @@ class MergeProcess(ForkProcess):
__slots__ = ('mycat', 'mypkg', 'settings', 'treetype',
'vartree', 'blockers', 'pkgloc', 'infloc', 'myebuild',
- 'mydbapi', 'prev_mtimes', 'unmerge', '_elog_reader_fd', '_elog_reg_id',
+ 'mydbapi', 'postinst_failure', 'prev_mtimes', 'unmerge',
+ '_elog_reader_fd', '_elog_reg_id',
'_buf', '_elog_keys', '_locked_vdb')
def _start(self):
@@ -250,6 +251,12 @@ class MergeProcess(ForkProcess):
# in order to avoid a race condition.
os._exit(1)
+ def _set_returncode(self, wait_retval):
+ ForkProcess._set_returncode(self, wait_retval)
+ if self.returncode == portage.const.RETURNCODE_POSTINST_FAILURE:
+ self.postinst_failure = True
+ self.returncode = os.EX_OK
+
def _unregister(self):
"""
Unregister from the scheduler and close open files.
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index fca84d1b1..a2fb325c3 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1577,6 +1577,7 @@ class dblink(object):
self._hash_key = (self._eroot, self.mycpv)
self._protect_obj = None
self._pipe = pipe
+ self._postinst_failure = False
# When necessary, this attribute is modified for
# compliance with RESTRICT=preserve-libs.
@@ -4376,6 +4377,7 @@ class dblink(object):
if a != os.EX_OK:
# It's stupid to bail out here, so keep going regardless of
# phase return code.
+ self._postinst_failure = True
self._elog("eerror", "postinst", [
_("FAILED postinst: %s") % (a,),
])
@@ -5042,6 +5044,10 @@ class dblink(object):
self.vartree.dbapi._bump_mtime(self.mycpv)
if not parallel_install:
self.unlockdb()
+
+ if retval == os.EX_OK and self._postinst_failure:
+ retval = portage.const.RETURNCODE_POSTINST_FAILURE
+
return retval
def getstring(self,name):