summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbderrahim Kitouni <akitouni@gnome.org>2019-11-17 10:06:28 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-08-03 10:14:28 +0100
commit405396cfe8139f81ebc0bf4a2cf716d7a5df4273 (patch)
treebd1644ab8a5555b70320fa5e86a58e5647e076c0
parentcdee3d0565e2d96952ad6b6c4c9478405f6f178a (diff)
downloadbuildstream-405396cfe8139f81ebc0bf4a2cf716d7a5df4273.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 af0c1a27c..f442d9c85 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2254,6 +2254,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)
@@ -2263,10 +2265,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