* [gentoo-portage-dev] [PATCH] Scheduler: increase visiblity of postinst failures (bug 547778)
@ 2015-05-03 21:40 Zac Medico
2015-05-04 3:03 ` Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2015-05-03 21:40 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
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
---
pym/_emerge/EbuildMerge.py | 3 ++-
pym/_emerge/PackageMerge.py | 9 +++++++--
pym/_emerge/Scheduler.py | 20 +++++++++++++++++---
pym/portage/const.py | 2 ++
pym/portage/dbapi/_MergeProcess.py | 9 ++++++++-
pym/portage/dbapi/vartree.py | 6 ++++++
6 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/pym/_emerge/EbuildMerge.py b/pym/_emerge/EbuildMerge.py
index df0778c..07d9134 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 fa2102f..1e7b58b 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 6b39e3b..13abc92 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 c7ecda2..6c1201d 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 956dbb9..35591af 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 fca84d1..a2fb325 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):
--
2.3.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] Scheduler: increase visiblity of postinst failures (bug 547778)
2015-05-03 21:40 [gentoo-portage-dev] [PATCH] Scheduler: increase visiblity of postinst failures (bug 547778) Zac Medico
@ 2015-05-04 3:03 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-05-04 3:03 UTC (permalink / raw
To: gentoo-portage-dev
On Sun, 3 May 2015 14:40:07 -0700
Zac Medico <zmedico@gentoo.org> wrote:
> 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
> ---
> pym/_emerge/EbuildMerge.py | 3 ++-
> pym/_emerge/PackageMerge.py | 9 +++++++--
> pym/_emerge/Scheduler.py | 20 +++++++++++++++++---
> pym/portage/const.py | 2 ++
> pym/portage/dbapi/_MergeProcess.py | 9 ++++++++-
> pym/portage/dbapi/vartree.py | 6 ++++++
> 6 files changed, 42 insertions(+), 7 deletions(-)
>
patch looks good :)
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-04 3:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-03 21:40 [gentoo-portage-dev] [PATCH] Scheduler: increase visiblity of postinst failures (bug 547778) Zac Medico
2015-05-04 3:03 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox