summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbderrahim Kitouni <akitouni@gnome.org>2019-11-17 10:06:28 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-07-19 15:22:28 +0100
commitafbfd91cc1b9958b018adf7d1da1c9b632de2d90 (patch)
treeb3c55e0525efa96f9365b216647421ff7df6a600
parent8d7ee1885e2c458c4f2edf113e5a2d990235f708 (diff)
downloadbuildstream-afbfd91cc1b9958b018adf7d1da1c9b632de2d90.tar.gz
element.py: add configuration for sandbox architecture and os
based on 1ad35fcd1bbb4a89e177da44303cf95e5a3b659d
-rw-r--r--buildstream/_versions.py2
-rw-r--r--buildstream/element.py11
-rw-r--r--buildstream/sandbox/_config.py10
3 files changed, 14 insertions, 9 deletions
diff --git a/buildstream/_versions.py b/buildstream/_versions.py
index 383429902..2110c2889 100644
--- a/buildstream/_versions.py
+++ b/buildstream/_versions.py
@@ -23,7 +23,7 @@
# This version is bumped whenever enhancements are made
# to the `project.conf` format or the core element format.
#
-BST_FORMAT_VERSION = 17
+BST_FORMAT_VERSION = 18
# The base BuildStream artifact version
diff --git a/buildstream/element.py b/buildstream/element.py
index ef871b7ad..a498e6e08 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2256,6 +2256,8 @@ class Element(Plugin):
project.ensure_fully_loaded()
sandbox_config = _yaml.node_chain_copy(project._sandbox)
+ host_os, _, _, _, host_arch = os.uname()
+
# The default config is already composited with the project overrides
sandbox_defaults = _yaml.node_get(self.__defaults, Mapping, 'sandbox', default_value={})
sandbox_defaults = _yaml.node_chain_copy(sandbox_defaults)
@@ -2265,10 +2267,13 @@ class Element(Plugin):
_yaml.node_final_assertions(sandbox_config)
# Sandbox config, unlike others, has fixed members so we should validate them
- _yaml.node_validate(sandbox_config, ['build-uid', 'build-gid'])
+ _yaml.node_validate(sandbox_config, ['build-uid', 'build-gid', 'build-os', 'build-arch'])
- return SandboxConfig(self.node_get_member(sandbox_config, int, 'build-uid'),
- self.node_get_member(sandbox_config, int, 'build-gid'))
+ return SandboxConfig(
+ int(self.node_subst_member(sandbox_config, 'build-uid')),
+ int(self.node_subst_member(sandbox_config, 'build-gid')),
+ self.node_subst_member(sandbox_config, 'build-os', default=host_os),
+ self.node_subst_member(sandbox_config, 'build-arch', default=host_arch))
# This makes a special exception for the split rules, which
# elements may extend but whos defaults are defined in the project.
diff --git a/buildstream/sandbox/_config.py b/buildstream/sandbox/_config.py
index 5debe24b2..457f92b3c 100644
--- a/buildstream/sandbox/_config.py
+++ b/buildstream/sandbox/_config.py
@@ -16,7 +16,6 @@
#
# Authors:
# Jim MacArthur <jim.macarthur@codethink.co.uk>
-import os
# SandboxConfig
@@ -24,9 +23,11 @@ import os
# A container for sandbox configuration data. We want the internals
# of this to be opaque, hence putting it in its own private file.
class SandboxConfig():
- def __init__(self, build_uid, build_gid):
+ def __init__(self, build_uid, build_gid, build_os=None, build_arch=None):
self.build_uid = build_uid
self.build_gid = build_gid
+ self.build_os = build_os
+ self.build_arch = build_arch
# get_unique_key():
#
@@ -45,10 +46,9 @@ class SandboxConfig():
# However this should be the right place to support
# such configurations in the future.
#
- operating_system, _, _, _, machine_arch = os.uname()
unique_key = {
- 'os': operating_system,
- 'arch': machine_arch
+ 'os': self.build_os,
+ 'arch': self.build_arch
}
# Avoid breaking cache key calculation with