From 30367396ff12f352aaed409113d8c071057d6b9e Mon Sep 17 00:00:00 2001
From: Anders Roxell <anders.roxell@linaro.org>
Date: Tue, 9 Dec 2025 09:37:28 +0100
Subject: [PATCH] target: add dtbs_check for schema validation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Introduce a new TuxMake target, `dtbs_check`, to validate Device Tree
Source files against JSON schemas using the kernel's built-in
`dtbs_check` make target.

The Docker base image is updated to install the required runtime
packages for dt-schema validation. Due to upstream dt-schema commit
7b9c4e8412ea (“Switch to referencing jsonschema 4.18+”), which is not
released yet. The latest pip version of `dtschema` is currently
incompatible with the jsonschema package shipped in distributions.
Until an official release is available.

This enables CI environments to catch DTS/schema regressions earlier
and aligns TuxMake with upstream kernel validation workflows.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 support/docker/Dockerfile.base | 4 ++++
 tuxmake/target/dtbs_check.ini  | 5 +++++
 2 files changed, 9 insertions(+)
 create mode 100644 tuxmake/target/dtbs_check.ini

diff --git a/support/docker/Dockerfile.base b/support/docker/Dockerfile.base
index 0b4e740a7f77..a5334965f56e 100644
--- a/support/docker/Dockerfile.base
+++ b/support/docker/Dockerfile.base
@@ -26,6 +26,7 @@ RUN apt-get update \
         procps \
         apt-transport-https \
         ca-certificates \
+        device-tree-compiler \
         bash \
         bc \
         bison \
@@ -59,11 +60,13 @@ RUN apt-get update \
         python3-docutils \
         python3-setuptools \
         python3-jsonschema \
+        python3-pip \
         python3-yaml \
         rpm \
         rsync \
         socat \
         sparse \
+        swig \
         tar \
         u-boot-tools \
         uuid-dev \
@@ -76,6 +79,7 @@ RUN wget -O /etc/apt/trusted.gpg.d/tuxmake.gpg \
     && echo 'deb https://tuxmake.org/packages/ ./' > /etc/apt/sources.list.d/tuxmake.list \
     && apt-get update \
     && apt-get install --assume-yes tuxmake
+RUN pip install --break-system-packages --ignore-installed 'jsonschema<4.18' dtschema
 
 # Lightweight: base container customizations
 COPY tuxmake-check-environment /usr/local/bin/
diff --git a/tuxmake/target/dtbs_check.ini b/tuxmake/target/dtbs_check.ini
new file mode 100644
index 000000000000..1b21a436133d
--- /dev/null
+++ b/tuxmake/target/dtbs_check.ini
@@ -0,0 +1,5 @@
+[target]
+description = Device Tree Source validation against schemas
+dependencies = config
+preconditions = test -d arch/{source_arch}/boot/dts && grep -q ^dtbs_check: {source_tree}/Makefile
+commands = {make} dtbs_check
-- 
2.51.0

