diff options
-rw-r--r-- | pym/_emerge/EbuildPhase.py | 25 | ||||
-rw-r--r-- | pym/portage/package/ebuild/doebuild.py | 40 | ||||
-rw-r--r-- | pym/portage/util/__init__.py | 12 |
3 files changed, 41 insertions, 36 deletions
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index 51ee93da6..8d20fd878 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -58,18 +58,21 @@ class EbuildPhase(CompositeTask): settings = self.settings if self.phase == "install": - out = None - log_path = self.settings.get("PORTAGE_LOG_FILE") - log_file = None - if self.background and 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 + out = portage.StringIO() _post_src_install_chost_fix(settings) - _post_src_install_uid_fix(settings, out=out) - if log_file is not None: - log_file.close() + _post_src_install_uid_fix(settings, out) + msg = _unicode_decode(out.getvalue(), + encoding=_encodings['content'], errors='replace') + if msg: + if not self.background: + writemsg_stdout(msg, noiselevel=-1) + log_path = self.settings.get("PORTAGE_LOG_FILE") + 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') + log_file.write(msg) + log_file.close() post_phase_cmds = _post_phase_cmds.get(self.phase) if post_phase_cmds is not None: diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index ab474f241..1198e53ea 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -1392,13 +1392,27 @@ def _post_phase_userpriv_perms(mysettings): filemode=0o60, filemask=0) def _post_src_install_checks(mysettings): - _post_src_install_uid_fix(mysettings) + out = portage.StringIO() + _post_src_install_uid_fix(mysettings, out) global _post_phase_cmds retval = _spawn_misc_sh(mysettings, _post_phase_cmds["install"], phase='internal_post_src_install') if retval != os.EX_OK: writemsg(_("!!! install_qa_check failed; exiting.\n"), - noiselevel=-1) + fd=out, noiselevel=-1) + + msg = _unicode_decode(out.getvalue(), + encoding=_encodings['content'], errors='replace') + if msg: + writemsg_stdout(msg, noiselevel=-1) + log_path = mysettings.get("PORTAGE_LOG_FILE") + 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') + log_file.write(msg) + log_file.close() + return retval def _check_build_log(mysettings, out=None): @@ -1532,7 +1546,7 @@ _vdb_use_conditional_keys = ('DEPEND', 'LICENSE', 'PDEPEND', 'PROPERTIES', 'PROVIDE', 'RDEPEND', 'RESTRICT',) _vdb_use_conditional_atoms = frozenset(['DEPEND', 'PDEPEND', 'RDEPEND']) -def _post_src_install_uid_fix(mysettings, out=None): +def _post_src_install_uid_fix(mysettings, out): """ Files in $D with user and group bits that match the "portage" user or group are automatically mapped to PORTAGE_INST_UID and @@ -1557,8 +1571,6 @@ def _post_src_install_uid_fix(mysettings, out=None): (_shell_quote(mysettings["D"]),)) destdir = mysettings["D"] - logfile = mysettings.get("PORTAGE_LOG_FILE") - qa_out = StringIO() unicode_errors = [] while True: @@ -1623,8 +1635,8 @@ def _post_src_install_uid_fix(mysettings, out=None): writemsg("Fixing .la files\n", fd=out) msg = " %s is not a valid libtool archive, skipping\n" % fpath[len(destdir):] qa_msg = "QA Notice: invalid .la file found: %s, %s" % (fpath[len(destdir):], e) - writemsg(msg) - eqawarn(qa_msg, key=mysettings.mycpv, out=qa_out) + writemsg(msg, fd=out) + eqawarn(qa_msg, key=mysettings.mycpv, out=out) if needs_update: if not lafilefixing_announced: lafilefixing_announced = True @@ -1666,20 +1678,6 @@ def _post_src_install_uid_fix(mysettings, out=None): for l in _merge_unicode_error(unicode_errors): eerror(l, phase='install', key=mysettings.mycpv, out=out) - msg = _unicode_decode(qa_out.getvalue(), - encoding=_encodings['content'], errors='replace') - if msg and logfile: - 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() - build_info_dir = os.path.join(mysettings['PORTAGE_BUILDDIR'], 'build-info') diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index 821428d12..6e7f5db9d 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -56,10 +56,14 @@ def writemsg(mystr,noiselevel=0,fd=None): fd = sys.stderr if noiselevel <= noiselimit: # avoid potential UnicodeEncodeError - mystr = _unicode_encode(mystr, - encoding=_encodings['stdio'], errors='backslashreplace') - if sys.hexversion >= 0x3000000 and fd in (sys.stdout, sys.stderr): - fd = fd.buffer + if isinstance(fd, StringIO): + mystr = _unicode_decode(mystr, + encoding=_encodings['content'], errors='replace') + else: + mystr = _unicode_encode(mystr, + encoding=_encodings['stdio'], errors='backslashreplace') + if sys.hexversion >= 0x3000000 and fd in (sys.stdout, sys.stderr): + fd = fd.buffer fd.write(mystr) fd.flush() |