summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/elog/mod_save.py21
-rw-r--r--pym/portage/elog/mod_save_summary.py23
-rw-r--r--pym/portage/package/ebuild/prepare_build_dirs.py2
3 files changed, 27 insertions, 19 deletions
diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py
index 0f0979466..40ba26765 100644
--- a/pym/portage/elog/mod_save.py
+++ b/pym/portage/elog/mod_save.py
@@ -8,17 +8,15 @@ from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
-from portage.data import portage_uid, portage_gid
-from portage.util import ensure_dirs
+from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
+from portage.util import normalize_path
def process(mysettings, key, logentries, fulltext):
- path = key.replace("/", ":")
- if mysettings["PORT_LOGDIR"] != "":
- elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+ if mysettings.get("PORT_LOGDIR"):
+ logdir = normalize_path(mysettings["PORT_LOGDIR"])
else:
- elogdir = os.path.join(os.sep, "var", "log", "portage", "elog")
- ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+ logdir = os.path.join(os.sep, "var", "log", "portage")
cat = mysettings['CATEGORY']
pf = mysettings['PF']
@@ -28,11 +26,12 @@ def process(mysettings, key, logentries, fulltext):
encoding=_encodings['content'], errors='replace') + ".log"
if "split-elog" in mysettings.features:
- elogfilename = os.path.join(elogdir, cat, elogfilename)
+ log_subdir = os.path.join(logdir, "elog", cat)
+ elogfilename = os.path.join(log_subdir, elogfilename)
else:
- elogfilename = os.path.join(elogdir, cat + ':' + elogfilename)
- ensure_dirs(os.path.dirname(elogfilename),
- uid=portage_uid, gid=portage_gid, mode=0o2770)
+ log_subdir = os.path.join(logdir, "elog")
+ elogfilename = os.path.join(log_subdir, cat + ':' + elogfilename)
+ _ensure_log_subdirs(logdir, log_subdir)
elogfile = io.open(_unicode_encode(elogfilename,
encoding=_encodings['fs'], errors='strict'),
diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index 8970f06d0..67bd76e55 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -8,23 +8,32 @@ from portage import os
from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
-from portage.data import portage_uid, portage_gid
from portage.localization import _
-from portage.util import ensure_dirs, apply_permissions
+from portage.package.ebuild.prepare_build_dirs import _ensure_log_subdirs
+from portage.util import apply_permissions, normalize_path
def process(mysettings, key, logentries, fulltext):
- if mysettings["PORT_LOGDIR"] != "":
- elogdir = os.path.join(mysettings["PORT_LOGDIR"], "elog")
+ if mysettings.get("PORT_LOGDIR"):
+ logdir = normalize_path(mysettings["PORT_LOGDIR"])
else:
- elogdir = os.path.join(os.sep, "var", "log", "portage", "elog")
- ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=0o2770)
+ logdir = os.path.join(os.sep, "var", "log", "portage")
+
+ elogdir = os.path.join(logdir, "elog")
+ _ensure_log_subdirs(logdir, elogdir)
# TODO: Locking
elogfilename = elogdir+"/summary.log"
elogfile = io.open(_unicode_encode(elogfilename,
encoding=_encodings['fs'], errors='strict'),
mode='a', encoding=_encodings['content'], errors='backslashreplace')
- apply_permissions(elogfilename, mode=0o60, mask=0)
+
+ # Copy group permission bits from parent directory.
+ elogdir_st = os.stat(elogdir)
+ elogdir_gid = elogdir_st.st_gid
+ elogdir_grp_mode = 0o060 & elogdir_st.st_mode
+ apply_permissions(elogfilename, gid=elogdir_gid,
+ mode=elogdir_grp_mode, mask=0)
+
time_str = time.strftime("%Y-%m-%d %H:%M:%S %Z",
time.localtime(time.time()))
# Avoid potential UnicodeDecodeError later.
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py
index de1dc93f7..aaf0740d8 100644
--- a/pym/portage/package/ebuild/prepare_build_dirs.py
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
__all__ = ['prepare_build_dirs']