diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-02-16 18:18:51 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-02-16 18:18:51 +0900 |
commit | 6458d77aa1d35a5dd648c3fe3f94836d2d9e6282 (patch) | |
tree | 40c30bf0ddd928ad6656520ba49214b1c980f7bf | |
parent | f275cf64913f1ebeb66f035e1a7a808c3240651b (diff) | |
download | buildstream-proper-build-shells.tar.gz |
element.py: Create real build shell for `bst shell --build`proper-build-shells
Now we infer that a build shell is desired if `bst shell --build`
is specified, before there was no real build shell (only staged
sources in the build style shell).
Fixes issue #232
-rw-r--r-- | buildstream/element.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 8d69f07b0..d03f32c6c 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -1376,19 +1376,26 @@ class Element(Plugin): def _shell(self, scope=None, directory=None, command=None): with self._prepare_sandbox(scope, directory) as sandbox: - - # Override the element environment with some of - # the host environment and use that for the shell environment. - # - # XXX Hard code should be removed environment = self.get_environment() - environment = copy.copy(environment) - overrides = ['DISPLAY', 'DBUS_SESSION_BUS_ADDRESS'] - for override in overrides: - if os.environ.get(override) is not None: - environment[override] = os.environ.get(override) + flags = SandboxFlags.INTERACTIVE - flags = SandboxFlags.NETWORK_ENABLED | SandboxFlags.INTERACTIVE + if scope == Scope.RUN: + # If a testing sandbox was requested, override the element environment + # with some of the host environment and use that for the shell. + # + # XXX Hard code should be removed + environment = copy.copy(environment) + overrides = ['DISPLAY', 'DBUS_SESSION_BUS_ADDRESS'] + for override in overrides: + if os.environ.get(override) is not None: + environment[override] = os.environ.get(override) + + # Decide whether to create a build style sandbox or an open + # testing sandbox based on whether the build scope was requested + if scope == Scope.BUILD: + flags |= SandboxFlags.ROOT_READ_ONLY + elif scope == Scope.RUN: + flags |= SandboxFlags.NETWORK_ENABLED if command: argv = [arg for arg in command] |