summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildstream/_platform/linux.py15
-rw-r--r--buildstream/_platform/unix.py11
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