Gentoo Archives: gentoo-commits

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