diff options
author | Jürg Billeter <j@bitron.ch> | 2019-11-27 16:45:58 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-11-27 16:45:58 +0000 |
commit | 85a29b48ed3b8f524e2aaa815517a904b0e55c7b (patch) | |
tree | a3d3c4da642404d650266a5f4d5103e4185fbcc6 | |
parent | 5c54a559ec19c11f570aa7b3fb336c7afd61ef51 (diff) | |
parent | ba2aba842448aad4cd04901be4b12a740662c908 (diff) | |
download | buildstream-85a29b48ed3b8f524e2aaa815517a904b0e55c7b.tar.gz |
Merge branch 'juerg/sandbox-reapi' into 'master'
SandboxREAPI fixes
See merge request BuildStream/buildstream!1736
-rw-r--r-- | src/buildstream/sandbox/_sandboxreapi.py | 11 | ||||
-rw-r--r-- | src/buildstream/sandbox/sandbox.py | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/buildstream/sandbox/_sandboxreapi.py b/src/buildstream/sandbox/_sandboxreapi.py index 2d661c893..d2cd1b3bc 100644 --- a/src/buildstream/sandbox/_sandboxreapi.py +++ b/src/buildstream/sandbox/_sandboxreapi.py @@ -43,11 +43,20 @@ class SandboxREAPI(Sandbox): # set up virtual dircetory vdir = self.get_virtual_directory() + if not self._has_command(command[0], env): + raise SandboxCommandError( + "Staged artifacts do not provide command " "'{}'".format(command[0]), reason="missing-command" + ) + # Ensure working directory exists if len(cwd) > 1: assert cwd.startswith("/") vdir.descend(*cwd[1:].split(os.path.sep), create=True) + # Ensure directories required for sandboxed execution exist + for directory in ["dev", "proc", "tmp"]: + vdir.descend(directory, create=True) + # Create directories for all marked directories. This emulates # some of the behaviour of other sandboxes, which create these # to use as mount points. @@ -91,7 +100,7 @@ class SandboxREAPI(Sandbox): return remote_execution_pb2.Command( arguments=command, - working_directory=working_directory, + working_directory=working_directory[1:], environment_variables=environment_variables, output_files=[], output_directories=[output_directory], diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index c88cbf977..804759416 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -305,6 +305,8 @@ class Sandbox: cwd = self._get_work_directory(cwd=cwd) env = self._get_environment(cwd=cwd, env=env) + assert cwd.startswith("/"), "The working directory must be an absolute path" + # Convert single-string argument to a list if isinstance(command, str): command = [command] @@ -520,7 +522,7 @@ class Sandbox: # # Returns: # (str): The sandbox work directory - def _get_work_directory(self, *, cwd=None): + def _get_work_directory(self, *, cwd=None) -> str: return cwd or self.__cwd or "/" # _get_scratch_directory() |