diff options
author | Phillip Smyth <phillipsmyth@Nexus-x240.dyn.ducie.codethink.co.uk> | 2018-06-06 12:19:42 +0100 |
---|---|---|
committer | Phillip Smyth <phillipsmyth@Nexus-x240.dyn.ducie.codethink.co.uk> | 2018-06-11 10:11:56 +0100 |
commit | 825f4a013392862b629a873d703e838da539d071 (patch) | |
tree | 84ea02fc631755b8179e9f4017e27d904b0e6cb6 /buildstream/element.py | |
parent | ea775fa30ba0087b8d2f8cb50ad00d41aa808fe3 (diff) | |
download | buildstream-issue-413-Add_sources_to_bst_shell.tar.gz |
Element.py: Added stage_sources function to stage the sources in a shell sandboxissue-413-Add_sources_to_bst_shell
Diffstat (limited to 'buildstream/element.py')
-rw-r--r-- | buildstream/element.py | 15 |
1 files changed, 9 insertions, 6 deletions
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 |