1 |
Symlinking FILESDIR into the work tree has the unintended consequence |
2 |
of preserving all original file metadata, including system-specific ACLs |
3 |
and so on. When these files are installed, this could lead to |
4 |
unintentionally copying this metadata to the system and/or binary |
5 |
packages. |
6 |
|
7 |
Let's copy all files instead and drop metadata in the process. Since |
8 |
FILESDIR is expected to be small by design, this shouldn't cause any |
9 |
major trouble. It is also easier and less likely to cause regressions |
10 |
than making sure stuff is not preserved when installing. |
11 |
|
12 |
Unfortunately, a similar problem applies to DISTDIR. However, |
13 |
installing files from DISTDIR is rarer than from FILESDIR, so I guess |
14 |
we'll cross that bridge when we get to it. |
15 |
|
16 |
Bug: https://bugs.gentoo.org/814857 |
17 |
Signed-off-by: Michał Górny <mgorny@g.o> |
18 |
--- |
19 |
bin/phase-functions.sh | 2 +- |
20 |
.../package/ebuild/prepare_build_dirs.py | 19 +++++++++---------- |
21 |
2 files changed, 10 insertions(+), 11 deletions(-) |
22 |
|
23 |
Changed in v3: |
24 |
- use optimized copyfile from Portage (supports reflinking) |
25 |
|
26 |
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh |
27 |
index d3221993d..9a4c97b16 100644 |
28 |
--- a/bin/phase-functions.sh |
29 |
+++ b/bin/phase-functions.sh |
30 |
@@ -296,7 +296,7 @@ __dyn_clean() { |
31 |
|
32 |
rm -rf "${PORTAGE_BUILDDIR}/build-info" |
33 |
rm -rf "${WORKDIR}" |
34 |
- rm -f "${PORTAGE_BUILDDIR}/files" |
35 |
+ rm -rf "${PORTAGE_BUILDDIR}/files" |
36 |
fi |
37 |
|
38 |
if [ -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then |
39 |
diff --git a/lib/portage/package/ebuild/prepare_build_dirs.py b/lib/portage/package/ebuild/prepare_build_dirs.py |
40 |
index 659198905..2e2ef73f4 100644 |
41 |
--- a/lib/portage/package/ebuild/prepare_build_dirs.py |
42 |
+++ b/lib/portage/package/ebuild/prepare_build_dirs.py |
43 |
@@ -1,4 +1,4 @@ |
44 |
-# Copyright 2010-2020 Gentoo Authors |
45 |
+# Copyright 2010-2021 Gentoo Authors |
46 |
# Distributed under the terms of the GNU General Public License v2 |
47 |
|
48 |
__all__ = ["prepare_build_dirs"] |
49 |
@@ -27,6 +27,7 @@ from portage.util import ( |
50 |
normalize_path, |
51 |
writemsg, |
52 |
) |
53 |
+from portage.util.file_copy import copyfile |
54 |
from portage.util.install_mask import _raise_exc |
55 |
|
56 |
|
57 |
@@ -478,16 +479,14 @@ def _ensure_log_subdirs(logdir, subdir): |
58 |
|
59 |
def _prepare_fake_filesdir(settings): |
60 |
real_filesdir = settings["O"] + "/files" |
61 |
- symlink_path = settings["FILESDIR"] |
62 |
+ filesdir = settings["FILESDIR"] |
63 |
+ portage.util.ensure_dirs(filesdir, mode=0o755) |
64 |
|
65 |
- try: |
66 |
- link_target = os.readlink(symlink_path) |
67 |
- except OSError: |
68 |
- os.symlink(real_filesdir, symlink_path) |
69 |
- else: |
70 |
- if link_target != real_filesdir: |
71 |
- os.unlink(symlink_path) |
72 |
- os.symlink(real_filesdir, symlink_path) |
73 |
+ # Copy files from real directory to ebuild directory (without metadata). |
74 |
+ if os.path.isdir(real_filesdir): |
75 |
+ shutil.copytree( |
76 |
+ real_filesdir, filesdir, copy_function=copyfile, dirs_exist_ok=True |
77 |
+ ) |
78 |
|
79 |
|
80 |
def _prepare_fake_distdir(settings, alist): |
81 |
-- |
82 |
2.33.0 |