Raoul Hidalgo Charman pushed to branch raoul/775-execution-environment-reqs at BuildStream / buildstream
Commits:
-
ef67bd9a
by Raoul Hidalgo Charman at 2018-11-23T14:19:15Z
-
6973d07b
by Raoul Hidalgo Charman at 2018-11-23T14:19:23Z
-
610b4246
by Raoul Hidalgo Charman at 2018-11-23T14:19:23Z
-
c3abf6d7
by Raoul Hidalgo Charman at 2018-11-23T14:19:23Z
19 changed files:
- buildstream/_options/optionarch.py
- + buildstream/_options/optionos.py
- buildstream/_options/optionpool.py
- buildstream/sandbox/_sandboxremote.py
- doc/examples/flatpak-autotools/elements/base/sdk.bst
- doc/examples/flatpak-autotools/project.conf
- tests/examples/autotools.py
- tests/examples/flatpak-autotools.py
- tests/format/list-directive-type-error/project.conf
- tests/format/option-arch/element.bst
- tests/format/option-arch/project.conf
- + tests/format/option-os/element.bst
- + tests/format/option-os/project.conf
- tests/format/optionarch.py
- + tests/format/optionos.py
- tests/integration/base/generate-base.sh
- tests/integration/project/elements/base/base-alpine.bst
- tests/integration/project/project.conf
- tests/testutils/site.py
Changes:
... | ... | @@ -17,8 +17,8 @@ |
17 | 17 |
# Authors:
|
18 | 18 |
# Tristan Van Berkom <tristan vanberkom codethink co uk>
|
19 | 19 |
|
20 |
-import os
|
|
21 | 20 |
from .optionenum import OptionEnum
|
21 |
+from ..utils import arch_from_uname
|
|
22 | 22 |
|
23 | 23 |
|
24 | 24 |
# OptionArch
|
... | ... | @@ -41,8 +41,7 @@ class OptionArch(OptionEnum): |
41 | 41 |
super(OptionArch, self).load(node, allow_default_definition=False)
|
42 | 42 |
|
43 | 43 |
def load_default_value(self, node):
|
44 |
- _, _, _, _, machine_arch = os.uname()
|
|
45 |
- return machine_arch
|
|
44 |
+ return arch_from_uname()
|
|
46 | 45 |
|
47 | 46 |
def resolve(self):
|
48 | 47 |
|
1 |
+ |
|
2 |
+#
|
|
3 |
+# Copyright (C) 2017 Codethink Limited
|
|
4 |
+#
|
|
5 |
+# This program is free software; you can redistribute it and/or
|
|
6 |
+# modify it under the terms of the GNU Lesser General Public
|
|
7 |
+# License as published by the Free Software Foundation; either
|
|
8 |
+# version 2 of the License, or (at your option) any later version.
|
|
9 |
+#
|
|
10 |
+# This library is distributed in the hope that it will be useful,
|
|
11 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 |
+# Lesser General Public License for more details.
|
|
14 |
+#
|
|
15 |
+# You should have received a copy of the GNU Lesser General Public
|
|
16 |
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
+#
|
|
18 |
+# Authors:
|
|
19 |
+# Raoul Hidalgo Charman <raoul hidalgocharman codethink co uk>
|
|
20 |
+ |
|
21 |
+import os
|
|
22 |
+from .optionenum import OptionEnum
|
|
23 |
+ |
|
24 |
+ |
|
25 |
+# OptionOS
|
|
26 |
+#
|
|
27 |
+class OptionOS(OptionEnum):
|
|
28 |
+ |
|
29 |
+ OPTION_TYPE = 'os'
|
|
30 |
+ |
|
31 |
+ def load(self, node):
|
|
32 |
+ super(OptionOS, self).load(node, allow_default_definition=False)
|
|
33 |
+ |
|
34 |
+ def load_default_value(self, node):
|
|
35 |
+ return os.uname()[0]
|
|
36 |
+ |
|
37 |
+ def resolve(self):
|
|
38 |
+ |
|
39 |
+ # Validate that the default OS reported by uname() is explicitly
|
|
40 |
+ # supported by the project, if not overridden by user config or cli.
|
|
41 |
+ self.validate(self.value)
|
... | ... | @@ -28,6 +28,7 @@ from .optionenum import OptionEnum |
28 | 28 |
from .optionflags import OptionFlags
|
29 | 29 |
from .optioneltmask import OptionEltMask
|
30 | 30 |
from .optionarch import OptionArch
|
31 |
+from .optionos import OptionOS
|
|
31 | 32 |
|
32 | 33 |
|
33 | 34 |
_OPTION_TYPES = {
|
... | ... | @@ -36,6 +37,7 @@ _OPTION_TYPES = { |
36 | 37 |
OptionFlags.OPTION_TYPE: OptionFlags,
|
37 | 38 |
OptionEltMask.OPTION_TYPE: OptionEltMask,
|
38 | 39 |
OptionArch.OPTION_TYPE: OptionArch,
|
40 |
+ OptionOS.OPTION_TYPE: OptionOS,
|
|
39 | 41 |
}
|
40 | 42 |
|
41 | 43 |
|
... | ... | @@ -65,13 +65,20 @@ class SandboxRemote(Sandbox): |
65 | 65 |
EnvironmentVariable(name=k, value=v)
|
66 | 66 |
for (k, v) in environment.items()]
|
67 | 67 |
|
68 |
+ config = self._get_config()
|
|
69 |
+ platform_variables = remote_execution_pb2.Platform()
|
|
70 |
+ platform_variables.properties.extend([remote_execution_pb2.Platform.
|
|
71 |
+ Property(name="os", value=config.build_os),
|
|
72 |
+ remote_execution_pb2.Platform.
|
|
73 |
+ Property(name="arch", value=config.build_arch)])
|
|
74 |
+ |
|
68 | 75 |
# Create and send the Command object.
|
69 | 76 |
remote_command = remote_execution_pb2.Command(arguments=command,
|
70 | 77 |
working_directory=working_directory,
|
71 | 78 |
environment_variables=environment_variables,
|
72 | 79 |
output_files=[],
|
73 | 80 |
output_directories=[self._output_directory],
|
74 |
- platform=None)
|
|
81 |
+ platform=platform_variables)
|
|
75 | 82 |
context = self._get_context()
|
76 | 83 |
cascache = context.artifactcache
|
77 | 84 |
# Upload the Command message to the remote CAS server
|
... | ... | @@ -5,10 +5,10 @@ sources: |
5 | 5 |
url: gnomesdk:repo/
|
6 | 6 |
gpg-key: keys/gnome-sdk.gpg
|
7 | 7 |
(?):
|
8 |
- - arch == "x86_64":
|
|
8 |
+ - arch == "x86-64":
|
|
9 | 9 |
track: runtime/org.freedesktop.BaseSdk/x86_64/1.4
|
10 | 10 |
ref: 0d9d255d56b08aeaaffb1c820eef85266eb730cb5667e50681185ccf5cd7c882
|
11 |
- - arch == "i386":
|
|
11 |
+ - arch == "x86-32":
|
|
12 | 12 |
track: runtime/org.freedesktop.BaseSdk/i386/1.4
|
13 | 13 |
ref: 16036b747c1ec8e7fe291f5b1f667cb942f0267d08fcad962e9b7627d6cf1981
|
14 | 14 |
config:
|
... | ... | @@ -10,6 +10,6 @@ options: |
10 | 10 |
type: arch
|
11 | 11 |
description: The machine architecture
|
12 | 12 |
values:
|
13 |
- - x86_64
|
|
14 |
- - i386
|
|
13 |
+ - x86-64
|
|
14 |
+ - x86-32
|
|
15 | 15 |
|
... | ... | @@ -13,8 +13,8 @@ DATA_DIR = os.path.join( |
13 | 13 |
|
14 | 14 |
|
15 | 15 |
# Tests a build of the autotools amhello project on a alpine-linux base runtime
|
16 |
-@pytest.mark.skipif(MACHINE_ARCH != 'x86_64',
|
|
17 |
- reason='Examples are writtent for x86_64')
|
|
16 |
+@pytest.mark.skipif(MACHINE_ARCH != 'x86-64',
|
|
17 |
+ reason='Examples are writtent for x86-64')
|
|
18 | 18 |
@pytest.mark.skipif(not IS_LINUX or not HAVE_BWRAP, reason='Only available on linux with bubblewrap')
|
19 | 19 |
@pytest.mark.datafiles(DATA_DIR)
|
20 | 20 |
def test_autotools_build(cli, tmpdir, datafiles):
|
... | ... | @@ -38,8 +38,8 @@ def test_autotools_build(cli, tmpdir, datafiles): |
38 | 38 |
|
39 | 39 |
|
40 | 40 |
# Test running an executable built with autotools.
|
41 |
-@pytest.mark.skipif(MACHINE_ARCH != 'x86_64',
|
|
42 |
- reason='Examples are writtent for x86_64')
|
|
41 |
+@pytest.mark.skipif(MACHINE_ARCH != 'x86-64',
|
|
42 |
+ reason='Examples are writtent for x86-64')
|
|
43 | 43 |
@pytest.mark.skipif(not IS_LINUX or not HAVE_BWRAP, reason='Only available on linux with bubblewrap')
|
44 | 44 |
@pytest.mark.datafiles(DATA_DIR)
|
45 | 45 |
def test_autotools_run(cli, tmpdir, datafiles):
|
... | ... | @@ -32,8 +32,8 @@ def workaround_setuptools_bug(project): |
32 | 32 |
|
33 | 33 |
# Test that a build upon flatpak runtime 'works' - we use the autotools sample
|
34 | 34 |
# amhello project for this.
|
35 |
-@pytest.mark.skipif(MACHINE_ARCH != 'x86_64',
|
|
36 |
- reason='Examples are writtent for x86_64')
|
|
35 |
+@pytest.mark.skipif(MACHINE_ARCH != 'x86-64',
|
|
36 |
+ reason='Examples are writtent for x86-64')
|
|
37 | 37 |
@pytest.mark.skipif(not IS_LINUX or not HAVE_OSTREE, reason='Only available on linux with ostree')
|
38 | 38 |
@pytest.mark.datafiles(DATA_DIR)
|
39 | 39 |
def test_autotools_build(cli, tmpdir, datafiles):
|
... | ... | @@ -57,8 +57,8 @@ def test_autotools_build(cli, tmpdir, datafiles): |
57 | 57 |
|
58 | 58 |
|
59 | 59 |
# Test running an executable built with autotools
|
60 |
-@pytest.mark.skipif(MACHINE_ARCH != 'x86_64',
|
|
61 |
- reason='Examples are writtent for x86_64')
|
|
60 |
+@pytest.mark.skipif(MACHINE_ARCH != 'x86-64',
|
|
61 |
+ reason='Examples are writtent for x86-64')
|
|
62 | 62 |
@pytest.mark.skipif(not IS_LINUX or not HAVE_OSTREE, reason='Only available on linux with ostree')
|
63 | 63 |
@pytest.mark.datafiles(DATA_DIR)
|
64 | 64 |
def test_autotools_run(cli, tmpdir, datafiles):
|
... | ... | @@ -4,4 +4,4 @@ options: |
4 | 4 |
arch:
|
5 | 5 |
type: arch
|
6 | 6 |
description: Example architecture option
|
7 |
- values: [ x86_32, x86_64, aarch64 ]
|
|
7 |
+ values: [ x86-32, x86-64, AArch64 ]
|
|
\ No newline at end of file |
... | ... | @@ -2,7 +2,7 @@ kind: autotools |
2 | 2 |
variables:
|
3 | 3 |
result: "Nothing"
|
4 | 4 |
(?):
|
5 |
- - machine_arch == "arm":
|
|
5 |
+ - machine_arch == "AArch32":
|
|
6 | 6 |
result: "Army"
|
7 |
- - machine_arch == "aarch64":
|
|
7 |
+ - machine_arch == "AArch64":
|
|
8 | 8 |
result: "Aarchy"
|
... | ... | @@ -5,5 +5,5 @@ options: |
5 | 5 |
type: arch
|
6 | 6 |
description: The machine architecture
|
7 | 7 |
values:
|
8 |
- - arm
|
|
9 |
- - aarch64
|
|
8 |
+ - AArch32
|
|
9 |
+ - AArch64
|
1 |
+kind: autotools
|
|
2 |
+variables:
|
|
3 |
+ result: "Nothing"
|
|
4 |
+ (?):
|
|
5 |
+ - machine_os == "Linux":
|
|
6 |
+ result: "Linuxy"
|
|
7 |
+ - machine_os == "Darwin":
|
|
8 |
+ result: "Darwiny"
|
|
9 |
+ - machine_os == "SunOS":
|
|
10 |
+ result: "SunOSy"
|
|
11 |
+ - machine_os == "FreeBSD":
|
|
12 |
+ result: "FreeBSDy"
|
|
\ No newline at end of file |
1 |
+name: test
|
|
2 |
+ |
|
3 |
+options:
|
|
4 |
+ machine_os:
|
|
5 |
+ type: os
|
|
6 |
+ description: The operating system
|
|
7 |
+ values:
|
|
8 |
+ - Linux
|
|
9 |
+ - Darwin
|
|
10 |
+ - FreeBSD
|
|
11 |
+ - SunOS
|
... | ... | @@ -29,8 +29,8 @@ def override_uname_arch(name): |
29 | 29 |
@pytest.mark.datafiles(DATA_DIR)
|
30 | 30 |
@pytest.mark.parametrize("uname,value,expected", [
|
31 | 31 |
# Test explicitly provided arches
|
32 |
- ('arm', 'arm', 'Army'),
|
|
33 |
- ('arm', 'aarch64', 'Aarchy'),
|
|
32 |
+ ('arm', 'AArch32', 'Army'),
|
|
33 |
+ ('arm', 'AArch64', 'Aarchy'),
|
|
34 | 34 |
|
35 | 35 |
# Test automatically derived arches
|
36 | 36 |
('arm', None, 'Army'),
|
... | ... | @@ -38,8 +38,8 @@ def override_uname_arch(name): |
38 | 38 |
|
39 | 39 |
# Test that explicitly provided arches dont error out
|
40 | 40 |
# when the `uname` reported arch is not supported
|
41 |
- ('i386', 'arm', 'Army'),
|
|
42 |
- ('x86_64', 'aarch64', 'Aarchy'),
|
|
41 |
+ ('i386', 'AArch32', 'Army'),
|
|
42 |
+ ('x86_64', 'AArch64', 'Aarchy'),
|
|
43 | 43 |
])
|
44 | 44 |
def test_conditional(cli, datafiles, uname, value, expected):
|
45 | 45 |
with override_uname_arch(uname):
|
1 |
+import os
|
|
2 |
+import pytest
|
|
3 |
+from contextlib import contextmanager
|
|
4 |
+ |
|
5 |
+from buildstream import _yaml
|
|
6 |
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
|
7 |
+from tests.testutils.runcli import cli
|
|
8 |
+ |
|
9 |
+DATA_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
10 |
+ |
|
11 |
+ |
|
12 |
+@contextmanager
|
|
13 |
+def override_uname_os(name):
|
|
14 |
+ orig_uname = os.uname
|
|
15 |
+ orig_tuple = tuple(os.uname())
|
|
16 |
+ override_result = (name, orig_tuple[1],
|
|
17 |
+ orig_tuple[2], orig_tuple[3],
|
|
18 |
+ orig_tuple[4])
|
|
19 |
+ |
|
20 |
+ def override():
|
|
21 |
+ return override_result
|
|
22 |
+ |
|
23 |
+ os.uname = override
|
|
24 |
+ yield
|
|
25 |
+ os.uname = orig_uname
|
|
26 |
+ |
|
27 |
+ |
|
28 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
29 |
+@pytest.mark.parametrize("uname,value,expected", [
|
|
30 |
+ # Test explicitly provided arches
|
|
31 |
+ ('Darwin', 'Linux', 'Linuxy'),
|
|
32 |
+ ('SunOS', 'FreeBSD', 'FreeBSDy'),
|
|
33 |
+ |
|
34 |
+ # Test automatically derived arches
|
|
35 |
+ ('Linux', None, 'Linuxy'),
|
|
36 |
+ ('Darwin', None, 'Darwiny'),
|
|
37 |
+ |
|
38 |
+ # Test that explicitly provided arches dont error out
|
|
39 |
+ # when the `uname` reported arch is not supported
|
|
40 |
+ ('AIX', 'Linux', 'Linuxy'),
|
|
41 |
+ ('HaikuOS', 'SunOS', 'SunOSy'),
|
|
42 |
+])
|
|
43 |
+def test_conditionals(cli, datafiles, uname, value, expected):
|
|
44 |
+ with override_uname_os(uname):
|
|
45 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'option-os')
|
|
46 |
+ |
|
47 |
+ bst_args = []
|
|
48 |
+ if value is not None:
|
|
49 |
+ bst_args += ['--option', 'machine_os', value]
|
|
50 |
+ |
|
51 |
+ bst_args += [
|
|
52 |
+ 'show',
|
|
53 |
+ '--deps', 'none',
|
|
54 |
+ '--format', '%{vars}',
|
|
55 |
+ 'element.bst'
|
|
56 |
+ ]
|
|
57 |
+ result = cli.run(project=project, silent=True, args=bst_args)
|
|
58 |
+ result.assert_success()
|
|
59 |
+ |
|
60 |
+ loaded = _yaml.load_data(result.output)
|
|
61 |
+ assert loaded['result'] == expected
|
|
62 |
+ |
|
63 |
+ |
|
64 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
65 |
+def test_unsupported_arch(cli, datafiles):
|
|
66 |
+ |
|
67 |
+ with override_uname_os("AIX"):
|
|
68 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'option-os')
|
|
69 |
+ result = cli.run(project=project, silent=True, args=[
|
|
70 |
+ 'show',
|
|
71 |
+ '--deps', 'none',
|
|
72 |
+ '--format', '%{vars}',
|
|
73 |
+ 'element.bst'
|
|
74 |
+ ])
|
|
75 |
+ |
|
76 |
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 |
|
10 | 10 |
set -eux
|
11 | 11 |
|
12 |
-ALPINE_ARCH=${ARCH:-x86_64}
|
|
12 |
+ALPINE_ARCH=${ARCH:-x86-64}
|
|
13 | 13 |
ALPINE_BASE=http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/${ALPINE_ARCH}/alpine-minirootfs-3.7.0-${ALPINE_ARCH}.tar.gz
|
14 | 14 |
|
15 | 15 |
mkdir root
|
... | ... | @@ -9,9 +9,9 @@ sources: |
9 | 9 |
- kind: tar
|
10 | 10 |
base-dir: ''
|
11 | 11 |
(?):
|
12 |
- - arch == "x86_64":
|
|
12 |
+ - arch == "x86-64":
|
|
13 | 13 |
ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639
|
14 | 14 |
url: "alpine:integration-tests-base.v1.x86_64.tar.xz"
|
15 |
- - arch == "aarch64":
|
|
15 |
+ - arch == "AArch64":
|
|
16 | 16 |
ref: 431fb5362032ede6f172e70a3258354a8fd71fcbdeb1edebc0e20968c792329a
|
17 | 17 |
url: "alpine:integration-tests-base.v1.aarch64.tar.xz"
|
... | ... | @@ -13,8 +13,8 @@ options: |
13 | 13 |
type: arch
|
14 | 14 |
description: Current architecture
|
15 | 15 |
values:
|
16 |
- - x86_64
|
|
17 |
- - aarch64
|
|
16 |
+ - x86-64
|
|
17 |
+ - AArch64
|
|
18 | 18 |
split-rules:
|
19 | 19 |
test:
|
20 | 20 |
- |
|
... | ... | @@ -52,4 +52,4 @@ except ImportError: |
52 | 52 |
|
53 | 53 |
IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux')
|
54 | 54 |
|
55 |
-_, _, _, _, MACHINE_ARCH = os.uname()
|
|
55 |
+MACHINE_ARCH = utils.arch_from_uname()
|