diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-07-25 10:13:14 +0200 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-07-25 10:20:08 +0200 |
commit | 9a5e1d1d66ad7849f0121481433619ee2bd17e31 (patch) | |
tree | 9f8cc8144738e9def06c351877555fd3f3d4fa54 | |
parent | de162e43b11a743c346d569ffc8b19820cfaba11 (diff) | |
download | buildstream-valentindavid/498_bwrap_environment.tar.gz |
Set environment in bwrap command line instead of its environmentvalentindavid/498_bwrap_environment
Fixes #498
-rw-r--r-- | buildstream/sandbox/_sandboxbwrap.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py index 9ed677620..30ef2681f 100644 --- a/buildstream/sandbox/_sandboxbwrap.py +++ b/buildstream/sandbox/_sandboxbwrap.py @@ -87,6 +87,12 @@ class SandboxBwrap(Sandbox): # Grab the full path of the bwrap binary bwrap_command = [utils.get_host_tool('bwrap')] + for k, v in env.items(): + bwrap_command += ['--setenv', k, v] + for k, _ in os.environ.items(): + if k not in env: + bwrap_command += ['--unsetenv', k] + # Create a new pid namespace, this also ensures that any subprocesses # are cleaned up when the bwrap process exits. bwrap_command += ['--unshare-pid'] @@ -192,7 +198,7 @@ class SandboxBwrap(Sandbox): stdin = stack.enter_context(open(os.devnull, "r")) # Run bubblewrap ! - exit_code = self.run_bwrap(bwrap_command, stdin, stdout, stderr, env, + exit_code = self.run_bwrap(bwrap_command, stdin, stdout, stderr, os.environ, (flags & SandboxFlags.INTERACTIVE)) # Cleanup things which bwrap might have left behind, while |