aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_emerge')
-rw-r--r--lib/_emerge/AbstractEbuildProcess.py33
-rw-r--r--lib/_emerge/MiscFunctionsProcess.py8
2 files changed, 27 insertions, 14 deletions
diff --git a/lib/_emerge/AbstractEbuildProcess.py b/lib/_emerge/AbstractEbuildProcess.py
index fd8a40cc1..1c1955cfe 100644
--- a/lib/_emerge/AbstractEbuildProcess.py
+++ b/lib/_emerge/AbstractEbuildProcess.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import errno
@@ -19,7 +19,6 @@ from portage.package.ebuild._ipc.ExitCommand import ExitCommand
from portage.package.ebuild._ipc.QueryCommand import QueryCommand
from portage import shutil, os
from portage.util.futures import asyncio
-from portage.util.futures.compat_coroutine import coroutine, coroutine_return
from portage.util._pty import _create_pty_or_pipe
from portage.util import apply_secpass_permissions
@@ -31,7 +30,7 @@ class AbstractEbuildProcess(SpawnProcess):
__slots__ = ('phase', 'settings',) + \
('_build_dir', '_build_dir_unlock', '_ipc_daemon',
- '_exit_command', '_exit_timeout_id')
+ '_exit_command', '_exit_timeout_id', '_start_future')
_phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',)
_phases_interactive_whitelist = ('config',)
@@ -56,10 +55,6 @@ class AbstractEbuildProcess(SpawnProcess):
self.phase = phase
def _start(self):
- self.scheduler.run_until_complete(self._async_start())
-
- @coroutine
- def _async_start(self):
need_builddir = self.phase not in self._phases_without_builddir
@@ -74,7 +69,7 @@ class AbstractEbuildProcess(SpawnProcess):
self._eerror(textwrap.wrap(msg, 72))
self.returncode = 1
self._async_wait()
- coroutine_return()
+ return
# Check if the cgroup hierarchy is in place. If it's not, mount it.
if (os.geteuid() == 0 and platform.system() == 'Linux'
@@ -147,7 +142,11 @@ class AbstractEbuildProcess(SpawnProcess):
if 'PORTAGE_BUILDDIR_LOCKED' not in self.settings:
self._build_dir = EbuildBuildDir(
scheduler=self.scheduler, settings=self.settings)
- yield self._build_dir.async_lock()
+ self._start_future = self._build_dir.async_lock()
+ self._start_future.add_done_callback(
+ functools.partial(self._start_post_builddir_lock,
+ start_ipc_daemon=start_ipc_daemon))
+ return
else:
self.settings.pop('PORTAGE_IPC_DAEMON', None)
else:
@@ -168,6 +167,22 @@ class AbstractEbuildProcess(SpawnProcess):
else:
self.settings.pop('PORTAGE_EBUILD_EXIT_FILE', None)
+ self._start_post_builddir_lock(start_ipc_daemon=start_ipc_daemon)
+
+ def _start_post_builddir_lock(self, lock_future=None, start_ipc_daemon=False):
+ if lock_future is not None:
+ if lock_future is not self._start_future:
+ raise AssertionError('lock_future is not self._start_future')
+ self._start_future = None
+ if lock_future.cancelled():
+ self._build_dir = None
+ self.cancelled = True
+ self._was_cancelled()
+ self._async_wait()
+ return
+
+ lock_future.result()
+
if start_ipc_daemon:
self.settings['PORTAGE_IPC_DAEMON'] = "1"
self._start_ipc_daemon()
diff --git a/lib/_emerge/MiscFunctionsProcess.py b/lib/_emerge/MiscFunctionsProcess.py
index cb0363820..89fd22635 100644
--- a/lib/_emerge/MiscFunctionsProcess.py
+++ b/lib/_emerge/MiscFunctionsProcess.py
@@ -1,9 +1,8 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.AbstractEbuildProcess import AbstractEbuildProcess
import portage
-from portage.util.futures.compat_coroutine import coroutine
portage.proxy.lazyimport.lazyimport(globals(),
'portage.package.ebuild.doebuild:spawn'
)
@@ -16,8 +15,7 @@ class MiscFunctionsProcess(AbstractEbuildProcess):
__slots__ = ('commands', 'ld_preload_sandbox')
- @coroutine
- def _async_start(self):
+ def _start(self):
settings = self.settings
portage_bin_path = settings["PORTAGE_BIN_PATH"]
misc_sh_binary = os.path.join(portage_bin_path,
@@ -28,7 +26,7 @@ class MiscFunctionsProcess(AbstractEbuildProcess):
self.settings.get("PORTAGE_BACKGROUND") != "subprocess":
self.logfile = settings.get("PORTAGE_LOG_FILE")
- yield AbstractEbuildProcess._async_start(self)
+ AbstractEbuildProcess._start(self)
def _spawn(self, args, **kwargs):
# If self.ld_preload_sandbox is None, default to free=False,