From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8A354139694 for ; Fri, 24 Mar 2017 19:41:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D9B3C21C098; Fri, 24 Mar 2017 19:41:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A95E921C098 for ; Fri, 24 Mar 2017 19:41:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9CBCA340FDA for ; Fri, 24 Mar 2017 19:41:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 098B573A7 for ; Fri, 24 Mar 2017 19:41:48 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1490384461.0637c95545ab7dc0bb5d091de221b9e99e2cf5b2.mgorny@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/, pym/portage/package/ebuild/, man/ X-VCS-Repository: proj/portage X-VCS-Files: man/ebuild.5 pym/_emerge/EbuildPhase.py pym/portage/package/ebuild/config.py pym/portage/package/ebuild/doebuild.py pym/portage/package/ebuild/prepare_build_dirs.py X-VCS-Directories: man/ pym/_emerge/ pym/portage/package/ebuild/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 0637c95545ab7dc0bb5d091de221b9e99e2cf5b2 X-VCS-Branch: master Date: Fri, 24 Mar 2017 19:41:48 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 717ba632-9163-4ef9-a3aa-20db8c0812b8 X-Archives-Hash: e12f30b00b2271c571e7a197e17e4488 commit: 0637c95545ab7dc0bb5d091de221b9e99e2cf5b2 Author: Michał Górny gentoo org> AuthorDate: Sat Jun 4 18:23:53 2016 +0000 Commit: Michał Górny gentoo org> CommitDate: Fri Mar 24 19:41:01 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0637c955 portage.package.ebuild: Use a fake FILESDIR to catch invalid accesses Use a model of fake FILESDIR path to ensure that invalid accesses to FILESDIR will result in failures rather than being silently allowed by Portage. This mostly involves accesses in the global scope and pkg_* phases, although the current model does not cover the latter completely (i.e. does not guarantee that the directory is removed post src_*). This model aims to follow PMS wording quite precisely. The value of FILESDIR is meant to be stable throughout the build process, and it is reliably set to a temporary directory path. However, since the path is not guaranteed to be present outside src_*, the directory symlink is not actually created before src_* phases. Reviewed-by: Zac Medico gentoo.org> man/ebuild.5 | 6 +++--- pym/_emerge/EbuildPhase.py | 6 +++++- pym/portage/package/ebuild/config.py | 3 --- pym/portage/package/ebuild/doebuild.py | 2 +- pym/portage/package/ebuild/prepare_build_dirs.py | 13 +++++++++++++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/man/ebuild.5 b/man/ebuild.5 index 72b8b6905..e4c866cd2 100644 --- a/man/ebuild.5 +++ b/man/ebuild.5 @@ -411,9 +411,9 @@ not be defined. It is autogenerated from the \fBSRC_URI\fR variable. .B WORKDIR\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/work" Contains the path to the package build root. Do not modify this variable. .TP -.B FILESDIR\fR = \fI"${repository_location}/${CATEGORY}/${PN}/files" -Contains the path to the 'files' subdirectory in the package specific -location in given repository. Do not modify this variable. +.B FILESDIR\fR = \fI"${PORTAGE_TMPDIR}/${CATEGORY}/${PF}/files" +Contains the path to the directory in which package-specific auxiliary +files are located. Do not modify this variable. .TP .B EBUILD_PHASE Contains the abreviated name of the phase function that is diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index 6191ee2b3..aa3a66831 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -11,7 +11,8 @@ from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor from _emerge.MiscFunctionsProcess import MiscFunctionsProcess from _emerge.EbuildProcess import EbuildProcess from _emerge.CompositeTask import CompositeTask -from portage.package.ebuild.prepare_build_dirs import _prepare_workdir +from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir, + _prepare_fake_filesdir) from portage.util import writemsg try: @@ -169,6 +170,9 @@ class EbuildPhase(CompositeTask): def _start_ebuild(self): + if self.phase == "unpack": + _prepare_fake_filesdir(self.settings) + fd_pipes = self.fd_pipes if fd_pipes is None: if not self.background and self.phase == 'nofetch': diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index ef29afeab..f8043dbf5 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -2784,9 +2784,6 @@ class config(object): mydict.pop("EPREFIX", None) mydict.pop("EROOT", None) - if phase == 'depend': - mydict.pop('FILESDIR', None) - if phase not in ("pretend", "setup", "preinst", "postinst") or \ not eapi_exports_replace_vars(eapi): mydict.pop("REPLACING_VERSIONS", None) diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 4baae17b1..e7db54bcf 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -337,7 +337,6 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, mysettings["EBUILD"] = ebuild_path mysettings["O"] = pkg_dir mysettings.configdict["pkg"]["CATEGORY"] = cat - mysettings["FILESDIR"] = pkg_dir+"/files" mysettings["PF"] = mypv if hasattr(mydbapi, 'repositories'): @@ -390,6 +389,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, mysettings["WORKDIR"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "work") mysettings["D"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "image") + os.sep mysettings["T"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "temp") + mysettings["FILESDIR"] = os.path.join(settings["PORTAGE_BUILDDIR"], "files") # Prefix forward compatability eprefix_lstrip = mysettings["EPREFIX"].lstrip(os.sep) diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py index 7e5249b66..e3ae318bd 100644 --- a/pym/portage/package/ebuild/prepare_build_dirs.py +++ b/pym/portage/package/ebuild/prepare_build_dirs.py @@ -396,3 +396,16 @@ def _ensure_log_subdirs(logdir, subdir): while subdir_split: current = os.path.join(current, subdir_split.pop()) ensure_dirs(current, uid=uid, gid=gid, mode=grp_mode, mask=0) + +def _prepare_fake_filesdir(settings): + real_filesdir = settings["O"]+"/files" + symlink_path = settings["FILESDIR"] + + try: + link_target = os.readlink(symlink_path) + except OSError: + os.symlink(real_filesdir, symlink_path) + else: + if link_target != real_filesdir: + os.unlink(symlink_path) + os.symlink(real_filesdir, symlink_path)