diff options
author | Jürg Billeter <j@bitron.ch> | 2018-03-15 18:36:19 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-03-15 18:43:05 +0100 |
commit | a92f9ddbde28539ed78b3f3e260667e8171eb01f (patch) | |
tree | 473aa0966931cfa99b3db0fa1379e024580c73a3 /buildstream/sandbox | |
parent | 3f98a55d277207270a86a6a18a5a621edc7e5265 (diff) | |
download | buildstream-a92f9ddbde28539ed78b3f3e260667e8171eb01f.tar.gz |
_sandboxchroot.py: Ensure the cwd exists
This matches SandboxBwrap.
Diffstat (limited to 'buildstream/sandbox')
-rw-r--r-- | buildstream/sandbox/_sandboxchroot.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/buildstream/sandbox/_sandboxchroot.py b/buildstream/sandbox/_sandboxchroot.py index 4803e2181..c5e14e485 100644 --- a/buildstream/sandbox/_sandboxchroot.py +++ b/buildstream/sandbox/_sandboxchroot.py @@ -61,6 +61,7 @@ class SandboxChroot(Sandbox): # Create the mount map, this will tell us where # each mount point needs to be mounted from and to self.mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY) + root_mount_source = self.mount_map.get_mount_source('/') # Create a sysroot and run the command inside it with ExitStack() as stack: @@ -86,6 +87,11 @@ class SandboxChroot(Sandbox): else: stdin = stack.enter_context(open(os.devnull, 'r')) + # Ensure the cwd exists + if cwd is not None: + workdir = os.path.join(root_mount_source, cwd.lstrip(os.sep)) + os.makedirs(workdir, exist_ok=True) + status = self.chroot(rootfs, command, stdin, stdout, stderr, cwd, env, flags) |