summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildstream/_stream.py7
-rw-r--r--buildstream/element.py15
2 files changed, 15 insertions, 7 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 0680f2a1f..e4455febb 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -150,7 +150,12 @@ class Stream():
raise StreamError("Elements need to be built or downloaded before staging a shell environment",
detail="\n".join(missing_deps))
- return element._shell(scope, directory, mounts=mounts, isolate=isolate, prompt=prompt, command=command)
+ with element._prepare_sandbox(scope, directory) as sandbox:
+ for dep in self._pipeline.dependencies([element], scope):
+ dep.stage_sources(sandbox, dep.get_variable('build-root'))
+
+ return element._shell(scope, directory, mounts=mounts, isolate=isolate,
+ prompt=prompt, command=command, sandbox=sandbox)
# build()
#
diff --git a/buildstream/element.py b/buildstream/element.py
index e876eb120..e18152976 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -78,7 +78,7 @@ import re
import stat
import copy
from collections import Mapping, OrderedDict
-from contextlib import contextmanager
+from contextlib import contextmanager, ExitStack
from enum import Enum
import tempfile
import time
@@ -1243,7 +1243,7 @@ class Element(Plugin):
# is used to stage things by the `bst checkout` codepath
#
@contextmanager
- def _prepare_sandbox(self, scope, directory, integrate=True):
+ def _prepare_sandbox(self, scope, directory, integrate=True, dep=False):
with self.__sandbox(directory, config=self.__sandbox_config) as sandbox:
@@ -1263,8 +1263,8 @@ class Element(Plugin):
# once they are all staged and ready
if integrate:
with self.timed_activity("Integrating sandbox"):
- for dep in self.dependencies(scope):
- dep.integrate(sandbox)
+ for depend in self.dependencies(scope):
+ depend.integrate(sandbox)
yield sandbox
@@ -1677,9 +1677,12 @@ class Element(Plugin):
# Returns: Exit code
#
# If directory is not specified, one will be staged using scope
- def _shell(self, scope=None, directory=None, *, mounts=None, isolate=False, prompt=None, command=None):
+ def _shell(self, scope=None, directory=None, *, mounts=None, isolate=False,
+ prompt=None, command=None, sandbox=None):
- with self._prepare_sandbox(scope, directory) as sandbox:
+ with ExitStack() as stack:
+ if sandbox is None:
+ sandbox = stack.enter_context(self._prepare_sandbox(scope, directory))
environment = self.get_environment()
environment = copy.copy(environment)
flags = SandboxFlags.INTERACTIVE | SandboxFlags.ROOT_READ_ONLY