[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/package/ebuild/_config/

2023-08-19 Thread Sam James
commit: 2410f8d7dde2ac12de4ec040696bcbb51e09ce9f
Author: Sam James  gentoo  org>
AuthorDate: Sat Aug 19 13:54:08 2023 +
Commit: Sam James  gentoo  org>
CommitDate: Sat Aug 19 14:49:34 2023 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2410f8d7

save-ebuild-env.sh, special_env_vars.py: add https_proxy

For parity with http_proxy.

Bug: https://bugs.gentoo.org/691434
Bug: https://bugs.gentoo.org/835927
Bug: https://bugs.gentoo.org/911629
Signed-off-by: Sam James  gentoo.org>

 bin/save-ebuild-env.sh | 2 +-
 lib/portage/package/ebuild/_config/special_env_vars.py | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 20cd868665..3a2560aabf 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -28,7 +28,7 @@ __save_ebuild_env() {
 
# misc variables inherited from the calling environment
unset COLORTERM DISPLAY EDITOR LESS LESSOPEN LOGNAME LS_COLORS PAGER \
-   TERM TERMCAP USER ftp_proxy http_proxy no_proxy
+   TERM TERMCAP USER ftp_proxy http_proxy https_proxy no_proxy
 
# other variables inherited from the calling environment
unset CVS_RSH ECHANGELOG_USER GPG_AGENT_INFO \

diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py 
b/lib/portage/package/ebuild/_config/special_env_vars.py
index beb411188c..ef8f06abe3 100644
--- a/lib/portage/package/ebuild/_config/special_env_vars.py
+++ b/lib/portage/package/ebuild/_config/special_env_vars.py
@@ -215,6 +215,7 @@ environ_whitelist = frozenset(
 "USER",
 "ftp_proxy",
 "http_proxy",
+"https_proxy",
 "no_proxy",
 # tempdir settings
 "TMPDIR",



[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/package/ebuild/, lib/_emerge/

2021-06-11 Thread Michał Górny
commit: 689c79fc573879086aa809b62d9d4f4c8418f1fb
Author: Michał Górny  gentoo  org>
AuthorDate: Tue May 25 14:00:32 2021 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jun 11 17:48:06 2021 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=689c79fc

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  gentoo.org>
Signed-off-by: Michał Górny  gentoo.org>

 bin/ebuild.sh  | 6 +++---
 bin/phase-functions.sh | 3 ++-
 lib/_emerge/EbuildPhase.py | 5 -
 lib/portage/package/ebuild/doebuild.py | 5 +
 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



[gentoo-commits] proj/portage:master commit in: bin/, lib/portage/package/ebuild/

2019-01-03 Thread Zac Medico
commit: be2312f4f9bf854897431440734a765f5279c7d1
Author: Zac Medico  gentoo  org>
AuthorDate: Wed Jan  2 23:40:57 2019 +
Commit: Zac Medico  gentoo  org>
CommitDate: Thu Jan  3 08:24:40 2019 +
URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=be2312f4

ebuild.sh: sandbox write to ${PORTAGE_TMPDIR}/portage (bug 673738)

In ebuild.sh, grant sandbox write access directly to
${PORTAGE_TMPDIR}/portage, since write access to ${PORTAGE_TMPDIR}
itself is not needed. Also, remove the _check_temp_dir symlink
check from bug 378403, since a symlink is permissible if write
access is granted directly to ${PORTAGE_TMPDIR}/portage.

Bug: https://bugs.gentoo.org/673738
Bug: https://bugs.gentoo.org/378403
Signed-off-by: Zac Medico  gentoo.org>

 bin/ebuild.sh  |  4 ++--
 lib/portage/package/ebuild/doebuild.py | 27 ++-
 2 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 00524d019..978643af7 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -161,8 +161,8 @@ addwrite()   { __sb_append_var WRITE   "$@" ; }
 adddeny(){ __sb_append_var DENY"$@" ; }
 addpredict() { __sb_append_var PREDICT "$@" ; }
 
-addwrite "${PORTAGE_TMPDIR}"
-addread "/:${PORTAGE_TMPDIR}"
+addwrite "${PORTAGE_TMPDIR}/portage"
+addread "/:${PORTAGE_TMPDIR}/portage"
 [[ -n ${PORTAGE_GPG_DIR} ]] && addpredict "${PORTAGE_GPG_DIR}"
 
 # Avoid sandbox violations in temporary directories.

diff --git a/lib/portage/package/ebuild/doebuild.py 
b/lib/portage/package/ebuild/doebuild.py
index 2dd458835..baebb9a27 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -82,6 +82,7 @@ from portage.util import ( apply_recursive_permissions,
 from portage.util.cpuinfo import get_cpu_count
 from portage.util.lafilefixer import rewrite_lafile
 from portage.util.compression_probe import _compressors
+from portage.util.path import first_existing
 from portage.util.socks5 import get_socks5_proxy
 from portage.versions import _pkgsplit
 from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor
@@ -1296,31 +1297,7 @@ def _check_temp_dir(settings):
# as some people use a separate PORTAGE_TMPDIR mount
# we prefer that as the checks below would otherwise be pointless
# for those people.
-   tmpdir = os.path.realpath(settings["PORTAGE_TMPDIR"])
-   if os.path.exists(os.path.join(tmpdir, "portage")):
-   checkdir = os.path.realpath(os.path.join(tmpdir, "portage"))
-   if ("sandbox" in settings.features or
-   "usersandox" in settings.features) and \
-   not checkdir.startswith(tmpdir + os.sep):
-   msg = _("The 'portage' subdirectory of the directory "
-   "referenced by the PORTAGE_TMPDIR variable appears to 
be "
-   "a symlink. In order to avoid sandbox violations (see 
bug "
-   "#378403), you must adjust PORTAGE_TMPDIR instead of 
using "
-   "the symlink located at '%s'. A suitable PORTAGE_TMPDIR 
"
-   "setting would be '%s'.") % \
-   (os.path.join(tmpdir, "portage"), checkdir)
-   lines = []
-   lines.append("")
-   lines.append("")
-   lines.extend(wrap(msg, 72))
-   lines.append("")
-   for line in lines:
-   if line:
-   line = "!!! %s" % (line,)
-   writemsg("%s\n" % (line,), noiselevel=-1)
-   return 1
-   else:
-   checkdir = tmpdir
+   checkdir = first_existing(os.path.join(settings["PORTAGE_TMPDIR"], 
"portage"))
 
if not os.access(checkdir, os.W_OK):
writemsg(_("%s is not writable.\n"