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 | |
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')
-rw-r--r-- | meta/files/layers.example.json | 72 | ||||
-rw-r--r-- | meta/files/layers.schema.json | 91 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/bblayers.py | 16 |
3 files changed, 178 insertions, 1 deletions
diff --git a/meta/files/layers.example.json b/meta/files/layers.example.json new file mode 100644 index 0000000000..3772404ec9 --- /dev/null +++ b/meta/files/layers.example.json | |||
@@ -0,0 +1,72 @@ | |||
1 | { | ||
2 | "sources": { | ||
3 | "meta-alex": { | ||
4 | "contains_this_file": true, | ||
5 | "git-remote": { | ||
6 | "branch": "master", | ||
7 | "describe": "", | ||
8 | "remotes": { | ||
9 | "remote-alex": { | ||
10 | "uri": "https://github.com/kanavin/meta-alex" | ||
11 | } | ||
12 | }, | ||
13 | "rev": "05b25605fb8b2399e4706d7323828676bf0da0b5" | ||
14 | }, | ||
15 | "layers": { | ||
16 | "meta-alex": { | ||
17 | "subpath": "" | ||
18 | } | ||
19 | }, | ||
20 | "path": "meta-alex" | ||
21 | }, | ||
22 | "meta-intel": { | ||
23 | "git-remote": { | ||
24 | "branch": "master", | ||
25 | "describe": "15.0-hardknott-3.3-310-g0a96edae", | ||
26 | "remotes": { | ||
27 | "origin": { | ||
28 | "uri": "git://git.yoctoproject.org/meta-intel" | ||
29 | } | ||
30 | }, | ||
31 | "rev": "0a96edae609a3f48befac36af82cf1eed6786b4a" | ||
32 | }, | ||
33 | "layers": { | ||
34 | "meta-intel": { | ||
35 | "subpath": "" | ||
36 | } | ||
37 | }, | ||
38 | "path": "meta-intel" | ||
39 | }, | ||
40 | "poky": { | ||
41 | "git-remote": { | ||
42 | "branch": "akanavin/setup-layers", | ||
43 | "describe": "4.1_M1-374-g9dda719b2a", | ||
44 | "remotes": { | ||
45 | "origin": { | ||
46 | "uri": "git://git.yoctoproject.org/poky" | ||
47 | }, | ||
48 | "poky-contrib": { | ||
49 | "uri": "ssh://git@push.yoctoproject.org/poky-contrib" | ||
50 | } | ||
51 | }, | ||
52 | "rev": "9dda719b2a4727a4d43a6ab8d9e23f8ca68790ec" | ||
53 | }, | ||
54 | "layers": { | ||
55 | "meta": { | ||
56 | "subpath": "meta" | ||
57 | }, | ||
58 | "meta-poky": { | ||
59 | "subpath": "meta-poky" | ||
60 | }, | ||
61 | "meta-selftest": { | ||
62 | "subpath": "meta-selftest" | ||
63 | }, | ||
64 | "meta-yocto-bsp": { | ||
65 | "subpath": "meta-yocto-bsp" | ||
66 | } | ||
67 | }, | ||
68 | "path": "poky" | ||
69 | } | ||
70 | }, | ||
71 | "version": "1.0" | ||
72 | } | ||
diff --git a/meta/files/layers.schema.json b/meta/files/layers.schema.json new file mode 100644 index 0000000000..cd4ddd3dcd --- /dev/null +++ b/meta/files/layers.schema.json | |||
@@ -0,0 +1,91 @@ | |||
1 | { | ||
2 | "description": "OpenEmbedder Layer Setup Manifest", | ||
3 | "type": "object", | ||
4 | "additionalProperties": false, | ||
5 | "required": [ | ||
6 | "version" | ||
7 | ], | ||
8 | "properties": { | ||
9 | "version": { | ||
10 | "description": "The version of this document; currently '1.0'", | ||
11 | "enum": ["1.0"] | ||
12 | }, | ||
13 | "sources": { | ||
14 | "description": "The dict of layer sources", | ||
15 | "type": "object", | ||
16 | "patternProperties": { ".*" : { | ||
17 | "type": "object", | ||
18 | "description": "The upstream source from which a set of layers may be fetched", | ||
19 | "additionalProperties": false, | ||
20 | "required": [ | ||
21 | "path" | ||
22 | ], | ||
23 | "properties": { | ||
24 | "path": { | ||
25 | "description": "The path where this layer source will be placed when fetching", | ||
26 | "type": "string" | ||
27 | }, | ||
28 | "contains_this_file": { | ||
29 | "description": "Whether the directory with the layer source also contains this json description. Tools may want to skip the checkout of the source then.", | ||
30 | "type": "boolean" | ||
31 | }, | ||
32 | "layers": { | ||
33 | "description": "The dict of layers to be used from this upstream source", | ||
34 | "type": "object", | ||
35 | "patternProperties": { ".*" : { | ||
36 | "description": "A layer from the upstream source", | ||
37 | "type": "object", | ||
38 | "additionalProperties": false, | ||
39 | "properties": { | ||
40 | "subpath": { | ||
41 | "description": "The subpath (relative to the source root) for this layer. Omit if the source root is the layer path", | ||
42 | "type": "string" | ||
43 | } | ||
44 | } | ||
45 | }} | ||
46 | }, | ||
47 | "git-remote": { | ||
48 | "description": "A remote git source from which to fetch", | ||
49 | "type": "object", | ||
50 | "additionalProperties": false, | ||
51 | "required": [ | ||
52 | "rev" | ||
53 | ], | ||
54 | "properties": { | ||
55 | "branch": { | ||
56 | "description": "The git branch to fetch (optional)", | ||
57 | "type": "string" | ||
58 | }, | ||
59 | "rev": { | ||
60 | "description": "The git revision to checkout", | ||
61 | "type": "string" | ||
62 | }, | ||
63 | "describe": { | ||
64 | "description": "The output of 'git describe' (human readable description of the revision using tags in revision history).", | ||
65 | "type": "string" | ||
66 | }, | ||
67 | "remotes": { | ||
68 | "description": "The dict of git remotes to add to this repository", | ||
69 | "type": "object", | ||
70 | "patternProperties": { ".*" : { | ||
71 | "description": "A git remote", | ||
72 | "type": "object", | ||
73 | "addtionalProperties": false, | ||
74 | "required": [ | ||
75 | "uri" | ||
76 | ], | ||
77 | "properties": { | ||
78 | "uri": { | ||
79 | "description": "The URI for the remote", | ||
80 | "type": "string" | ||
81 | } | ||
82 | } | ||
83 | }} | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | }} | ||
90 | } | ||
91 | } | ||
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) | ||