diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2022-08-31 13:13:57 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-09-01 10:07:02 +0100 |
commit | f5d6792d68a12db9c512522ef576b5a8d4204952 (patch) | |
tree | a7fe16f44b54350cf2811b56baa7cc223fc326fa /meta/lib | |
parent | 3f9e3feb2225b681318c81dc9977b2b9656a373c (diff) | |
download | poky-f5d6792d68a12db9c512522ef576b5a8d4204952.tar.gz |
meta/files: add layer setup JSON schema and example
Defines a common schema for layer setup that can be consumed by tools to
know how to fetch and assemble layers for end users. Also includes an
example of the layer setup that constructs poky/meta-intel/imaginary product layer
for reference.
The schema can be used to validate a layer setup file with the commands:
$ python3 -m pip install jsonschema
$ jsonschema -i meta/files/layers.example.json meta/files/layers.schema.json
(From OE-Core rev: 72740b5dd635579e373b4bfe6ccacfe6a02aa998)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Alex: I made the following modifications to Joshua's original commit:
- moved the files from meta/lib to meta/files
- the example json showcases a multi-repo, multi-layer setup
instead of just poky - closer to a typical product
- added oe-selftest that validates the example json against the schema using python3-jsonschema-native
- the schema is modified so that:
-- all lists (sources, layers, remotes) are replaced by objects keyed by 'name' properties of the list items.
This allows using them as dicts inside Python, and makes the json more compact and readable.
-- added 'contains_this_file' property to source object
-- replaced 'remote' property with a 'oneOf' definition for git with a specific
'git-remote' property. 'oneOf' is problematic when schema validation fails:
the diagnostic is only that none of oneOf variants matched, which is too non-specific.
-- added 'describe' property to 'git-remote' object.
-- removed description property for a layer source: it is not clear how to add that
when auto-generating the json
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/bblayers.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py index 549abe7d10..c753a7b795 100644 --- a/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/meta/lib/oeqa/selftest/cases/bblayers.py | |||
@@ -8,12 +8,16 @@ import os | |||
8 | import re | 8 | import re |
9 | 9 | ||
10 | import oeqa.utils.ftools as ftools | 10 | import oeqa.utils.ftools as ftools |
11 | from oeqa.utils.commands import runCmd, get_bb_var, get_bb_vars | 11 | from oeqa.utils.commands import runCmd, get_bb_var, get_bb_vars, bitbake |
12 | 12 | ||
13 | from oeqa.selftest.case import OESelftestTestCase | 13 | from oeqa.selftest.case import OESelftestTestCase |
14 | 14 | ||
15 | class BitbakeLayers(OESelftestTestCase): | 15 | class BitbakeLayers(OESelftestTestCase): |
16 | 16 | ||
17 | def setUpLocal(self): | ||
18 | bitbake("python3-jsonschema-native") | ||
19 | bitbake("-c addto_recipe_sysroot python3-jsonschema-native") | ||
20 | |||
17 | def test_bitbakelayers_layerindexshowdepends(self): | 21 | def test_bitbakelayers_layerindexshowdepends(self): |
18 | result = runCmd('bitbake-layers layerindex-show-depends meta-poky') | 22 | result = runCmd('bitbake-layers layerindex-show-depends meta-poky') |
19 | find_in_contents = re.search("openembedded-core", result.output) | 23 | find_in_contents = re.search("openembedded-core", result.output) |
@@ -128,3 +132,13 @@ class BitbakeLayers(OESelftestTestCase): | |||
128 | 132 | ||
129 | self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe) | 133 | self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe) |
130 | return os.path.basename(recipe_file) | 134 | return os.path.basename(recipe_file) |
135 | |||
136 | def validate_layersjson(self, json): | ||
137 | python = os.path.join(get_bb_var('STAGING_BINDIR', 'python3-jsonschema-native'), 'nativepython3') | ||
138 | jsonvalidator = os.path.join(get_bb_var('STAGING_BINDIR', 'python3-jsonschema-native'), 'jsonschema') | ||
139 | jsonschema = os.path.join(get_bb_var('COREBASE'), 'meta/files/layers.schema.json') | ||
140 | result = runCmd("{} {} -i {} {}".format(python, jsonvalidator, json, jsonschema)) | ||
141 | |||
142 | def test_validate_examplelayersjson(self): | ||
143 | json = os.path.join(get_bb_var('COREBASE'), "meta/files/layers.example.json") | ||
144 | self.validate_layersjson(json) | ||