diff mbox series

[1/3] meta/files: Add a jsonschema for bitbake-setup configuration files

Message ID 20251023072513.280477-1-yoann.congal@smile.fr
State New
Headers show
Series [1/3] meta/files: Add a jsonschema for bitbake-setup configuration files | expand

Commit Message

Yoann Congal Oct. 23, 2025, 7:25 a.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

This schema is a bit loose and should validate any configuration files working with
bitbake-setup but, also, some broken ones:
* If present, a "bb-layer" can be an empty array.
* bb-setup need at least one of "bb-layers" or "oe-template", that is
  not enforced in the current schema.
* bb-setup accepts "configurations = []" but it results in a impossible
  choice in interactive mode. This is rejected by the schema.
* In each configuration, "name" and "description" are optional but the
  flatten configuration must have them. This is not enforced by the
  schema.

To test a configuration files against this schema: (for exemple to
validate bitbake default registry)
   $ pip install check-jsonschema
   $ check-jsonschema -v --schemafile meta/files/bitbake-setup.schema.json bitbake/default-registry/configurations/*
  ok -- validation done
  The following files were checked:
    bitbake/default-registry/configurations/oe-nodistro.conf.json
    bitbake/default-registry/configurations/poky-master.conf.json

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
Notes:
* I plan to send a patch to make bb-setup reject "configurations = []"
* '"additionalProperties": false' makes "comments":"..."  impossible right now, I
  plan to add them later.
---
 meta/files/bitbake-setup.schema.json | 108 +++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 meta/files/bitbake-setup.schema.json
diff mbox series

Patch

diff --git a/meta/files/bitbake-setup.schema.json b/meta/files/bitbake-setup.schema.json
new file mode 100644
index 0000000000..5101b0de53
--- /dev/null
+++ b/meta/files/bitbake-setup.schema.json
@@ -0,0 +1,108 @@ 
+{
+    "$schema": "https://json-schema.org/draft/2020-12/schema",
+    "description": "Schema for bitbake-setup configuration files",
+    "type": "object",
+    "required": [
+        "description",
+        "bitbake-setup",
+        "version"
+    ],
+    "properties": {
+        "description": {
+            "type": "string",
+            "description": "Description of the bitbake-setup configuration file"
+        },
+        "sources": {
+            "$ref": "layers.schema.json#/properties/sources"
+        },
+        "bitbake-setup": {
+            "type": "object",
+            "description": "BitBake-setup configurations",
+            "required": [
+                "configurations"
+            ],
+            "properties": {
+                "configurations": {
+                    "type": "array",
+                    "minItems": 1,
+                    "$anchor": "configurations",
+                    "items": {
+                        "type": "object",
+                        "properties": {
+                            "name": {
+                                "type": "string",
+                                "description": "Name of the configuration"
+                            },
+                            "description": {
+                                "type": "string",
+                                "description": "Human-readable description of the configuration"
+                            },
+                            "bb-layers": {
+                                "type": "array",
+                                "description": "List of BitBake layers to include",
+                                "items": {
+                                    "type": "string"
+                                }
+                            },
+                            "oe-template": {
+                                "type": "string",
+                                "description": "OE-template configuration"
+                            },
+                            "oe-fragments": {
+                                "$anchor": "oe-fragments",
+                                "type": "array",
+                                "description": "List of BitBake configuration fragments to enable",
+                                "items": {
+                                    "type": "string"
+                                }
+                            },
+                            "oe-fragments-one-of": {
+                                "type": "object",
+                                "description": "Mutually exclusive bitbake configuration fragment",
+                                "patternProperties": {
+                                    ".*": {
+                                        "type": "object",
+                                        "required": [
+                                            "description",
+                                            "options"
+                                        ],
+                                        "properties": {
+                                            "description": {
+                                                "type": "string",
+                                                "description": "Human-readable description of the fragment category"
+                                            },
+                                            "options": {
+                                                "$ref": "#oe-fragments"
+                                            }
+                                        },
+                                        "additionalProperties": false
+                                    }
+                                },
+                                "additionalProperties": false
+                            },
+                            "configurations": {
+                                "$ref": "#configurations"
+                            },
+                            "bb-env-passthrough-additions": {
+                                "type": "array",
+                                "description": "List of environment variables to include in BB_ENV_PASSTHROUGH_ADDITIONS",
+                                "items": {
+                                    "type": "string"
+                                }
+                            }
+                        },
+                        "additionalProperties": false
+                    }
+                }
+            },
+            "additionalProperties": false
+        },
+        "version": {
+            "description": "The version of this document; currently '1.0'",
+            "enum": [
+                "1.0"
+            ]
+        }
+    },
+    "additionalProperties": false
+}