Skip to contentSkip to conversation

Layer Setup JSON schema and example

RFC In review Joshua Watt 3 participants 8 messages Jul 6, 2022 – Jul 7, 2022

lore
Share & tools
lore
#0 lore raw

RFC 1/1 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 for reference.

The schema can be used to validate a layer setup file with the commands:

 $ python3 -m pip install jsonschema
 $ jsonschema -i meta/lib/layers.example.json meta/lib/layers.schema.json
---
 meta/lib/layers.example.json |  35 +++++++++++
 meta/lib/layers.schema.json  | 113 +++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+)
 create mode 100644 meta/lib/layers.example.json
 create mode 100644 meta/lib/layers.schema.json
meta/lib/layers.example.json new file +35 -0
new file mode 100644
index 0000000000..33264dac9e
@@ -0,0 +1,35 @@
+{
+    "version": "1.0",
+    "sources": [
+        {
+            "name": "poky",
+            "path": "poky",
+            "description": "Poky reference distribution",
+            "remote": {
+                "type": "git",
+                "branch": "master",
+                "rev": "bc6d96e69684253a7236594cb0af2738be06b7a9",
+                "remotes": [
+                    {
+                        "name": "origin",
+                        "uri": "git://git.yoctoproject.org/poky"
+                    }
+                ]
+            },
+            "layers": [
+                {
+                    "name": "meta",
+                    "subpath": "meta"
+                },
+                {
+                    "name": "meta-poky",
+                    "subpath": "meta-poky"
+                },
+                {
+                    "name": "meta-yocto-bsp",
+                    "subpath": "meta-yocto-bsp"
+                }
+            ]
+        }
+    ]
+}
meta/lib/layers.schema.json new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.33.0
#1 lore raw
Quoted 2 lines · Joshua Watt
 $ python3 -m pip install jsonschema
 $ jsonschema -i meta/lib/layers.example.json meta/lib/layers.schema.json

Since jsonschema is not a standard module, we need to think for a bit about how and when validation should occur with tools available directly in core. I would like it to happen every time json is produced or (about to be) consumed, but then the module should be coming from somewhere, either from the host or from a native recipe, both look like not a great idea. Thoughts? Is this where 'oe-setup installed via pip' approach starts to show benefits? :)

Alex

#2 lore raw
Quoted 5 lines · Alexander Kanavin
Quoted 2 lines · Joshua Watt
 $ python3 -m pip install jsonschema
 $ jsonschema -i meta/lib/layers.example.json meta/lib/layers.schema.json
Quoted 7 lines

Since jsonschema is not a standard module, we need to think for a bit about how and when validation should occur with tools available directly in core. I would like it to happen every time json is produced or (about to be) consumed, but then the module should be coming from somewhere, either from the host or from a native recipe, both look like not a great idea. Thoughts? Is this where 'oe-setup installed via pip' approach starts to show benefits? :)

Ya, for a 100% "standalone" tool, I'm not sure if we can do any real validation in python without external modules. For testing, can either add the requirement for the python3-jsonschema system package, or maybe use python3-jsonschema-native?

Quoted 2 lines

Alex

#3 lore raw
In reply to Joshua Watt
Quoted 7 lines · Joshua Watt via lists.openembedded.org

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 for reference.

JSON is terrible for humans to read or edit, is this intended to be purely for the machine, or are humans meant to read it too? If humans are meant to work on the file I’d really prefer something readable like YAML.

Ross
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

#4 lore raw
Quoted 1 line · Ross Burton

JSON is terrible for humans to read or edit, is this intended to be purely for the machine, or are humans meant to read it too? If humans are meant to work on the file I’d really prefer something readable like YAML.

Wait, how is YAML more readable, if JSON is valid YAML?

Alex

#5 lore raw
Quoted 1 line

Wait, how is YAML more readable, if JSON is valid YAML?

But YAML is not valid JSON, and YAML is the one which can be readable, unlike JSON.

Ross
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

#6 lore raw
Quoted 3 lines · Ross Burton
Quoted 1 line

Wait, how is YAML more readable, if JSON is valid YAML?

But YAML is not valid JSON, and YAML is the one which can be readable, unlike JSON.

YAML is also not an included python battery, while JSON is. I'll stick with JSON for now, if you provide specific examples of how the JSON that we're defining would look more readable rendered in YAML, that would be appreciated.

Alex

#7 lore raw
Quoted 10 lines · Alexander Kanavin
Quoted 3 lines · Ross Burton
Quoted 1 line

Wait, how is YAML more readable, if JSON is valid YAML?

But YAML is not valid JSON, and YAML is the one which can be readable, unlike JSON.

YAML is also not an included python battery, while JSON is. I'll stick with JSON for now, if you provide specific examples of how the JSON that we're defining would look more readable rendered in YAML, that would be appreciated.

I generally agree that YAML is better for humans, but using JSON now allows us to make progress without having to hash out that discussion, and won't exclude using YAML in the future (since YAML is a strict superset of JSON).

Quoted 2 lines

Alex