You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2022/02/24 03:29:15 UTC
[buildstream] branch bst-1 updated: _sandboxbwrap.py: try to support architectures that don't match host
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch bst-1
in repository https://gitbox.apache.org/repos/asf/buildstream.git
The following commit(s) were added to refs/heads/bst-1 by this push:
new 820c0b3 _sandboxbwrap.py: try to support architectures that don't match host
new 7172d17 Merge pull request #1576 from abderrahim/arch-test
820c0b3 is described below
commit 820c0b350160b7f16f97220b6547dfbbf7827f68
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Tue Jan 25 10:27:11 2022 +0100
_sandboxbwrap.py: try to support architectures that don't match host
This can be used by setting up the host to run binaries from different
architectures via binfmt and qemu-user.
---
buildstream/sandbox/_sandboxbwrap.py | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py
index 291fce1..df33442 100644
--- a/buildstream/sandbox/_sandboxbwrap.py
+++ b/buildstream/sandbox/_sandboxbwrap.py
@@ -49,6 +49,14 @@ class SandboxBwrap(Sandbox):
'/dev/zero'
]
+ ARCHITECTURES = {
+ 'amd64': 'x86_64',
+ 'arm64': 'aarch64',
+ 'i386': 'i686',
+ 'armhf': 'armv7l',
+ 'ppc64el': 'ppc64le',
+ }
+
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.user_ns_available = kwargs['user_ns_available']
@@ -58,11 +66,25 @@ class SandboxBwrap(Sandbox):
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
+ # We can't do builds for another host OS
if config.build_os != host_os:
raise SandboxError("Configured and host OS don't match.")
if config.build_arch != host_arch:
+ try:
+ archtest = utils.get_host_tool('arch-test')
+ supported = subprocess.getoutput(archtest).splitlines()
+ supported_architectures = map(self.ARCHITECTURES.get, supported, supported)
+ except utils.ProgramNotFoundError:
+ supported_architectures = []
+ if host_arch == "x86_64":
+ supported_architectures = ["i686"]
+ elif host_arch == "aarch64":
+ supported_architectures = ["armv7l"]
+
+ if config.build_arch not in supported_architectures:
+ raise SandboxError("Configured and host architecture don't match.")
+
if ((config.build_arch == "i686" and host_arch == "x86_64") or
(config.build_arch == "armv7l" and host_arch == "aarch64")):
# check whether linux32 is available
@@ -71,8 +93,6 @@ class SandboxBwrap(Sandbox):
self._linux32 = True
except utils.ProgramNotFoundError as e:
raise SandboxError("Configured and host architecture don't match.") from e
- else:
- raise SandboxError("Configured and host architecture don't match.")
def run(self, command, flags, *, cwd=None, env=None):
stdout, stderr = self._get_output()