summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/SpawnProcess.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/SpawnProcess.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/SpawnProcess.py')
-rw-r--r--pym/_emerge/SpawnProcess.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index 6e0586815..aeb206a06 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -6,10 +6,13 @@ from _emerge.PollConstants import PollConstants
import sys
from portage.cache.mappings import slot_dict_class
import portage
+from portage import _encodings
+from portage import _unicode_encode
from portage import os
import fcntl
import errno
import array
+import gzip
class SpawnProcess(SubProcess):
@@ -77,7 +80,12 @@ class SpawnProcess(SubProcess):
fd_pipes[1] = slave_fd
fd_pipes[2] = slave_fd
- files.log = open(logfile, mode='ab')
+ files.log = open(_unicode_encode(logfile,
+ encoding=_encodings['fs'], errors='strict'), mode='ab')
+ if logfile.endswith('.gz'):
+ files.log = gzip.GzipFile(filename='', mode='ab',
+ fileobj=files.log)
+
portage.util.apply_secpass_permissions(logfile,
uid=portage.portage_uid, gid=portage.portage_gid,
mode=0o660)
@@ -188,7 +196,11 @@ class SpawnProcess(SubProcess):
fcntl.fcntl(files.stdout.fileno(),
fcntl.F_GETFL) ^ os.O_NONBLOCK)
- buf.tofile(files.log)
+ try:
+ buf.tofile(files.log)
+ except TypeError:
+ # array.tofile() doesn't work with GzipFile
+ files.log.write(buf.tostring())
files.log.flush()
else:
self._unregister()