diff options
author | William Salmon <will.salmon@codethink.co.uk> | 2019-05-21 13:33:25 +0100 |
---|---|---|
committer | William Salmon <will.salmon@codethink.co.uk> | 2019-07-25 13:57:18 +0100 |
commit | 2f52b19ebc18fcefe70c8c04037b735b95c7bcf9 (patch) | |
tree | 978a52c61ec982a39dd650b12f12802671507ed5 /src | |
parent | 455323471868f653b0a305b9dc7d2a2dde2b9753 (diff) | |
download | buildstream-2f52b19ebc18fcefe70c8c04037b735b95c7bcf9.tar.gz |
Update sandbox to use virtual directories
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/sandbox/sandbox.py | 12 | ||||
-rw-r--r-- | src/buildstream/storage/_filebaseddirectory.py | 9 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/buildstream/sandbox/sandbox.py b/src/buildstream/sandbox/sandbox.py index 4cab7d6b8..3229b2dc6 100644 --- a/src/buildstream/sandbox/sandbox.py +++ b/src/buildstream/sandbox/sandbox.py @@ -548,13 +548,17 @@ class Sandbox(): # Returns: # (bool): Whether a command exists inside the sandbox. def _has_command(self, command, env=None): + vroot = self.get_virtual_directory() + command_as_parts = command.lstrip(os.sep).split(os.sep) if os.path.isabs(command): - return os.path.lexists(os.path.join( - self._root, command.lstrip(os.sep))) + return vroot._exists(*command_as_parts, follow_symlinks=True) + + if len(command_as_parts) > 1: + return False for path in env.get('PATH').split(':'): - if os.path.lexists(os.path.join( - self._root, path.lstrip(os.sep), command)): + path_as_parts = path.lstrip(os.sep).split(os.sep) + if vroot._exists(*path_as_parts, command, follow_symlinks=True): return True return False diff --git a/src/buildstream/storage/_filebaseddirectory.py b/src/buildstream/storage/_filebaseddirectory.py index a083f6507..07c23c192 100644 --- a/src/buildstream/storage/_filebaseddirectory.py +++ b/src/buildstream/storage/_filebaseddirectory.py @@ -285,3 +285,12 @@ class FileBasedDirectory(Directory): assert entry.type == _FileType.SYMLINK os.symlink(entry.target, dest_path) result.files_written.append(relative_pathname) + + def _exists(self, *path, follow_symlinks=False): + """This is very simple but mirrors the cas based storage were it is less trivial""" + if follow_symlinks: + # The lexists is not ideal as it cant spot broken symlinks but this is a long + # standing bug in buildstream as exists follow absolute syslinks to real root + # and incorrectly thinks they are broken the new casbaseddirectory dose not have this bug. + return os.path.lexists(os.path.join(self.external_directory, *path)) + raise ImplError("_exists can only follow symlinks in filebaseddirectory") |