1 |
Use a model of fake FILESDIR path to ensure that invalid accesses to |
2 |
FILESDIR will result in failures rather than being silently allowed by |
3 |
Portage. This mostly involves accesses in the global scope and pkg_* |
4 |
phases, although the current model does not cover the latter completely |
5 |
(i.e. does not guarantee that the directory is removed post src_*). |
6 |
|
7 |
This model aims to follow PMS wording quite precisely. The value of |
8 |
FILESDIR is meant to be stable throughout the build process, and it is |
9 |
reliably set to a temporary directory path. However, since the path is |
10 |
not guaranteed to be present outside src_*, the directory symlink is not |
11 |
actually created before src_* phases. |
12 |
--- |
13 |
man/ebuild.5 | 6 +++--- |
14 |
pym/_emerge/EbuildPhase.py | 6 +++++- |
15 |
pym/portage/package/ebuild/config.py | 3 --- |
16 |
pym/portage/package/ebuild/doebuild.py | 2 +- |
17 |
pym/portage/package/ebuild/prepare_build_dirs.py | 13 +++++++++++++ |
18 |
5 files changed, 22 insertions(+), 8 deletions(-) |
19 |
|
20 |
diff --git a/man/ebuild.5 b/man/ebuild.5 |
21 |
index 72b8b6905..e4c866cd2 100644 |
22 |
--- a/man/ebuild.5 |
23 |
+++ b/man/ebuild.5 |
24 |
@@ -411,9 +411,9 @@ not be defined. It is autogenerated from the \fBSRC_URI\fR variable. |
25 |
.B WORKDIR\fR = \fI"${PORTAGE_TMPDIR}/portage/${CATEGORY}/${PF}/work" |
26 |
Contains the path to the package build root. Do not modify this variable. |
27 |
.TP |
28 |
-.B FILESDIR\fR = \fI"${repository_location}/${CATEGORY}/${PN}/files" |
29 |
-Contains the path to the 'files' subdirectory in the package specific |
30 |
-location in given repository. Do not modify this variable. |
31 |
+.B FILESDIR\fR = \fI"${PORTAGE_TMPDIR}/${CATEGORY}/${PF}/files" |
32 |
+Contains the path to the directory in which package-specific auxiliary |
33 |
+files are located. Do not modify this variable. |
34 |
.TP |
35 |
.B EBUILD_PHASE |
36 |
Contains the abreviated name of the phase function that is |
37 |
diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py |
38 |
index fc185fcfd..2d498bffc 100644 |
39 |
--- a/pym/_emerge/EbuildPhase.py |
40 |
+++ b/pym/_emerge/EbuildPhase.py |
41 |
@@ -11,7 +11,8 @@ from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor |
42 |
from _emerge.MiscFunctionsProcess import MiscFunctionsProcess |
43 |
from _emerge.EbuildProcess import EbuildProcess |
44 |
from _emerge.CompositeTask import CompositeTask |
45 |
-from portage.package.ebuild.prepare_build_dirs import _prepare_workdir |
46 |
+from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir, |
47 |
+ _prepare_fake_filesdir) |
48 |
from portage.util import writemsg |
49 |
|
50 |
try: |
51 |
@@ -169,6 +170,9 @@ class EbuildPhase(CompositeTask): |
52 |
|
53 |
def _start_ebuild(self): |
54 |
|
55 |
+ if self.phase == "unpack": |
56 |
+ _prepare_fake_filesdir(self.settings) |
57 |
+ |
58 |
fd_pipes = self.fd_pipes |
59 |
if fd_pipes is None: |
60 |
if not self.background and self.phase == 'nofetch': |
61 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
62 |
index ef29afeab..f8043dbf5 100644 |
63 |
--- a/pym/portage/package/ebuild/config.py |
64 |
+++ b/pym/portage/package/ebuild/config.py |
65 |
@@ -2784,9 +2784,6 @@ class config(object): |
66 |
mydict.pop("EPREFIX", None) |
67 |
mydict.pop("EROOT", None) |
68 |
|
69 |
- if phase == 'depend': |
70 |
- mydict.pop('FILESDIR', None) |
71 |
- |
72 |
if phase not in ("pretend", "setup", "preinst", "postinst") or \ |
73 |
not eapi_exports_replace_vars(eapi): |
74 |
mydict.pop("REPLACING_VERSIONS", None) |
75 |
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
76 |
index 4baae17b1..e7db54bcf 100644 |
77 |
--- a/pym/portage/package/ebuild/doebuild.py |
78 |
+++ b/pym/portage/package/ebuild/doebuild.py |
79 |
@@ -337,7 +337,6 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, |
80 |
mysettings["EBUILD"] = ebuild_path |
81 |
mysettings["O"] = pkg_dir |
82 |
mysettings.configdict["pkg"]["CATEGORY"] = cat |
83 |
- mysettings["FILESDIR"] = pkg_dir+"/files" |
84 |
mysettings["PF"] = mypv |
85 |
|
86 |
if hasattr(mydbapi, 'repositories'): |
87 |
@@ -390,6 +389,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, |
88 |
mysettings["WORKDIR"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "work") |
89 |
mysettings["D"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "image") + os.sep |
90 |
mysettings["T"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "temp") |
91 |
+ mysettings["FILESDIR"] = os.path.join(settings["PORTAGE_BUILDDIR"], "files") |
92 |
|
93 |
# Prefix forward compatability |
94 |
eprefix_lstrip = mysettings["EPREFIX"].lstrip(os.sep) |
95 |
diff --git a/pym/portage/package/ebuild/prepare_build_dirs.py b/pym/portage/package/ebuild/prepare_build_dirs.py |
96 |
index 7e5249b66..e3ae318bd 100644 |
97 |
--- a/pym/portage/package/ebuild/prepare_build_dirs.py |
98 |
+++ b/pym/portage/package/ebuild/prepare_build_dirs.py |
99 |
@@ -396,3 +396,16 @@ def _ensure_log_subdirs(logdir, subdir): |
100 |
while subdir_split: |
101 |
current = os.path.join(current, subdir_split.pop()) |
102 |
ensure_dirs(current, uid=uid, gid=gid, mode=grp_mode, mask=0) |
103 |
+ |
104 |
+def _prepare_fake_filesdir(settings): |
105 |
+ real_filesdir = settings["O"]+"/files" |
106 |
+ symlink_path = settings["FILESDIR"] |
107 |
+ |
108 |
+ try: |
109 |
+ link_target = os.readlink(symlink_path) |
110 |
+ except OSError: |
111 |
+ os.symlink(real_filesdir, symlink_path) |
112 |
+ else: |
113 |
+ if link_target != real_filesdir: |
114 |
+ os.unlink(symlink_path) |
115 |
+ os.symlink(real_filesdir, symlink_path) |
116 |
-- |
117 |
2.12.0 |