summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-23 20:37:13 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-02-25 00:20:14 +0900
commit306f82e2f0ee654859ee666be290f5bbf8985f52 (patch)
tree9faa0998f1bc84a8117f6cb7b686da2031d51868
parent89f280867dcf012d08d97a6911d912865e99f912 (diff)
downloadbuildstream-306f82e2f0ee654859ee666be290f5bbf8985f52.tar.gz
element.py: Use project shell configuration when launching shells.
Use the toplevel project configuration to decide: o What command to run for an interactive shell o Which environment variables to inherit from host environment when not running an isolated shell
-rw-r--r--buildstream/element.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index b4739c3bb..e50f570e5 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1382,6 +1382,11 @@ class Element(Plugin):
environment = copy.copy(environment)
flags = SandboxFlags.INTERACTIVE | SandboxFlags.ROOT_READ_ONLY
+ # Fetch the main toplevel project, in case this is a junctioned
+ # subproject, we want to use the rules defined by the main one.
+ context = self._get_context()
+ project = context._get_toplevel_project()
+
if prompt is not None:
environment['PS1'] = prompt
@@ -1392,19 +1397,15 @@ class Element(Plugin):
#
flags |= SandboxFlags.NETWORK_ENABLED | SandboxFlags.INHERIT_UID
- # 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
- overrides = ['DISPLAY', 'DBUS_SESSION_BUS_ADDRESS']
- for override in overrides:
- if os.environ.get(override) is not None:
- environment[override] = os.environ.get(override)
+ # Use the project defined list of env vars to inherit
+ for inherit in project._shell_env_inherit:
+ if os.environ.get(inherit) is not None:
+ environment[inherit] = os.environ.get(inherit)
if command:
argv = [arg for arg in command]
else:
- argv = ['sh', '-i']
+ argv = project._shell_command
self.status("Running command", detail=" ".join(argv))