summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-05-25 16:00:32 +0200
committerMichał Górny <mgorny@gentoo.org>2021-06-11 19:48:06 +0200
commit689c79fc573879086aa809b62d9d4f4c8418f1fb (patch)
tree1464613b43fbde58374d8313e9577e97c49362b7
parentrepoman/setup.py: prefer setuptools over distutils (bug 794166) (diff)
downloadportage-689c79fc573879086aa809b62d9d4f4c8418f1fb.tar.gz
portage-689c79fc573879086aa809b62d9d4f4c8418f1fb.tar.bz2
portage-689c79fc573879086aa809b62d9d4f4c8418f1fb.zip
Use an explicit empty dir for pkg_* phases [WIP]
Create and use an explicit ${PORTAGE_BUILDDIR}/empty as working directory for pkg_* phases, as proposed for EAPI 8. Note that this patch doesn't work fully -- empty is not cleared between pkg_preinst and pkg_postinst, and between pkg_prerm and pkg_postrm. Reviewed-by: Zac Medico <zmedico@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rwxr-xr-xbin/ebuild.sh6
-rw-r--r--bin/phase-functions.sh3
-rw-r--r--lib/_emerge/EbuildPhase.py5
-rw-r--r--lib/portage/package/ebuild/doebuild.py5
4 files changed, 14 insertions, 5 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index c8fe3d0f1..2c3b985a9 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -186,9 +186,9 @@ export SANDBOX_ON=0
# Ensure that $PWD is sane whenever possible, to protect against
# exploitation of insecure search path for python -c in ebuilds.
# See bug #239560, bug #469338, and bug #595028.
-if [[ -d ${HOME} ]]; then
- # Use portage's temporary HOME directory if available.
- cd "${HOME}" || die
+# EAPI 8 requires us to use an empty directory here.
+if [[ -d ${PORTAGE_BUILDDIR}/empty ]]; then
+ cd "${PORTAGE_BUILDDIR}/empty" || die
else
cd "${PORTAGE_PYM_PATH}" || \
die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'"
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 6a0300165..71411d414 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -278,7 +278,8 @@ __dyn_clean() {
cd "${PORTAGE_PYM_PATH}" || \
die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'"
- rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir"
+ rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir" \
+ "${PORTAGE_BUILDDIR}/empty"
rm -f "${PORTAGE_BUILDDIR}/.installed"
if [[ $EMERGE_FROM = binary ]] || \
diff --git a/lib/_emerge/EbuildPhase.py b/lib/_emerge/EbuildPhase.py
index 26c770d29..6c2e737c4 100644
--- a/lib/_emerge/EbuildPhase.py
+++ b/lib/_emerge/EbuildPhase.py
@@ -21,7 +21,7 @@ from portage.util._dyn_libs.soname_deps_qa import (
)
from portage.package.ebuild.prepare_build_dirs import (_prepare_workdir,
_prepare_fake_distdir, _prepare_fake_filesdir)
-from portage.util import writemsg
+from portage.util import writemsg, ensure_dirs
from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
from portage.util._async.BuildLogger import BuildLogger
from portage.util.futures import asyncio
@@ -41,6 +41,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.elog:messages@elog_messages',
'portage.package.ebuild.doebuild:_check_build_log,' + \
'_post_phase_cmds,_post_phase_userpriv_perms,' + \
+ '_post_phase_emptydir_cleanup,' +
'_post_src_install_soname_symlinks,' + \
'_post_src_install_uid_fix,_postinst_bsdflags,' + \
'_post_src_install_write_metadata,' + \
@@ -89,6 +90,7 @@ class EbuildPhase(CompositeTask):
'logging', self.phase))
except OSError:
pass
+ ensure_dirs(os.path.join(self.settings["PORTAGE_BUILDDIR"], "empty"))
if self.phase in ('nofetch', 'pretend', 'setup'):
@@ -270,6 +272,7 @@ class EbuildPhase(CompositeTask):
settings = self.settings
_post_phase_userpriv_perms(settings)
+ _post_phase_emptydir_cleanup(settings)
if self.phase == "unpack":
# Bump WORKDIR timestamp, in case tar gave it a timestamp
diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py
index b1557edd7..0cbc2d01b 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -1770,6 +1770,11 @@ def _post_phase_userpriv_perms(mysettings):
filemode=0o600, filemask=0)
+def _post_phase_emptydir_cleanup(mysettings):
+ empty_dir = os.path.join(mysettings["PORTAGE_BUILDDIR"], "empty")
+ shutil.rmtree(empty_dir, ignore_errors=True)
+
+
def _check_build_log(mysettings, out=None):
"""
Search the content of $PORTAGE_LOG_FILE if it exists