diff options
-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) |