summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-08-14 20:28:33 +0000
committerZac Medico <zmedico@gentoo.org>2008-08-14 20:28:33 +0000
commitef917ae144197e5097a5b3e4faadddaa604d05d2 (patch)
treeb29c7932d76c4d96abfeb9cd08e6882acc4ff733
parent6ce970a6a2462fcc07d4b0b2551ffa0c7dd9b338 (diff)
downloadportage-ef917ae144197e5097a5b3e4faadddaa604d05d2.tar.gz
portage-ef917ae144197e5097a5b3e4faadddaa604d05d2.tar.bz2
portage-ef917ae144197e5097a5b3e4faadddaa604d05d2.zip
When a build fails, generate a status message showing which package
failed and the path of the relevant log file if available. Thanks to _neuron_ for the suggestion. Here is some sample output: >>> Emerging (1 of 1) foo-bar/baz-1.0 >>> Failed to emerge foo-bar/baz-1.0, Log file: >>> '/var/log/portage/foo-bar:baz-1.0:20080814-202327.log' svn path=/main/trunk/; revision=11411
-rw-r--r--pym/_emerge/__init__.py64
1 files changed, 46 insertions, 18 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 9bc06db22..a900dbb61 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -9428,27 +9428,12 @@ class Scheduler(PollScheduler):
log_paths = [failed_pkg.build_log]
- if not (build_dir and os.path.isdir(build_dir)):
- log_paths.append(failed_pkg.fetch_log)
-
- for log_path in log_paths:
- if not log_path:
- continue
-
- try:
- log_size = os.stat(log_path).st_size
- except OSError:
- continue
-
- if log_size == 0:
- continue
-
+ log_path = self._locate_failure_log(failed_pkg)
+ if log_path is not None:
try:
log_file = open(log_path, 'rb')
except IOError:
- continue
-
- break
+ pass
if log_file is not None:
try:
@@ -9505,6 +9490,32 @@ class Scheduler(PollScheduler):
self._failed_pkgs_die_msgs.append(
(mysettings, key, errors))
+ def _locate_failure_log(self, failed_pkg):
+
+ build_dir = failed_pkg.build_dir
+ log_file = None
+
+ log_paths = [failed_pkg.build_log]
+
+ if not (build_dir and os.path.isdir(build_dir)):
+ log_paths.append(failed_pkg.fetch_log)
+
+ for log_path in log_paths:
+ if not log_path:
+ continue
+
+ try:
+ log_size = os.stat(log_path).st_size
+ except OSError:
+ continue
+
+ if log_size == 0:
+ continue
+
+ return log_path
+
+ return None
+
def _add_packages(self):
pkg_queue = self._pkg_queue
for pkg in self._mergelist:
@@ -9534,6 +9545,7 @@ class Scheduler(PollScheduler):
build_dir=build_dir, build_log=build_log,
fetch_log=fetch_log, pkg=pkg,
returncode=merge.returncode))
+ self._failed_pkg_msg(self._failed_pkgs[-1], "install", "to")
self._status_display.failed = len(self._failed_pkgs)
return
@@ -9578,6 +9590,7 @@ class Scheduler(PollScheduler):
build_dir=build_dir, build_log=build_log,
fetch_log=fetch_log, pkg=build.pkg,
returncode=build.returncode))
+ self._failed_pkg_msg(self._failed_pkgs[-1], "emerge", "for")
self._status_display.failed = len(self._failed_pkgs)
self._deallocate_config(build.settings)
@@ -9851,6 +9864,21 @@ class Scheduler(PollScheduler):
return task
+ def _failed_pkg_msg(self, failed_pkg, action, preposition):
+ pkg = failed_pkg.pkg
+ msg = "%s to %s %s" % \
+ (bad("Failed"), action, colorize("INFORM", pkg.cpv))
+ if pkg.root != "/":
+ msg += " %s %s" % (preposition, pkg.root)
+
+ log_path = self._locate_failure_log(failed_pkg)
+ if log_path is not None:
+ msg += ", Log file:"
+ self._status_msg(msg)
+
+ if log_path is not None:
+ self._status_msg(" '%s'" % (colorize("INFORM", log_path),))
+
def _status_msg(self, msg):
"""
Display a brief status message (no newlines) in the status display.