summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/BinpkgVerifier.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-21 11:18:40 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-21 11:18:40 -0700
commit42cab46428e69cf7423053b10940a275c38c04ff (patch)
tree3d136311af222afb8d0d9bda838c1d5674b6cf4f /pym/_emerge/BinpkgVerifier.py
parent99832a79bff002a7494c4fb31701451c13a5a435 (diff)
downloadportage-42cab46428e69cf7423053b10940a275c38c04ff.tar.gz
portage-42cab46428e69cf7423053b10940a275c38c04ff.tar.bz2
portage-42cab46428e69cf7423053b10940a275c38c04ff.zip
Bug #324191 - Add support for FEATURES=compress-build-logs. The causes
all build logs to be compressed while they are being written. Log file names have an extension that is appropriate for the compression type. Currently, only gzip(1) compression is supported, so build logs will have a '.gz' extension when this feature is enabled.
Diffstat (limited to 'pym/_emerge/BinpkgVerifier.py')
-rw-r--r--pym/_emerge/BinpkgVerifier.py34
1 files changed, 11 insertions, 23 deletions
diff --git a/pym/_emerge/BinpkgVerifier.py b/pym/_emerge/BinpkgVerifier.py
index 83a02c76c..02a942c94 100644
--- a/pym/_emerge/BinpkgVerifier.py
+++ b/pym/_emerge/BinpkgVerifier.py
@@ -7,7 +7,9 @@ import sys
import portage
from portage import os
from portage import _encodings
+from portage import _unicode_decode
from portage import _unicode_encode
+from portage import StringIO
from portage.package.ebuild.fetch import _checksum_failure_temp_file
import codecs
@@ -27,27 +29,10 @@ class BinpkgVerifier(AsynchronousTask):
rval = os.EX_OK
stdout_orig = sys.stdout
stderr_orig = sys.stderr
- log_file = None
- if self.background and self.logfile is not None:
- if sys.hexversion >= 0x3000000:
- # Since we are replacing the sys.std* streams,
- # we need to use the normal open() function
- # so that we get the right class (otherwise our
- # code that expects the 'buffer' attribute
- # will break).
- log_file = open(_unicode_encode(self.logfile,
- encoding=_encodings['fs'], errors='strict'),
- mode='a', encoding=_encodings['content'],
- errors='backslashreplace')
- else:
- # For python2, sys.std* are expected to be binary streams.
- log_file = open(_unicode_encode(self.logfile,
- encoding=_encodings['fs'], errors='strict'),
- mode='ab')
+ out = portage.StringIO()
try:
- if log_file is not None:
- sys.stdout = log_file
- sys.stderr = log_file
+ sys.stdout = out
+ sys.stderr = out
try:
bintree.digestCheck(pkg)
except portage.exception.FileNotFound:
@@ -69,7 +54,7 @@ class BinpkgVerifier(AsynchronousTask):
if rval == os.EX_OK:
# If this was successful, discard the log here since otherwise
# we'll get multiple logs for the same package.
- if log_file is not None:
+ if self.logfile is not None:
try:
os.unlink(self.logfile)
except OSError:
@@ -83,8 +68,11 @@ class BinpkgVerifier(AsynchronousTask):
finally:
sys.stdout = stdout_orig
sys.stderr = stderr_orig
- if log_file is not None:
- log_file.close()
+
+ msg = _unicode_decode(out.getvalue(),
+ encoding=_encodings['content'], errors='replace')
+ if msg:
+ self.scheduler.output(msg, log_path=self.logfile)
self.returncode = rval
self.wait()