[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/
commit: 67663e586320347e604727aef006bfe027bcd470 Author: Zac Medico gentoo org> AuthorDate: Mon Feb 12 02:10:52 2024 + Commit: Zac Medico gentoo org> CommitDate: Mon Feb 12 13:57:42 2024 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=67663e58 EbuildBuild: Execute EbuildFetchonly in subprocess Execute EbuildFetchonly in a subprocess since it needs to run the event loop itself (even for pretend mode since it may need to fetch mirror layouts as reported in bug 702154). Also remove obsolete loop.is_running() case in doebuild related to bug 601252, since it will fail if a mirror layout file needs to be fetched, so we should just assume that the event loop is not running. Set fetched = 2 for listonly (pretend) mode in the fetch function so that EbuildFetchonly will properly report success for this mode. Pass ebuild_path to EbuildFetchonly, and also remove setcpv call from EbuildFetchonly since it's called earlier in EbuildBuild. Bug: https://bugs.gentoo.org/924287 Signed-off-by: Zac Medico gentoo.org> lib/_emerge/EbuildBuild.py | 39 +- lib/_emerge/EbuildFetchonly.py | 10 +++-- lib/portage/package/ebuild/doebuild.py | 30 -- lib/portage/package/ebuild/fetch.py| 1 + 4 files changed, 33 insertions(+), 47 deletions(-) diff --git a/lib/_emerge/EbuildBuild.py b/lib/_emerge/EbuildBuild.py index 81cbfdc085..d4a4c6dacb 100644 --- a/lib/_emerge/EbuildBuild.py +++ b/lib/_emerge/EbuildBuild.py @@ -1,4 +1,4 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import functools @@ -22,6 +22,7 @@ from portage.package.ebuild.digestcheck import digestcheck from portage.package.ebuild.doebuild import _check_temp_dir from portage.package.ebuild._spawn_nofetch import SpawnNofetchWithoutBuilddir from portage.util._async.AsyncTaskFuture import AsyncTaskFuture +from portage.util.futures.executor.fork import ForkExecutor from portage.util.path import first_existing @@ -152,29 +153,25 @@ class EbuildBuild(CompositeTask): if opts.fetchonly: if opts.pretend: fetcher = EbuildFetchonly( +ebuild_path=self._ebuild_path, fetch_all=opts.fetch_all_uri, pkg=pkg, pretend=opts.pretend, settings=settings, ) -retval = fetcher.execute() -if retval == os.EX_OK: -self._current_task = None -self.returncode = os.EX_OK -self._async_wait() -else: -# For pretend mode, the convention it to execute -# pkg_nofetch and return a successful exitcode. -self._start_task( -SpawnNofetchWithoutBuilddir( -background=self.background, - portdb=self.pkg.root_config.trees[self._tree].dbapi, -ebuild_path=self._ebuild_path, -scheduler=self.scheduler, -settings=self.settings, +# Execute EbuildFetchonly in a subprocess since it needs to +# run the event loop itself (even for pretend mode since it +# may need to fetch mirror layouts as reported in bug 702154). +self._start_task( +AsyncTaskFuture( +background=self.background, +scheduler=self.scheduler, +future=self.scheduler.run_in_executor( +ForkExecutor(loop=self.scheduler), fetcher.execute ), -self._default_final_exit, -) +), +self._fetchonly_exit, +) return quiet_setting = settings.get("PORTAGE_QUIET", False) @@ -241,8 +238,12 @@ class EbuildBuild(CompositeTask): self._start_task(pre_clean_phase, self._pre_clean_exit) def _fetchonly_exit(self, fetcher): +if not fetcher.cancelled and isinstance(fetcher, AsyncTaskFuture): +# Set returncode from EbuildFetchonly.execute() result, since +# it can fail if it can't resolve a mirror for a file. +fetcher.returncode = fetcher.future.result() self._final_exit(fetcher) -if self.returncode != os.EX_OK: +if not self.cancelled and self.returncode != os.EX_OK: self.returncode = None portdb = self.pkg.root_config.trees[self._tree].dbapi self._start_task( diff --git a/lib/_emerge/EbuildFetchonly.py b/lib/_emerge/EbuildFetchonly.py index e887dd858d..c806122bea 100644 --- a/lib/_emerge/EbuildFetchonly.py +++
[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/
commit: 190e8ad1a238d20d782235dd1faa6b00d1b3fd4a Author: Zac Medico gentoo org> AuthorDate: Sat Feb 3 21:24:49 2024 + Commit: Zac Medico gentoo org> CommitDate: Wed Feb 7 00:55:45 2024 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=190e8ad1 doebuild: Add returnproc parameter and deprecate returnpid Raise NotImplementedError if returnproc is enabled for anything other than the "depend" phase, since corresponding returnpid support has long been deprecated. Bug: https://bugs.gentoo.org/916566 Signed-off-by: Zac Medico gentoo.org> lib/_emerge/EbuildMetadataPhase.py | 4 +-- lib/portage/package/ebuild/doebuild.py | 47 ++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/_emerge/EbuildMetadataPhase.py b/lib/_emerge/EbuildMetadataPhase.py index a7c9650d74..f4f685e81c 100644 --- a/lib/_emerge/EbuildMetadataPhase.py +++ b/lib/_emerge/EbuildMetadataPhase.py @@ -124,7 +124,7 @@ class EbuildMetadataPhase(SubProcess): mydbapi=self.portdb, tree="porttree", fd_pipes=fd_pipes, -returnpid=True, +returnproc=True, ) settings.pop("PORTAGE_PIPE_FD", None) @@ -137,7 +137,7 @@ class EbuildMetadataPhase(SubProcess): self._async_wait() return -self._proc = portage.process.Process(retval[0]) +self._proc = retval def _output_handler(self): while True: diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index e10b884e08..1c89af5ac8 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -19,6 +19,7 @@ import sys import tempfile from textwrap import wrap import time +from typing import Union import warnings import zlib @@ -246,14 +247,21 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): def _spawn_phase( -phase, settings, actionmap=None, returnpid=False, logfile=None, **kwargs +phase, +settings, +actionmap=None, +returnpid=False, +returnproc=False, +logfile=None, +**kwargs, ): -if returnpid: +if returnproc or returnpid: return _doebuild_spawn( phase, settings, actionmap=actionmap, returnpid=returnpid, +returnproc=returnproc, logfile=logfile, **kwargs, ) @@ -725,7 +733,8 @@ def doebuild( prev_mtimes=None, fd_pipes=None, returnpid=False, -): +returnproc=False, +) -> Union[int, portage.process.MultiprocessingProcess, list[int]]: """ Wrapper function that invokes specific ebuild phases through the spawning of ebuild.sh @@ -762,9 +771,15 @@ def doebuild( for example. @type fd_pipes: Dictionary @param returnpid: Return a list of process IDs for a successful spawn, or -an integer value if spawn is unsuccessful. NOTE: This requires the -caller clean up all returned PIDs. +an integer value if spawn is unsuccessful. This parameter is supported +supported only when mydo is "depend". NOTE: This requires the caller clean +up all returned PIDs. @type returnpid: Boolean +@param returnproc: Return a MultiprocessingProcess instance for a successful spawn, or +an integer value if spawn is unsuccessful. This parameter is supported +supported only when mydo is "depend". NOTE: This requires the caller to +asynchronously wait for the MultiprocessingProcess instance. +@type returnproc: Boolean @rtype: Boolean @return: 1. 0 for success @@ -867,17 +882,25 @@ def doebuild( writemsg("\n", noiselevel=-1) return 1 -if returnpid and mydo != "depend": +if (returnproc or returnpid) and mydo != "depend": # This case is not supported, since it bypasses the EbuildPhase class # which implements important functionality (including post phase hooks # and IPC for things like best/has_version and die). +if returnproc: +raise NotImplementedError(f"returnproc not implemented for phase {mydo}") warnings.warn( "portage.doebuild() called " "with returnpid parameter enabled. This usage will " "not be supported in the future.", -DeprecationWarning, +UserWarning, stacklevel=2, ) +elif returnpid: +warnings.warn( +"The portage.doebuild() returnpid parameter is deprecated and replaced by returnproc", +UserWarning, +stacklevel=1, +) if mydo == "fetchall": fetchall = 1 @@ -1027,10 +1050,14 @@ def doebuild( # get possible slot information from the deps file if mydo == "depend": -if not returnpid: -raise
[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/
commit: 0e4378fd18bcefde4472c7ae65e99578cf47dce6 Author: Zac Medico gentoo org> AuthorDate: Sun Feb 4 07:59:26 2024 + Commit: Zac Medico gentoo org> CommitDate: Sun Feb 4 08:00:31 2024 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0e4378fd Revert "doebuild: Add returnproc parameter and deprecate returnpid" This reverts commit 6aeee45d9b88d7dc8c450ba86975e4b017db203c. It triggered a "Bad file descriptor" during the instprep phase as reported in bug 923755. Bug: https://bugs.gentoo.org/923755 Signed-off-by: Zac Medico gentoo.org> lib/_emerge/EbuildMetadataPhase.py | 5 ++-- lib/portage/package/ebuild/doebuild.py | 47 -- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/lib/_emerge/EbuildMetadataPhase.py b/lib/_emerge/EbuildMetadataPhase.py index b8164f2b16..a7c9650d74 100644 --- a/lib/_emerge/EbuildMetadataPhase.py +++ b/lib/_emerge/EbuildMetadataPhase.py @@ -108,7 +108,6 @@ class EbuildMetadataPhase(SubProcess): fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK, ) -os.set_inheritable(slave_fd, True) fd_pipes[slave_fd] = slave_fd settings["PORTAGE_PIPE_FD"] = str(slave_fd) @@ -125,7 +124,7 @@ class EbuildMetadataPhase(SubProcess): mydbapi=self.portdb, tree="porttree", fd_pipes=fd_pipes, -returnproc=True, +returnpid=True, ) settings.pop("PORTAGE_PIPE_FD", None) @@ -138,7 +137,7 @@ class EbuildMetadataPhase(SubProcess): self._async_wait() return -self._proc = retval +self._proc = portage.process.Process(retval[0]) def _output_handler(self): while True: diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index 59a2b86a38..e10b884e08 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -19,7 +19,6 @@ import sys import tempfile from textwrap import wrap import time -from typing import Union import warnings import zlib @@ -247,21 +246,14 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): def _spawn_phase( -phase, -settings, -actionmap=None, -returnpid=False, -returnproc=False, -logfile=None, -**kwargs, +phase, settings, actionmap=None, returnpid=False, logfile=None, **kwargs ): -if returnproc or returnpid: +if returnpid: return _doebuild_spawn( phase, settings, actionmap=actionmap, returnpid=returnpid, -returnproc=returnproc, logfile=logfile, **kwargs, ) @@ -733,8 +725,7 @@ def doebuild( prev_mtimes=None, fd_pipes=None, returnpid=False, -returnproc=False, -) -> Union[int, portage.process.MultiprocessingProcess, list[int]]: +): """ Wrapper function that invokes specific ebuild phases through the spawning of ebuild.sh @@ -771,15 +762,9 @@ def doebuild( for example. @type fd_pipes: Dictionary @param returnpid: Return a list of process IDs for a successful spawn, or -an integer value if spawn is unsuccessful. This parameter is supported -supported only when mydo is "depend". NOTE: This requires the caller clean -up all returned PIDs. +an integer value if spawn is unsuccessful. NOTE: This requires the +caller clean up all returned PIDs. @type returnpid: Boolean -@param returnproc: Return a MultiprocessingProcess instance for a successful spawn, or -an integer value if spawn is unsuccessful. This parameter is supported -supported only when mydo is "depend". NOTE: This requires the caller to -asynchronously wait for the MultiprocessingProcess instance. -@type returnproc: Boolean @rtype: Boolean @return: 1. 0 for success @@ -882,25 +867,17 @@ def doebuild( writemsg("\n", noiselevel=-1) return 1 -if (returnproc or returnpid) and mydo != "depend": +if returnpid and mydo != "depend": # This case is not supported, since it bypasses the EbuildPhase class # which implements important functionality (including post phase hooks # and IPC for things like best/has_version and die). -if returnproc: -raise NotImplementedError(f"returnproc not implemented for phase {mydo}") warnings.warn( "portage.doebuild() called " "with returnpid parameter enabled. This usage will " "not be supported in the future.", -UserWarning, +DeprecationWarning, stacklevel=2, ) -elif returnpid: -warnings.warn( -"The portage.doebuild() returnpid paramenter is deprecated and replaced by returnproc", -
[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/
commit: 6aeee45d9b88d7dc8c450ba86975e4b017db203c Author: Zac Medico gentoo org> AuthorDate: Sat Feb 3 21:24:49 2024 + Commit: Zac Medico gentoo org> CommitDate: Sat Feb 3 22:40:34 2024 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=6aeee45d doebuild: Add returnproc parameter and deprecate returnpid Raise NotImplementedError if returnproc is enabled for anything other than the "depend" phase, since corresponding returnpid support has long been deprecated. Bug: https://bugs.gentoo.org/916566 Signed-off-by: Zac Medico gentoo.org> lib/_emerge/EbuildMetadataPhase.py | 5 ++-- lib/portage/package/ebuild/doebuild.py | 47 ++ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/lib/_emerge/EbuildMetadataPhase.py b/lib/_emerge/EbuildMetadataPhase.py index a7c9650d74..b8164f2b16 100644 --- a/lib/_emerge/EbuildMetadataPhase.py +++ b/lib/_emerge/EbuildMetadataPhase.py @@ -108,6 +108,7 @@ class EbuildMetadataPhase(SubProcess): fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK, ) +os.set_inheritable(slave_fd, True) fd_pipes[slave_fd] = slave_fd settings["PORTAGE_PIPE_FD"] = str(slave_fd) @@ -124,7 +125,7 @@ class EbuildMetadataPhase(SubProcess): mydbapi=self.portdb, tree="porttree", fd_pipes=fd_pipes, -returnpid=True, +returnproc=True, ) settings.pop("PORTAGE_PIPE_FD", None) @@ -137,7 +138,7 @@ class EbuildMetadataPhase(SubProcess): self._async_wait() return -self._proc = portage.process.Process(retval[0]) +self._proc = retval def _output_handler(self): while True: diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index e10b884e08..59a2b86a38 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -19,6 +19,7 @@ import sys import tempfile from textwrap import wrap import time +from typing import Union import warnings import zlib @@ -246,14 +247,21 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): def _spawn_phase( -phase, settings, actionmap=None, returnpid=False, logfile=None, **kwargs +phase, +settings, +actionmap=None, +returnpid=False, +returnproc=False, +logfile=None, +**kwargs, ): -if returnpid: +if returnproc or returnpid: return _doebuild_spawn( phase, settings, actionmap=actionmap, returnpid=returnpid, +returnproc=returnproc, logfile=logfile, **kwargs, ) @@ -725,7 +733,8 @@ def doebuild( prev_mtimes=None, fd_pipes=None, returnpid=False, -): +returnproc=False, +) -> Union[int, portage.process.MultiprocessingProcess, list[int]]: """ Wrapper function that invokes specific ebuild phases through the spawning of ebuild.sh @@ -762,9 +771,15 @@ def doebuild( for example. @type fd_pipes: Dictionary @param returnpid: Return a list of process IDs for a successful spawn, or -an integer value if spawn is unsuccessful. NOTE: This requires the -caller clean up all returned PIDs. +an integer value if spawn is unsuccessful. This parameter is supported +supported only when mydo is "depend". NOTE: This requires the caller clean +up all returned PIDs. @type returnpid: Boolean +@param returnproc: Return a MultiprocessingProcess instance for a successful spawn, or +an integer value if spawn is unsuccessful. This parameter is supported +supported only when mydo is "depend". NOTE: This requires the caller to +asynchronously wait for the MultiprocessingProcess instance. +@type returnproc: Boolean @rtype: Boolean @return: 1. 0 for success @@ -867,17 +882,25 @@ def doebuild( writemsg("\n", noiselevel=-1) return 1 -if returnpid and mydo != "depend": +if (returnproc or returnpid) and mydo != "depend": # This case is not supported, since it bypasses the EbuildPhase class # which implements important functionality (including post phase hooks # and IPC for things like best/has_version and die). +if returnproc: +raise NotImplementedError(f"returnproc not implemented for phase {mydo}") warnings.warn( "portage.doebuild() called " "with returnpid parameter enabled. This usage will " "not be supported in the future.", -DeprecationWarning, +UserWarning, stacklevel=2, ) +elif returnpid: +warnings.warn( +"The portage.doebuild() returnpid paramenter is deprecated and replaced by returnproc", +UserWarning,
[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/, bin/, lib/portage/tests/ebuild/
commit: 704bcd1581e49432f363f0eda648d58411775d7f Author: Zac Medico gentoo org> AuthorDate: Sun Nov 7 04:19:58 2021 + Commit: Zac Medico gentoo org> CommitDate: Wed Nov 10 23:10:53 2021 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=704bcd15 EbuildIpcDaemon: fix lock permission race Move ipc files to a .ipc subdirectory, with a setgid bit to prevent a lockfile group permission race. The lockfile function uses an appropriate open call with mode argument so that the lockfile is created atomically with both group ownership and group write bit. Bug: https://bugs.gentoo.org/468990 Signed-off-by: Zac Medico gentoo.org> bin/ebuild-ipc.py| 6 +++--- bin/phase-functions.sh | 4 ++-- lib/_emerge/AbstractEbuildProcess.py | 4 ++-- lib/_emerge/EbuildIpcDaemon.py | 2 +- lib/portage/package/ebuild/prepare_build_dirs.py | 9 + lib/portage/tests/ebuild/test_doebuild_spawn.py | 1 + lib/portage/tests/ebuild/test_ipc_daemon.py | 6 +++--- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py index 4999c043a..c24ba6f58 100755 --- a/bin/ebuild-ipc.py +++ b/bin/ebuild-ipc.py @@ -138,9 +138,9 @@ class EbuildIpc: def __init__(self): self.fifo_dir = os.environ["PORTAGE_BUILDDIR"] -self.ipc_in_fifo = os.path.join(self.fifo_dir, ".ipc_in") -self.ipc_out_fifo = os.path.join(self.fifo_dir, ".ipc_out") -self.ipc_lock_file = os.path.join(self.fifo_dir, ".ipc_lock") +self.ipc_in_fifo = os.path.join(self.fifo_dir, ".ipc", "in") +self.ipc_out_fifo = os.path.join(self.fifo_dir, ".ipc", "out") +self.ipc_lock_file = os.path.join(self.fifo_dir, ".ipc", "lock") def _daemon_is_alive(self): try: diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index d3221993d..5eb031805 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -291,10 +291,10 @@ __dyn_clean() { rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,logid,pretended,setuped,unpacked,prepared} \ "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged,instprepped} \ "$PORTAGE_BUILDDIR"/.die_hooks \ - "$PORTAGE_BUILDDIR"/.ipc_{in,out,lock} \ "$PORTAGE_BUILDDIR"/.exit_status - rm -rf "${PORTAGE_BUILDDIR}/build-info" + rm -rf "${PORTAGE_BUILDDIR}/build-info" \ + "${PORTAGE_BUILDDIR}/.ipc" rm -rf "${WORKDIR}" rm -f "${PORTAGE_BUILDDIR}/files" fi diff --git a/lib/_emerge/AbstractEbuildProcess.py b/lib/_emerge/AbstractEbuildProcess.py index 1b4e7759f..6d89d40f0 100644 --- a/lib/_emerge/AbstractEbuildProcess.py +++ b/lib/_emerge/AbstractEbuildProcess.py @@ -249,8 +249,8 @@ class AbstractEbuildProcess(SpawnProcess): def _init_ipc_fifos(self): -input_fifo = os.path.join(self.settings["PORTAGE_BUILDDIR"], ".ipc_in") -output_fifo = os.path.join(self.settings["PORTAGE_BUILDDIR"], ".ipc_out") +input_fifo = os.path.join(self.settings["PORTAGE_BUILDDIR"], ".ipc", "in") +output_fifo = os.path.join(self.settings["PORTAGE_BUILDDIR"], ".ipc", "out") for p in (input_fifo, output_fifo): diff --git a/lib/_emerge/EbuildIpcDaemon.py b/lib/_emerge/EbuildIpcDaemon.py index ee6fd7658..78594ff0a 100644 --- a/lib/_emerge/EbuildIpcDaemon.py +++ b/lib/_emerge/EbuildIpcDaemon.py @@ -81,7 +81,7 @@ class EbuildIpcDaemon(FifoIpcDaemon): # write something to the pipe just before we close it, and in that # case the write will be lost. Therefore, try for a non-blocking # lock, and only re-open the pipe if the lock is acquired. -lock_filename = os.path.join(os.path.dirname(self.input_fifo), ".ipc_lock") +lock_filename = os.path.join(os.path.dirname(self.input_fifo), "lock") try: lock_obj = lockfile(lock_filename, unlinkfile=True, flags=os.O_NONBLOCK) except TryAgain: diff --git a/lib/portage/package/ebuild/prepare_build_dirs.py b/lib/portage/package/ebuild/prepare_build_dirs.py index 659198905..32a770c99 100644 --- a/lib/portage/package/ebuild/prepare_build_dirs.py +++ b/lib/portage/package/ebuild/prepare_build_dirs.py @@ -102,6 +102,15 @@ def prepare_build_dirs(myroot=None, settings=None, cleanup=False): apply_secpass_permissions( mysettings[dir_key], uid=portage_uid, gid=portage_gid ) +# The setgid bit prevents a lockfile group permission race for bug #468990. +ipc_kwargs = {} +if portage.data.secpass >= 1: +ipc_kwargs["gid"] = portage_gid +ipc_kwargs["mode"] = 0o2770 +ensure_dirs( +os.path.join(mysettings["PORTAGE_BUILDDIR"], ".ipc"), +
[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/_parallel_manifest/, ...
commit: 709826c0896120e8b3d9995d71678c0b9b290e4c Author: Alec Warner gentoo org> AuthorDate: Wed Jul 29 18:27:16 2020 + Commit: Zac Medico gentoo org> CommitDate: Thu Jul 30 04:05:06 2020 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=709826c0 Fix R1705. The codebase appears to have this pattern like: if foo == bar: return a elif foo == baz: return b else: return c This can often be rewritten as: if foo == bar: return a if foo == baz: return b return c Closes: https://github.com/gentoo/portage/pull/592 Signed-off-by: Alec Warner gentoo.org> Signed-off-by: Zac Medico gentoo.org> lib/_emerge/EbuildBuild.py | 24 ++-- lib/_emerge/MergeListItem.py | 2 +- lib/_emerge/Package.py | 3 +- lib/_emerge/actions.py | 11 +- lib/_emerge/depgraph.py| 131 ++--- lib/_emerge/main.py| 4 +- lib/_emerge/resolver/backtracking.py | 3 +- lib/_emerge/resolver/output.py | 34 +++--- lib/_emerge/resolver/slot_collision.py | 32 +++-- lib/_emerge/unmerge.py | 4 +- lib/portage/_emirrordist/FetchTask.py | 36 +++--- lib/portage/_global_updates.py | 3 +- lib/portage/_legacy_globals.py | 2 +- lib/portage/_sets/__init__.py | 7 +- lib/portage/_sets/base.py | 3 +- lib/portage/_sets/dbapi.py | 43 --- lib/portage/cache/ebuild_xattr.py | 3 +- lib/portage/cache/mappings.py | 4 +- lib/portage/cache/sqlite.py| 5 +- lib/portage/checksum.py| 2 +- lib/portage/cvstree.py | 5 +- lib/portage/data.py| 5 +- lib/portage/dbapi/IndexedPortdb.py | 3 +- lib/portage/dbapi/IndexedVardb.py | 3 +- lib/portage/dbapi/bintree.py | 14 +-- lib/portage/dbapi/cpv_expand.py| 6 +- lib/portage/dbapi/porttree.py | 5 +- lib/portage/dbapi/vartree.py | 6 +- lib/portage/dbapi/virtual.py | 3 +- lib/portage/debug.py | 12 +- lib/portage/dep/__init__.py| 22 ++-- lib/portage/dep/_dnf.py| 2 +- lib/portage/dep/dep_check.py | 13 +- lib/portage/elog/mod_mail_summary.py | 2 +- lib/portage/exception.py | 3 +- lib/portage/getbinpkg.py | 8 +- lib/portage/glsa.py| 5 +- lib/portage/locks.py | 15 ++- lib/portage/manifest.py| 7 +- lib/portage/output.py | 30 +++-- lib/portage/package/ebuild/_ipc/QueryCommand.py| 15 ++- .../ebuild/_parallel_manifest/ManifestProcess.py | 3 +- lib/portage/package/ebuild/config.py | 17 ++- lib/portage/package/ebuild/doebuild.py | 8 +- lib/portage/package/ebuild/fetch.py| 10 +- lib/portage/package/ebuild/getmaskingreason.py | 9 +- lib/portage/package/ebuild/getmaskingstatus.py | 2 +- lib/portage/repository/config.py | 3 +- lib/portage/sync/controller.py | 3 +- lib/portage/sync/modules/git/git.py| 33 +++--- lib/portage/tests/util/futures/test_retry.py | 12 +- lib/portage/util/__init__.py | 33 ++ lib/portage/util/_async/PipeLogger.py | 89 +++--- lib/portage/util/_dyn_libs/LinkageMapELF.py| 33 +++--- lib/portage/util/_urlopen.py | 42 +++ lib/portage/util/changelog.py | 19 ++- lib/portage/util/futures/_asyncio/__init__.py | 5 +- lib/portage/util/futures/unix_events.py| 9 +- lib/portage/util/lafilefixer.py| 3 +- lib/portage/versions.py| 17 ++- 60 files changed, 409 insertions(+), 481 deletions(-) diff --git a/lib/_emerge/EbuildBuild.py b/lib/_emerge/EbuildBuild.py index a575835b7..4da815988 100644 --- a/lib/_emerge/EbuildBuild.py +++ b/lib/_emerge/EbuildBuild.py @@ -159,18 +159,18 @@ class EbuildBuild(CompositeTask): settings=self.settings), self._default_final_exit) return - else: - fetcher = EbuildFetcher( -
[gentoo-commits] proj/portage:master commit in: lib/_emerge/, lib/portage/package/ebuild/
commit: bbfc36befdeed60f29c17d80d7766fd0da402d61 Author: Zac Medico gentoo org> AuthorDate: Tue Jan 8 04:45:52 2019 + Commit: Zac Medico gentoo org> CommitDate: Tue Jan 8 09:12:11 2019 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=bbfc36be pid-sandbox: whitelist selected pkg_* phases (bug 673794) Whitelist the same phases that are whitelisted for FEATURES=cgroup, since pid-sandbox is less valuable and is likely to have unintended consenquences during these phases. Bug: https://bugs.gentoo.org/673794 Reviewed-by: Michał Górny gentoo.org> Signed-off-by: Zac Medico gentoo.org> lib/_emerge/AbstractEbuildProcess.py | 9 ++--- lib/portage/package/ebuild/doebuild.py | 8 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/_emerge/AbstractEbuildProcess.py b/lib/_emerge/AbstractEbuildProcess.py index bda0bd83f..ddf04e9b3 100644 --- a/lib/_emerge/AbstractEbuildProcess.py +++ b/lib/_emerge/AbstractEbuildProcess.py @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2019 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import errno @@ -22,6 +22,10 @@ from portage.util.futures import asyncio from portage.util._pty import _create_pty_or_pipe from portage.util import apply_secpass_permissions +portage.proxy.lazyimport.lazyimport(globals(), + 'portage.package.ebuild.doebuild:_global_pid_phases', +) + class AbstractEbuildProcess(SpawnProcess): __slots__ = ('phase', 'settings',) + \ @@ -30,7 +34,6 @@ class AbstractEbuildProcess(SpawnProcess): _phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',) _phases_interactive_whitelist = ('config',) - _phases_without_cgroup = ('preinst', 'postinst', 'prerm', 'postrm', 'config') # Number of milliseconds to allow natural exit of the ebuild # process after it has called the exit command via IPC. It @@ -71,7 +74,7 @@ class AbstractEbuildProcess(SpawnProcess): # Check if the cgroup hierarchy is in place. If it's not, mount it. if (os.geteuid() == 0 and platform.system() == 'Linux' and 'cgroup' in self.settings.features - and self.phase not in self._phases_without_cgroup): + and self.phase not in _global_pid_phases): cgroup_root = '/sys/fs/cgroup' cgroup_portage = os.path.join(cgroup_root, 'portage') diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index baebb9a27..f11923595 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -1,4 +1,4 @@ -# Copyright 2010-2018 Gentoo Authors +# Copyright 2010-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 from __future__ import unicode_literals @@ -110,6 +110,9 @@ _ipc_phases = frozenset([ "preinst", "postinst", "prerm", "postrm", ]) +# phases which execute in the global PID namespace +_global_pid_phases = frozenset(['preinst', 'postinst', 'prerm', 'postrm', 'config']) + # phases in which networking access is allowed _networked_phases = frozenset([ # for VCS fetching @@ -153,7 +156,8 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): kwargs['networked'] = 'network-sandbox' not in settings.features or \ phase in _networked_phases or \ 'network-sandbox' in settings['PORTAGE_RESTRICT'].split() - kwargs['pidns'] = 'pid-sandbox' in settings.features + kwargs['pidns'] = ('pid-sandbox' in settings.features and + phase not in _global_pid_phases) if phase == 'depend': kwargs['droppriv'] = 'userpriv' in settings.features