[RFC,2/3] linux-distro: Deploy devicetree files

Message ID 20240613043635.21239-3-ubely@ilbers.de
State Superseded, archived
Headers show
Series Deploy DTBs with kernel recipe | expand

Commit Message

Uladzimir Bely June 13, 2024, 4:19 a.m. UTC
For targets using distro kernel create .deb that includes devicetree
binaries taken from correspoinding "linux-image-*" distro package.

This .deb is then used to deploy devicetree files outside of image
recipe.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 meta/recipes-kernel/linux/linux-distro.bb | 31 +++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Patch

diff --git a/meta/recipes-kernel/linux/linux-distro.bb b/meta/recipes-kernel/linux/linux-distro.bb
index d4f6026d..df858a8a 100644
--- a/meta/recipes-kernel/linux/linux-distro.bb
+++ b/meta/recipes-kernel/linux/linux-distro.bb
@@ -21,3 +21,34 @@  python() {
 }
 
 inherit multiarch
+
+inherit dpkg-raw
+DEBIAN_BUILD_DEPENDS = "linux-image-${KERNEL_NAME}"
+
+do_prepare_build:prepend() {
+    mkdir -p ${D}/usr/lib/${PN}
+}
+
+do_prepare_build:append() {
+    cat <<EOF >> ${S}/debian/rules
+
+override_dh_auto_build:
+EOF
+    for dtb in ${DTB_FILES}; do
+        mkdir -p ${D}/usr/lib/${PN}/$(dirname ${dtb})
+        ppdir=${PP}/image/usr/lib/${PN}/$(dirname ${dtb})
+        cat <<EOF >> ${S}/debian/rules
+	find /usr/lib/linux-image* -path "*${dtb}" -print -exec cp {} ${ppdir} \;
+EOF
+    done
+}
+
+do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}"
+do_deploy() {
+    for dtb in ${DTB_FILES}; do
+        dpkg --fsys-tarfile ${WORKDIR}/${PN}_${CHANGELOG_V}_${PACKAGE_ARCH}.deb | \
+        tar xOf - ./usr/lib/${PN}/${dtb} \
+        > ${DEPLOY_DIR_IMAGE}/${dtb}
+    done
+}
+addtask deploy before do_deploy_deb after do_dpkg_build