From a92f9ddbde28539ed78b3f3e260667e8171eb01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Thu, 15 Mar 2018 18:36:19 +0100 Subject: _sandboxchroot.py: Ensure the cwd exists This matches SandboxBwrap. --- buildstream/sandbox/_sandboxchroot.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) -- cgit v1.2.1