Re: [gentoo-portage-dev] [PATCH] portage.package.ebuild: Use a fake FILESDIR to catch invalid accesses

2017-03-24 Thread Michał Górny
On czw, 2017-03-16 at 20:56 +0100, Michał Górny wrote:
> 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_*).
> 

Merged v3 now.

-- 
Best regards,
Michał Górny


signature.asc
Description: This is a digitally signed message part


Re: [gentoo-portage-dev] [PATCH] portage.package.ebuild: Use a fake FILESDIR to catch invalid accesses

2017-03-16 Thread Michał Górny
On czw, 2017-03-16 at 21:29 +0100, Ulrich Mueller wrote:
> > > > > > On Thu, 16 Mar 2017, Michał Górny wrote:
> > +   mysettings["FILESDIR"] = os.path.join(settings["PORTAGE_BUILDDIR"], 
> > "files")
> 
> I believe that this contradicts current PMS 11.1, which defines
> FILESDIR as follows: "The full path to the package's files directory,
> used for small support files or patches. See section 4.3."
> 
> So maybe you should first propose a clarification of the PMS wording?

I think that 'full' in this context means 'absolute'. I don't think this
really requires us to use the 'original' path. But sure, I'll submit
a patch in a few minutes.

-- 
Best regards,
Michał Górny


signature.asc
Description: This is a digitally signed message part


Re: [gentoo-portage-dev] [PATCH] portage.package.ebuild: Use a fake FILESDIR to catch invalid accesses

2017-03-16 Thread Ulrich Mueller
> On Thu, 16 Mar 2017, Michał Górny wrote:

> + mysettings["FILESDIR"] = os.path.join(settings["PORTAGE_BUILDDIR"], 
> "files")

I believe that this contradicts current PMS 11.1, which defines
FILESDIR as follows: "The full path to the package's files directory,
used for small support files or patches. See section 4.3."

So maybe you should first propose a clarification of the PMS wording?

Ulrich


pgpmZkYwR2dxH.pgp
Description: PGP signature


[gentoo-portage-dev] [PATCH] portage.package.ebuild: Use a fake FILESDIR to catch invalid accesses

2017-03-16 Thread Michał Górny
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.

== Review notes ==
This is the final version that actually works ;-). I did a full egencache
run with it and the only packages that fail are eblit users (all of them
have bugs open with deadline 1 week from now). There might be a few more
silly failures, so I'll test it for a while, and ask Toralf to possibly
do some tinderboxing.

---
 man/ebuild.5 |  6 +++---
 pym/_emerge/EbuildPhase.py   |  4 +++-
 pym/portage/package/ebuild/config.py |  3 ---
 pym/portage/package/ebuild/doebuild.py   |  6 +-
 pym/portage/package/ebuild/prepare_build_dirs.py | 13 +
 5 files changed, 24 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 fc185fcfd..504c812ea 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:
@@ -229,6 +230,7 @@ class EbuildPhase(CompositeTask):
# ownership since tar can change that too.
os.utime(settings["WORKDIR"], None)
_prepare_workdir(settings)
+   _prepare_fake_filesdir(settings)
elif self.phase == "install":
out = io.StringIO()
_post_src_install_write_metadata(settings)
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..2f80a28ee 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -31,6 +31,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.package.ebuild.digestcheck:digestcheck',
'portage.package.ebuild.digestgen:digestgen',
'portage.package.ebuild.fetch:fetch',
+   'portage.package.ebuild.prepare_build_dirs:_prepare_fake_filesdir',
'portage.package.ebuild._ipc.QueryCommand:QueryCommand',
'portage.dep._slot_operator:evaluate_slot_operator_equal_deps',
'portage.package.ebuild._spawn_nofetch:spawn_nofetch',
@@ -164,6 +165,9 @@ def _doebuild_spawn(phase, settings, actionmap=None, 
**kwargs):
os.path.basename(EBUILD_SH_BINARY))),
ebuild_sh_arg)
 
+   if phase == 'unpack':
+   _prepare_fake_filesdir(settings)
+
settings['EBUILD_PHASE'] = phase
try: