From 9ca46474139b131a2c2e416880f65ae9e3f99fc5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 9 Oct 2009 22:50:56 +0000 Subject: Bug #273099 - Add split-log and split-elog FEATURES for splitting build logs and elog mod_save logs into category subdirectories. Thanks to Sebastian Mingramm (few) for this patch. svn path=/main/trunk/; revision=14532 --- man/make.conf.5 | 9 +++++++++ pym/portage/__init__.py | 16 ++++++++++++---- pym/portage/elog/mod_save.py | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/man/make.conf.5 b/man/make.conf.5 index a2d41ef90..0e7ebf888 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -367,6 +367,15 @@ a read-only NFS share. A read-only \fBDISTDIR\fR is not compatible with the \fBFEATURES\fR in order to avoid warning messages that are triggered by this incompatibility. .TP +split\-elog +Store logs created by \fBPORTAGE_ELOG_SYSTEM="save"\fR in category +subdirectories of \fBPORT_LOGDIR/elog\fR, instead of using +\fBPORT_LOGDIR/elog\fR directly. +.TP +.B split\-log +Store build logs in category subdirectories of \fBPORT_LOGDIR/build\fR, +instead of using \fBPORT_LOGDIR\fR directly. +.TP .B splitdebug Prior to stripping ELF etdyn and etexec files, the debugging info is stored for later use by various debuggers. This feature is disabled by diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 9224b7138..94c698cc5 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -6476,10 +6476,18 @@ def _prepare_workdir(mysettings): logid_time = _unicode_decode(time.strftime("%Y%m%d-%H%M%S", time.gmtime(os.stat(logid_path).st_mtime)), encoding=_encodings['content'], errors='replace') - mysettings["PORTAGE_LOG_FILE"] = os.path.join( - mysettings["PORT_LOGDIR"], "%s:%s:%s.log" % \ - (mysettings["CATEGORY"], mysettings["PF"], logid_time)) - del logid_path, logid_time + + if "split-log" in mysettings.features: + mysettings["PORTAGE_LOG_FILE"] = os.path.join( + mysettings["PORT_LOGDIR"], "build", "%s/%s:%s.log" % \ + (mysettings["CATEGORY"], mysettings["PF"], logid_time)) + else: + mysettings["PORTAGE_LOG_FILE"] = os.path.join( + mysettings["PORT_LOGDIR"], "%s:%s:%s.log" % \ + (mysettings["CATEGORY"], mysettings["PF"], logid_time)) + + util.ensure_dirs(os.path.dirname(mysettings["PORTAGE_LOG_FILE"])) + else: # NOTE: When sesandbox is enabled, the local SELinux security policies # may not allow output to be piped out of the sesandbox domain. The diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py index 954787994..b1c38061d 100644 --- a/pym/portage/elog/mod_save.py +++ b/pym/portage/elog/mod_save.py @@ -21,9 +21,20 @@ def process(mysettings, key, logentries, fulltext): elogdir = os.path.join(os.sep, "var", "log", "portage", "elog") ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770) - elogfilename = os.path.join(elogdir, path + ":" + _unicode_decode( + cat = mysettings['CATEGORY'] + pf = mysettings['PF'] + + elogfilename = pf + ":" + _unicode_decode( time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())), - encoding=_encodings['content'], errors='replace') + ".log") + encoding=_encodings['content'], errors='replace') + ".log" + + if "split-elog" in mysettings.features: + elogfilename = os.path.join(elogdir, cat, elogfilename) + else: + elogfilename = os.path.join(elogdir, cat + ':' + elogfilename) + ensure_dirs(os.path.dirname(elogfilename), + uid=portage_uid, gid=portage_gid, mode=0o2770) + elogfile = codecs.open(_unicode_encode(elogfilename, encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['content'], errors='backslashreplace') -- cgit v1.2.3-1-g7c22