Raoul Hidalgo Charman pushed to branch raoul/775-execution-environment-reqs at BuildStream / buildstream
Commits:
-
8774ec5c
by Raoul Hidalgo Charman at 2018-11-26T17:05:36Z
-
0b123066
by Raoul Hidalgo Charman at 2018-11-26T17:10:56Z
3 changed files:
Changes:
... | ... | @@ -25,6 +25,7 @@ from .. import utils |
25 | 25 |
from ..sandbox import SandboxDummy
|
26 | 26 |
|
27 | 27 |
from . import Platform
|
28 |
+from .._exceptions import PlatformError
|
|
28 | 29 |
|
29 | 30 |
|
30 | 31 |
class Linux(Platform):
|
... | ... | @@ -58,6 +59,9 @@ class Linux(Platform): |
58 | 59 |
else:
|
59 | 60 |
self._user_ns_available = False
|
60 | 61 |
|
62 |
+ # Set linux32 option
|
|
63 |
+ self._linux32 = False
|
|
64 |
+ |
|
61 | 65 |
def create_sandbox(self, *args, **kwargs):
|
62 | 66 |
if not self._local_sandbox_available:
|
63 | 67 |
return self._create_dummy_sandbox(*args, **kwargs)
|
... | ... | @@ -71,11 +75,23 @@ class Linux(Platform): |
71 | 75 |
|
72 | 76 |
if self._user_ns_available:
|
73 | 77 |
# User namespace support allows arbitrary build UID/GID settings.
|
74 |
- return True
|
|
75 |
- else:
|
|
78 |
+ pass
|
|
79 |
+ elif (config.build_uid != self._uid or config.build_gid != self._gid):
|
|
76 | 80 |
# Without user namespace support, the UID/GID in the sandbox
|
77 | 81 |
# will match the host UID/GID.
|
78 |
- return config.build_uid == self._uid and config.build_gid == self._gid
|
|
82 |
+ return False
|
|
83 |
+ |
|
84 |
+ # We can't do builds for another host or architecture except x86-32 on
|
|
85 |
+ # x86-64
|
|
86 |
+ if config.build_os != self.get_host_os():
|
|
87 |
+ raise PlatformError("Configured and host OS don't match.")
|
|
88 |
+ elif config.build_arch != self.get_host_arch():
|
|
89 |
+ if config.build_arch == "x86-32" and self.get_host_arch() == "x86-64":
|
|
90 |
+ self._linux32 = True
|
|
91 |
+ else:
|
|
92 |
+ raise PlatformError("Configured architecture and host architecture don't match.")
|
|
93 |
+ |
|
94 |
+ return True
|
|
79 | 95 |
|
80 | 96 |
################################################
|
81 | 97 |
# Private Methods #
|
... | ... | @@ -100,6 +116,7 @@ class Linux(Platform): |
100 | 116 |
kwargs['user_ns_available'] = self._user_ns_available
|
101 | 117 |
kwargs['die_with_parent_available'] = self._die_with_parent_available
|
102 | 118 |
kwargs['json_status_available'] = self._json_status_available
|
119 |
+ kwargs['linux32'] = self._linux32
|
|
103 | 120 |
return SandboxBwrap(*args, **kwargs)
|
104 | 121 |
|
105 | 122 |
def _check_user_ns_available(self):
|
... | ... | @@ -44,4 +44,13 @@ class Unix(Platform): |
44 | 44 |
def check_sandbox_config(self, config):
|
45 | 45 |
# With the chroot sandbox, the UID/GID in the sandbox
|
46 | 46 |
# will match the host UID/GID (typically 0/0).
|
47 |
- return config.build_uid == self._uid and config.build_gid == self._gid
|
|
47 |
+ if config.build_uid != self._uid or config.build_gid != self._gid:
|
|
48 |
+ return False
|
|
49 |
+ |
|
50 |
+ # Check host os and architecture match
|
|
51 |
+ if config.build_os != self.get_host_os():
|
|
52 |
+ raise PlatformError("Configured and host OS don't match.")
|
|
53 |
+ elif config.build_arch != self.get_host_arch():
|
|
54 |
+ raise PlatformError("Configured and host architecture don't match.")
|
|
55 |
+ |
|
56 |
+ return True
|
... | ... | @@ -57,6 +57,7 @@ class SandboxBwrap(Sandbox): |
57 | 57 |
self.user_ns_available = kwargs['user_ns_available']
|
58 | 58 |
self.die_with_parent_available = kwargs['die_with_parent_available']
|
59 | 59 |
self.json_status_available = kwargs['json_status_available']
|
60 |
+ self.linux32 = kwargs['linux32']
|
|
60 | 61 |
|
61 | 62 |
def run(self, command, flags, *, cwd=None, env=None):
|
62 | 63 |
stdout, stderr = self._get_output()
|
... | ... | @@ -84,8 +85,14 @@ class SandboxBwrap(Sandbox): |
84 | 85 |
mount_map = MountMap(self, flags & SandboxFlags.ROOT_READ_ONLY)
|
85 | 86 |
root_mount_source = mount_map.get_mount_source('/')
|
86 | 87 |
|
88 |
+ # start command with linux32 if needed
|
|
89 |
+ if self.linux32:
|
|
90 |
+ bwrap_command = ['linux32']
|
|
91 |
+ else:
|
|
92 |
+ bwrap_command = []
|
|
93 |
+ |
|
87 | 94 |
# Grab the full path of the bwrap binary
|
88 |
- bwrap_command = [utils.get_host_tool('bwrap')]
|
|
95 |
+ bwrap_command += [utils.get_host_tool('bwrap')]
|
|
89 | 96 |
|
90 | 97 |
for k, v in env.items():
|
91 | 98 |
bwrap_command += ['--setenv', k, v]
|