From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QgJGE-0003Xq-TV for garchives@archives.gentoo.org; Mon, 11 Jul 2011 16:23:09 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B6B8121C30E; Mon, 11 Jul 2011 16:22:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 77A2321C30E for ; Mon, 11 Jul 2011 16:22:58 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C96D81B4081 for ; Mon, 11 Jul 2011 16:22:57 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id C8D0A8003D for ; Mon, 11 Jul 2011 16:22:56 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <002882cc5a936f2e111bfc6f342fb1f5987f68ed.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/package/ebuild/prepare_build_dirs.py X-VCS-Directories: pym/portage/package/ebuild/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 002882cc5a936f2e111bfc6f342fb1f5987f68ed Date: Mon, 11 Jul 2011 16:22:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: b1ef3a31d1cd9922b729c49b48858f2c commit: 002882cc5a936f2e111bfc6f342fb1f5987f68ed Author: Zac Medico gentoo org> AuthorDate: Mon Jul 11 16:22:37 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Jul 11 16:22:37 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D002882cc prepare_build_dirs: copy logdir group permissions The gid of PORT_LOGDIR is copied to all subdirectories, along with 0x2070 mode bits if present. --- pym/portage/package/ebuild/prepare_build_dirs.py | 43 ++++++++++++++++= +----- 1 files changed, 33 insertions(+), 10 deletions(-) diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/porta= ge/package/ebuild/prepare_build_dirs.py index 5153190..de1dc93 100644 --- a/pym/portage/package/ebuild/prepare_build_dirs.py +++ b/pym/portage/package/ebuild/prepare_build_dirs.py @@ -16,7 +16,7 @@ from portage.exception import DirectoryNotFound, FileNo= tFound, \ from portage.localization import _ from portage.output import colorize from portage.util import apply_recursive_permissions, \ - apply_secpass_permissions, ensure_dirs, writemsg + apply_secpass_permissions, ensure_dirs, normalize_path, writemsg =20 def prepare_build_dirs(myroot=3DNone, settings=3DNone, cleanup=3DFalse): """ @@ -303,6 +303,7 @@ def _prepare_workdir(mysettings): logdir_subdir_ok =3D False if "PORT_LOGDIR" in mysettings and \ os.access(mysettings["PORT_LOGDIR"], os.W_OK): + logdir =3D normalize_path(mysettings["PORT_LOGDIR"]) logid_path =3D os.path.join(mysettings["PORTAGE_BUILDDIR"], ".logid") if not os.path.exists(logid_path): open(_unicode_encode(logid_path), 'w') @@ -311,22 +312,25 @@ def _prepare_workdir(mysettings): encoding=3D_encodings['content'], errors=3D'replace') =20 if "split-log" in mysettings.features: + log_subdir =3D os.path.join(logdir, "build", mysettings["CATEGORY"]) mysettings["PORTAGE_LOG_FILE"] =3D os.path.join( - mysettings["PORT_LOGDIR"], "build", "%s/%s:%s.log%s" % \ - (mysettings["CATEGORY"], mysettings["PF"], logid_time, - compress_log_ext)) + log_subdir, "%s:%s.log%s" % + (mysettings["PF"], logid_time, compress_log_ext)) else: + log_subdir =3D logdir mysettings["PORTAGE_LOG_FILE"] =3D os.path.join( - mysettings["PORT_LOGDIR"], "%s:%s:%s.log%s" % \ + logdir, "%s:%s:%s.log%s" % \ (mysettings["CATEGORY"], mysettings["PF"], logid_time, compress_log_ext)) =20 - log_subdir =3D os.path.dirname(mysettings["PORTAGE_LOG_FILE"]) - try: - ensure_dirs(log_subdir) - except PortageException as e: - writemsg(_unicode_decode("!!! %s\n") % (e,), noiselevel=3D-1) + if log_subdir is logdir: + logdir_subdir_ok =3D True else: + try: + _ensure_log_subdirs(logdir, log_subdir) + except PortageException as e: + writemsg(_unicode_decode("!!! %s\n") % (e,), noiselevel=3D-1) + if os.access(log_subdir, os.W_OK): logdir_subdir_ok =3D True else: @@ -340,3 +344,22 @@ def _prepare_workdir(mysettings): # not through a normal pipe. See bug #162404. mysettings["PORTAGE_LOG_FILE"] =3D os.path.join( mysettings["T"], "build.log%s" % compress_log_ext) + +def _ensure_log_subdirs(logdir, subdir): + """ + This assumes that logdir exists, and creates subdirectories down + to subdir as necessary. The gid of logdir is copied to all + subdirectories, along with 0x2070 mode bits if present. Both logdir + and subdir are assumed to be normalized absolute paths. + """ + st =3D os.stat(logdir) + gid =3D st.st_gid + grp_mode =3D 0o2070 & st.st_mode + + logdir_split_len =3D len(logdir.split(os.sep)) + subdir_split =3D subdir.split(os.sep)[logdir_split_len:] + subdir_split.reverse() + current =3D logdir + while subdir_split: + current =3D os.path.join(current, subdir_split.pop()) + ensure_dirs(current, gid=3Dgid, mode=3Dgrp_mode, mask=3D0)