| Message ID | 20260121153028.869575-4-amikan@ilbers.de |
|---|---|
| State | Under Review |
| Headers | show |
| Series | [v4,1/4] meta: Fix do_copy_boot_files error for different distros of same machine | expand |
On 21.01.26 16:30, Anton Mikanovich wrote: > From: Uladzimir Bely <ubely@ilbers.de> > > Task do_copy_boot_files was deploying DTB files into the same location > for different images (e.g. -base or -debug). This causes build issue. > > Introduce `dtb-files` recipe responsible for the extraction of DTBs > from linux-image package (distro or self-built) and their deployment. > > Different images for the same machine now depend on this recipe and > shouldn't cause parallel execution issues. > > Signed-off-by: Uladzimir Bely <ubely@ilbers.de> > Signed-off-by: Anton Mikanovich <amikan@ilbers.de> > --- > meta/classes-recipe/image.bbclass | 15 +++----- > meta/recipes-kernel/dtb-files/dtb-files.bb | 41 ++++++++++++++++++++++ > 2 files changed, 46 insertions(+), 10 deletions(-) > create mode 100644 meta/recipes-kernel/dtb-files/dtb-files.bb > > diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass > index e605bc80..dc599535 100644 > --- a/meta/classes-recipe/image.bbclass > +++ b/meta/classes-recipe/image.bbclass > @@ -372,6 +372,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}" > @@ -385,16 +390,6 @@ do_copy_boot_files() { > sudo cat "$kernel" > "${DEPLOYDIR}/${KERNEL_IMAGE}" > 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..f64b4845 > --- /dev/null > +++ b/meta/recipes-kernel/dtb-files/dtb-files.bb > @@ -0,0 +1,41 @@ > +# This software is a part of Isar. > +# Copyright (C) ilbers GmbH, 2025 > +# > +# SPDX-License-Identifier: MIT > + > +inherit dpkg-raw > + Why does this need another package? We are repacking here already packaged artifacts, and that only for the purpose of pushing them into the deploy folder. This sounds strange, at best. Jan > +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}" > + > +DPKG_ARCH = "${PACKAGE_ARCH}" > + > +do_prepare_build:append() { > + for dtb in ${DTB_FILES}; do > + dir=debian/${PN}/usr/lib/${PN}/$(dirname ${dtb}) > + cat <<EOF >> ${S}/debian/rules > + mkdir -p ${dir} > + find /usr/lib/linux-image* -path "*${dtb}" -print -exec cp {} ${dir} \; > +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
21/01/2026 20:27, Jan Kiszka wrote: >> 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..f64b4845 >> --- /dev/null >> +++ b/meta/recipes-kernel/dtb-files/dtb-files.bb >> @@ -0,0 +1,41 @@ >> +# This software is a part of Isar. >> +# Copyright (C) ilbers GmbH, 2025 >> +# >> +# SPDX-License-Identifier: MIT >> + >> +inherit dpkg-raw >> + > Why does this need another package? We are repacking here already > packaged artifacts, and that only for the purpose of pushing them into > the deploy folder. This sounds strange, at best. > > Jan Hello Jan, The idea was to avoid parallel execution issues by moving it from multiple image recipes to one recipe which will cover all the images and any type of kernel (prebuilt or self-built).
On 23.01.26 13:40, Anton Mikanovich wrote: > 21/01/2026 20:27, Jan Kiszka wrote: >>> 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..f64b4845 >>> --- /dev/null >>> +++ b/meta/recipes-kernel/dtb-files/dtb-files.bb >>> @@ -0,0 +1,41 @@ >>> +# This software is a part of Isar. >>> +# Copyright (C) ilbers GmbH, 2025 >>> +# >>> +# SPDX-License-Identifier: MIT >>> + >>> +inherit dpkg-raw >>> + >> Why does this need another package? We are repacking here already >> packaged artifacts, and that only for the purpose of pushing them into >> the deploy folder. This sounds strange, at best. >> >> Jan > Hello Jan, > > The idea was to avoid parallel execution issues by moving it from multiple > image recipes to one recipe which will cover all the images and any type of > kernel (prebuilt or self-built). Still makes no sense to me: One image, one kernel, one dtb deployment - isn't that what patch 1 ensures? Jan
diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass index e605bc80..dc599535 100644 --- a/meta/classes-recipe/image.bbclass +++ b/meta/classes-recipe/image.bbclass @@ -372,6 +372,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}" @@ -385,16 +390,6 @@ do_copy_boot_files() { sudo cat "$kernel" > "${DEPLOYDIR}/${KERNEL_IMAGE}" 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..f64b4845 --- /dev/null +++ b/meta/recipes-kernel/dtb-files/dtb-files.bb @@ -0,0 +1,41 @@ +# This software is a part of Isar. +# Copyright (C) ilbers GmbH, 2025 +# +# SPDX-License-Identifier: MIT + +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}" + +DPKG_ARCH = "${PACKAGE_ARCH}" + +do_prepare_build:append() { + for dtb in ${DTB_FILES}; do + dir=debian/${PN}/usr/lib/${PN}/$(dirname ${dtb}) + cat <<EOF >> ${S}/debian/rules + mkdir -p ${dir} + find /usr/lib/linux-image* -path "*${dtb}" -print -exec cp {} ${dir} \; +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