diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2018-11-26 16:15:52 +0000 |
---|---|---|
committer | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2018-12-05 10:44:02 +0000 |
commit | e5d8c7d8a0ddbee8ff14b73960809831b9a9fbb2 (patch) | |
tree | 4b8c851193f50410a1fdbda60732a96180d9458c /buildstream | |
parent | defec11250773152c65dc6b05239d58f90d0a217 (diff) | |
download | buildstream-e5d8c7d8a0ddbee8ff14b73960809831b9a9fbb2.tar.gz |
_platform: Add checks for os and architecture
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_platform/linux.py | 15 | ||||
-rw-r--r-- | buildstream/_platform/unix.py | 11 |
2 files changed, 22 insertions, 4 deletions
diff --git a/buildstream/_platform/linux.py b/buildstream/_platform/linux.py index 33f3966c1..f9033914c 100644 --- a/buildstream/_platform/linux.py +++ b/buildstream/_platform/linux.py @@ -25,6 +25,7 @@ from .. import utils from ..sandbox import SandboxDummy from . import Platform +from .._exceptions import PlatformError class Linux(Platform): @@ -71,11 +72,19 @@ class Linux(Platform): if self._user_ns_available: # User namespace support allows arbitrary build UID/GID settings. - return True - else: + pass + elif (config.build_uid != self._uid or config.build_gid != self._gid): # Without user namespace support, the UID/GID in the sandbox # will match the host UID/GID. - return config.build_uid == self._uid and config.build_gid == self._gid + return False + + # We can't do builds for another host or architecture + if config.build_os != self.get_host_os(): + raise PlatformError("Configured and host OS don't match.") + elif config.build_arch != self.get_host_arch(): + raise PlatformError("Configured and host architecture don't match.") + + return True ################################################ # Private Methods # diff --git a/buildstream/_platform/unix.py b/buildstream/_platform/unix.py index d2acefe65..bbc55c3af 100644 --- a/buildstream/_platform/unix.py +++ b/buildstream/_platform/unix.py @@ -44,4 +44,13 @@ class Unix(Platform): def check_sandbox_config(self, config): # With the chroot sandbox, the UID/GID in the sandbox # will match the host UID/GID (typically 0/0). - return config.build_uid == self._uid and config.build_gid == self._gid + if config.build_uid != self._uid or config.build_gid != self._gid: + return False + + # Check host os and architecture match + if config.build_os != self.get_host_os(): + raise PlatformError("Configured and host OS don't match.") + elif config.build_arch != self.get_host_arch(): + raise PlatformError("Configured and host architecture don't match.") + + return True |