Symlinking FILESDIR into the work tree has the unintended consequence of preserving all original file metadata, including system-specific ACLs and so on. When these files are installed, this could lead to unintentionally copying this metadata to the system and/or binary packages.
Let's copy all files instead and drop metadata in the process. Since FILESDIR is expected to be small by design, this shouldn't cause any major trouble. It is also easier and less likely to cause regressions than making sure stuff is not preserved when installing. Unfortunately, a similar problem applies to DISTDIR. However, installing files from DISTDIR is rarer than from FILESDIR, so I guess we'll cross that bridge when we get to it. Bug: https://bugs.gentoo.org/814857 Signed-off-by: Michał Górny <mgo...@gentoo.org> --- bin/phase-functions.sh | 2 +- lib/portage/package/ebuild/prepare_build_dirs.py | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index d3221993d..9a4c97b16 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -296,7 +296,7 @@ __dyn_clean() { rm -rf "${PORTAGE_BUILDDIR}/build-info" rm -rf "${WORKDIR}" - rm -f "${PORTAGE_BUILDDIR}/files" + rm -rf "${PORTAGE_BUILDDIR}/files" fi if [ -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then diff --git a/lib/portage/package/ebuild/prepare_build_dirs.py b/lib/portage/package/ebuild/prepare_build_dirs.py index 659198905..9d83bacad 100644 --- a/lib/portage/package/ebuild/prepare_build_dirs.py +++ b/lib/portage/package/ebuild/prepare_build_dirs.py @@ -478,16 +478,14 @@ def _ensure_log_subdirs(logdir, subdir): def _prepare_fake_filesdir(settings): real_filesdir = settings["O"] + "/files" - symlink_path = settings["FILESDIR"] + filesdir = settings["FILESDIR"] + portage.util.ensure_dirs(filesdir, mode=0o755) - 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) + # Copy files from real directory to ebuild directory (without metadata). + if os.path.isdir(real_filesdir): + shutil.copytree( + real_filesdir, filesdir, copy_function=shutil.copyfile, dirs_exist_ok=True + ) def _prepare_fake_distdir(settings, alist): -- 2.33.0