summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbderrahim Kitouni <akitouni@gnome.org>2020-05-16 18:59:36 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-07-19 15:22:28 +0100
commit4f9a5156e7eb9cba0e552e0b11d5e70deabb308a (patch)
treebd1c7e600c41ea0993c5708b647ff1bd4b38aa27
parentafbfd91cc1b9958b018adf7d1da1c9b632de2d90 (diff)
downloadbuildstream-abderrahim/arch.tar.gz
sandbox: check for os and architectureabderrahim/arch
only allow builds of the same os and architecture and 32-bit on 64-bit based on e5d8c7d8a0ddbee8ff14 and b0603fb014c51660860c
-rw-r--r--buildstream/sandbox/_sandboxbwrap.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index 450f1913f..7aa8f31c8 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -53,6 +53,25 @@ class SandboxBwrap(Sandbox):
super().__init__(*args, **kwargs)
self.user_ns_available = kwargs['user_ns_available']
self.die_with_parent_available = kwargs['die_with_parent_available']
+ self.linux32 = False
+
+ host_os, _, _, _, host_arch = os.uname()
+ config = self._get_config()
+
+ # We can't do builds for another host or architecture except 32 bit on 64 bit
+ if config.build_os != host_os:
+ raise SandboxError("Configured and host OS don't match.")
+ elif config.build_arch != host_arch:
+ if ((config.build_arch == "i686" and host_arch == "x86_64") or
+ (config.build_arch == "armv7l" and host_arch == "aarch64")):
+ # check whether linux32 is available
+ try:
+ utils.get_host_tool('linux32')
+ self._linux32 = True
+ except utils.ProgramNotFoundError:
+ raise SandboxError("Configured and host architecture don't match.")
+ else:
+ raise SandboxError("Configured and host architecture don't match.")
def run(self, command, flags, *, cwd=None, env=None):
stdout, stderr = self._get_output()
@@ -84,8 +103,14 @@ class SandboxBwrap(Sandbox):
if cwd is None:
cwd = '/'
+ # start command with linux32 if needed
+ if self.linux32:
+ bwrap_command = [utils.get_host_tool('linux32')]
+ else:
+ bwrap_command = []
+
# Grab the full path of the bwrap binary
- bwrap_command = [utils.get_host_tool('bwrap')]
+ bwrap_command += [utils.get_host_tool('bwrap')]
for k, v in env.items():
bwrap_command += ['--setenv', k, v]