public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 3/3] meta: Move DTB deployment to a separate dtb-files recipe
Date: Fri, 12 Jul 2024 08:09:34 +0300	[thread overview]
Message-ID: <20240712054327.9526-4-ubely@ilbers.de> (raw)
In-Reply-To: <20240712054327.9526-1-ubely@ilbers.de>

Task do_copy_boot_files deploys DTB files into the same location
for different images (e.g. -base or -debug). This causes build issue.

Introduce `dtb-files` recipe responcible for extraction DTBs from
linux-image package (distro or self-built) and their deployment.

Different images for the same machine now depend on this recipe and
don't cause parallell execution issue.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 meta/classes/image.bbclass                 | 16 +++-----
 meta/recipes-kernel/dtb-files/dtb-files.bb | 45 ++++++++++++++++++++++
 2 files changed, 50 insertions(+), 11 deletions(-)
 create mode 100644 meta/recipes-kernel/dtb-files/dtb-files.bb

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index c29d9e26..3644183e 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -328,6 +328,11 @@ INITRD_IMG = "${PP_DEPLOY}/${INITRD_DEPLOY_FILE}"
 # only one dtb file supported, pick the first
 DTB_IMG = "${PP_DEPLOY}/${@(d.getVar('DTB_FILES').split() or [''])[0]}"
 
+python() {
+    if d.getVar('DTB_FILES'):
+        d.appendVarFlag("do_copy_boot_files", "depends", "dtb-files-${MACHINE}:do_deploy")
+}
+
 do_copy_boot_files[cleandirs] += "${DEPLOYDIR}"
 do_copy_boot_files[sstate-inputdirs] = "${DEPLOYDIR}"
 do_copy_boot_files[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
@@ -351,17 +356,6 @@ do_copy_boot_files() {
             cp -f "$initrd" '${DEPLOYDIR}/${INITRD_DEPLOY_FILE}'
         fi
     fi
-
-    for file in ${DTB_FILES}; do
-        dtb="$(find '${IMAGE_ROOTFS}/usr/lib' -type f \
-                    -iwholename '*linux-image-*/'${file} | head -1)"
-
-        if [ -z "$dtb" -o ! -e "$dtb" ]; then
-            die "${file} not found"
-        fi
-
-        cp -f "$dtb" "${DEPLOYDIR}/"
-    done
 }
 addtask copy_boot_files before do_rootfs_postprocess after do_rootfs_install
 
diff --git a/meta/recipes-kernel/dtb-files/dtb-files.bb b/meta/recipes-kernel/dtb-files/dtb-files.bb
new file mode 100644
index 00000000..49f0d584
--- /dev/null
+++ b/meta/recipes-kernel/dtb-files/dtb-files.bb
@@ -0,0 +1,45 @@
+# This software is a part of Isar.
+# Copyright (C) 2024 ilbers GmbH
+
+inherit dpkg-raw
+
+PN:append = "-${MACHINE}"
+
+KERNEL_IMAGE_PKG ??= "${@ ("linux-image-" + d.getVar("KERNEL_NAME")) if d.getVar("KERNEL_NAME") else ""}"
+
+DEPENDS = "${KERNEL_IMAGE_PKG}"
+DEBIAN_BUILD_DEPENDS = "${KERNEL_IMAGE_PKG}"
+
+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
+}
+
+DTB_PACKAGE ??= "${PN}_${CHANGELOG_V}_${DISTRO_ARCH}.deb"
+
+do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}"
+do_deploy[cleandirs] = "${WORKDIR}/deploy"
+do_deploy() {
+    dpkg --fsys-tarfile ${WORKDIR}/${DTB_PACKAGE} | \
+    tar --wildcards --extract --directory ${WORKDIR}/deploy ./usr/lib/${PN}
+    for dtb in ${DTB_FILES}; do
+        mkdir -p ${DEPLOY_DIR_IMAGE}/$(dirname ${dtb})
+        find ${WORKDIR}/deploy/usr/lib/${PN} -path "*${dtb}" -print \
+            -exec cp {} ${DEPLOY_DIR_IMAGE}/${dtb} \;
+    done
+}
+
+addtask deploy before do_deploy_deb after do_dpkg_build
-- 
2.44.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20240712054327.9526-4-ubely%40ilbers.de.

      parent reply	other threads:[~2024-07-12  5:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-12  5:09 [PATCH v2 0/3] Deploy DTBs with separate recipe Uladzimir Bely
2024-07-12  5:09 ` [PATCH v2 1/3] meta: Fix do_copy_boot_files error for different distros of same machine Uladzimir Bely
2024-07-12 15:06   ` Cedric Hombourger
2024-07-15  6:45     ` 'Florian Bezdeka' via isar-users
2024-07-12  5:09 ` [PATCH v2 2/3] testsuite: Build also debug images for some targets Uladzimir Bely
2024-07-12  5:09 ` Uladzimir Bely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240712054327.9526-4-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox