Skip to content
Snippets Groups Projects
Commit 99ac4525 authored by Raoul Hidalgo Charman's avatar Raoul Hidalgo Charman
Browse files

Sandbox: use linux32 for x86-32 builds on x86-64 machines

  o _platform/linux.py: Add flag to send to sandbox bwrap when the build arch
    is x86-32 and the machines arch is x86-64.
  o sandbox/_sandboxbwrap.py: Use flag passed to start bwrap command with
    linux32 if set.
parent 5caa6496
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,9 @@ class Linux(Platform):
else:
self._user_ns_available = False
# Set linux32 option
self._linux32 = False
def create_sandbox(self, *args, **kwargs):
if not self._local_sandbox_available:
return self._create_dummy_sandbox(*args, **kwargs)
......@@ -78,11 +81,20 @@ class Linux(Platform):
# will match the host UID/GID.
return False
# We can't do builds for another host or architecture
if config.build_os != self.get_host_os():
# We can't do builds for another host or architecture except x86-32 on
# x86-64
host_os = self.get_host_os()
host_arch = self.get_host_arch()
if config.build_os != 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.")
elif config.build_arch != host_arch:
# We can use linux32 for building 32bit on 64bit machines
if (host_os == "Linux" and
((config.build_arch == "x86-32" and host_arch == "x86-64") or
(config.build_arch == "AArch32" and host_arch == "AArch64"))):
self._linux32 = True
else:
raise PlatformError("Configured architecture and host architecture don't match.")
return True
......@@ -109,6 +121,7 @@ class Linux(Platform):
kwargs['user_ns_available'] = self._user_ns_available
kwargs['die_with_parent_available'] = self._die_with_parent_available
kwargs['json_status_available'] = self._json_status_available
kwargs['linux32'] = self._linux32
return SandboxBwrap(*args, **kwargs)
def _check_user_ns_available(self):
......
......@@ -57,6 +57,7 @@ class SandboxBwrap(Sandbox):
self.user_ns_available = kwargs['user_ns_available']
self.die_with_parent_available = kwargs['die_with_parent_available']
self.json_status_available = kwargs['json_status_available']
self.linux32 = kwargs['linux32']
def _run(self, command, flags, *, cwd, env):
stdout, stderr = self._get_output()
......@@ -74,8 +75,14 @@ class SandboxBwrap(Sandbox):
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
root_mount_source = mount_map.get_mount_source('/')
# 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]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment