diff options
Diffstat (limited to 'pym')
-rw-r--r-- | pym/_emerge/EbuildPhase.py | 15 | ||||
-rw-r--r-- | pym/portage/__init__.py | 27 |
2 files changed, 37 insertions, 5 deletions
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index fcf60d39c..01661b2cc 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -5,10 +5,11 @@ from _emerge.MiscFunctionsProcess import MiscFunctionsProcess from _emerge.EbuildProcess import EbuildProcess from _emerge.CompositeTask import CompositeTask -from portage.util import writemsg +from portage.util import writemsg, writemsg_stdout import portage from portage import os from portage import _encodings +from portage import _unicode_decode from portage import _unicode_encode import codecs @@ -30,16 +31,22 @@ class EbuildPhase(CompositeTask): def _ebuild_exit(self, ebuild_process): if self.phase == "install": - out = None + out = portage.StringIO() log_path = self.settings.get("PORTAGE_LOG_FILE") log_file = None - if self.background and log_path is not None: + if log_path is not None: log_file = codecs.open(_unicode_encode(log_path, encoding=_encodings['fs'], errors='strict'), mode='a', encoding=_encodings['content'], errors='replace') - out = log_file try: portage._check_build_log(self.settings, out=out) + msg = _unicode_decode(out.getvalue(), + encoding=_encodings['content'], errors='replace') + if msg: + if not self.background: + writemsg_stdout(msg, noiselevel=-1) + if log_file is not None: + log_file.write(msg) finally: if log_file is not None: log_file.close() diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index c138a3ec0..9c8930ad6 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -33,6 +33,15 @@ try: from subprocess import getstatusoutput as subprocess_getstatusoutput except ImportError: from commands import getstatusoutput as subprocess_getstatusoutput + + try: + from io import StringIO + except ImportError: + # Needed for python-2.6 with USE=build since + # io imports threading which imports thread + # which is unavailable. + from StringIO import StringIO + from time import sleep from random import shuffle from itertools import chain @@ -5620,7 +5629,23 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0, _post_phase_userpriv_perms(mysettings) if mydo == "install": - _check_build_log(mysettings) + out = StringIO() + _check_build_log(mysettings, out=out) + msg = _unicode_decode(out.getvalue(), + encoding=_encodings['content'], errors='replace') + if msg: + writemsg_stdout(msg, noiselevel=-1) + if logfile is not None: + try: + f = codecs.open(_unicode_encode(logfile, + encoding=_encodings['fs'], errors='strict'), + mode='a', encoding=_encodings['content'], + errors='replace') + except EnvironmentError: + pass + else: + f.write(msg) + f.close() if phase_retval == os.EX_OK: _post_src_install_chost_fix(mysettings) phase_retval = _post_src_install_checks(mysettings) |