From: Anton Mikanovich <amikan@ilbers.de>
To: "MOESSBAUER, Felix" <felix.moessbauer@siemens.com>,
"isar-users@googlegroups.com" <isar-users@googlegroups.com>
Subject: Re: [PATCH v11 2/3] meta: Move kernel artifacts deployment from image recipe
Date: Tue, 30 Jun 2026 15:21:29 +0300 [thread overview]
Message-ID: <3a696f95-0f63-43c9-a9c4-c75bf34a30ee@ilbers.de> (raw)
In-Reply-To: <1402cd5ce266312076b38a6896873abd9615efd7.camel@siemens.com>
Hello Felix, thanks for the review.
On 29/06/2026 18:04, MOESSBAUER, Felix wrote:
> On Tue, 2026-06-09 at 11:44 +0300, Anton Mikanovich wrote:
>> ...shortened...
>> +}
>> +
>> +# Associate kernel with image by symlinks
>> +do_copy_boot_files[dirs] += "${DEPLOY_DIR_IMAGE}"
>> +do_copy_boot_files[file-checksums] += "${KERNEL_DEPLOY_DIR}/${KERNEL_WILDCARD}:True"
>> do_copy_boot_files() {
>> - kernel="$(realpath -q '${IMAGE_ROOTFS}'/vmlinu[xz])"
>> - if [ ! -f "$kernel" ]; then
>> - kernel="$(realpath -q '${IMAGE_ROOTFS}'/boot/vmlinu[xz])"
>> - fi
>> + kernel="$(realpath -mq '${KERNEL_DEPLOY_DIR}/'${KERNEL_WILDCARD} | head -n1)"
>> if [ -f "$kernel" ]; then
>> - sudo cat "$kernel" > "${DEPLOYDIR}/${KERNEL_IMAGE}"
>> + ln -sfr "$kernel" "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}"
> These symlinks will be dangling when running bitbake -c clean on the
> kernel recipe. This is because the kernel is deployed via sstate cache,
> but the symlink is manually created.
>
> I have no idea how to fix this...
It looks like this is not possible because kernel have no idea which
image it
was build for, and it can be shared between images.
I don't think this is a big issue because files will not be there after
clean
in any case. The only issue can be if some downstream rely only on the file
existence without care about possible symlinking, which is more downstream
logic issue.
Anyway those symlinks are left only for the backward compatibility and I
hope
downstreams will migrate to the new location (and naming) at some point.
I can try to make a hack to lookup for symlinks to kernel files in
deploy dir
inside of kernel's sstate tasks, but do we really need it?
>
>> fi
>>
>> for file in ${DTB_FILES}; do
>> - dtb="$(find '${IMAGE_ROOTFS}/usr/lib' -type f \
>> - -iwholename '*linux-image-*/'${file} | head -1)"
>> + dtb="${KERNEL_DEPLOY_DIR}/$(basename ${file})"
>>
>> if [ -z "$dtb" -o ! -e "$dtb" ]; then
>> die "${file} not found"
>> fi
>>
>> - cp -f "$dtb" "${DEPLOYDIR}/"
>> + ln -sfr "$dtb" "${DEPLOY_DIR_IMAGE}/$(basename $dtb)"
> Same here.
>
>> done
>> }
>> addtask copy_boot_files before do_rootfs_postprocess after do_rootfs_install
>>
>> -python do_copy_boot_files_setscene () {
>> - sstate_setscene(d)
>> -}
>> -addtask do_copy_boot_files_setscene
>> -
>> python do_image_tools() {
>> """Virtual task"""
>> pass
>> diff --git a/meta/classes-recipe/linux-deploy.bbclass b/meta/classes-recipe/linux-deploy.bbclass
>> new file mode 100644
>> index 00000000..cb29065d
>> --- /dev/null
>> +++ b/meta/classes-recipe/linux-deploy.bbclass
>> @@ -0,0 +1,46 @@
>> +# This software is a part of Isar.
>> +# Copyright (C) 2026 ilbers GmbH
>> +#
>> +# SPDX-License-Identifier: MIT
>> +
>> +DEPLOYDIR = "${WORKDIR}/deploy_${@ d.getVar('MACHINE').replace('-','_') or ''}"
>> +KERNEL_DEPLOY_TASKNAME ?= "do_deploy_kernel_${@ d.getVar('MACHINE').replace('-','_') or ''}"
>> +SSTATETASKS += "${KERNEL_DEPLOY_TASKNAME}"
>> +
>> +python () {
>> + kernel_name = d.getVar('KERNEL_NAME_PROVIDED') or ''
>> + if "linux-image-"+kernel_name in d.getVar('PROVIDES'):
>> + task = d.getVar('KERNEL_DEPLOY_TASKNAME')
>> + d.setVar(task, d.expand('kernel_deploy'))
>> + d.setVarFlag(task, 'func', '1')
>> + d.setVarFlag(task, 'sstate-inputdirs', d.expand('${DEPLOYDIR}'))
>> + d.setVarFlag(task, 'sstate-outputdirs', d.expand('${KERNEL_DEPLOY_DIR}'))
>> + d.appendVarFlag(task, 'cleandirs', d.expand('${DEPLOYDIR}'))
>> + d.appendVarFlag(task, 'stamp-extra-info', d.expand('${MACHINE}'))
> Why not simply d.getVar()?
It was implemented in the same style as imagetypes virtual tasks creation.
But maybe you are right and getVar (which is widely used across Isar) is
enough.
>
>> + bb.build.addtask(task, 'do_build', 'do_dpkg_build', d)
>> +}
>> +
>> +KERNEL_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}/kernel-${KERNEL_NAME_PROVIDED}"
>> +
>> +KERNEL_LOCATION ?= "./boot"
>> +KERNEL_DEB ?= "linux-image-${KERNEL_NAME_PROVIDED}_${CHANGELOG_V}_${DISTRO_ARCH}.deb"
>> +
>> +# Take care the case when requested kernel format doesn't match distro one
>> +DEPLOY_WILDCARDS = "'${KERNEL_LOCATION}/${@ 'vmlinu[xz]*' if (p := d.getVar('KERNEL_FILE')) == 'vmlinux' else p+'*'}'"
>> +DEPLOY_WILDCARDS += "${@(' '.join("'*%s'" % p for p in (d.getVar('DTB_FILES') or '').split()))}"
>> +
>> +kernel_deploy() {
>> + case "${PROVIDES}" in
>> + *linux-image-${KERNEL_NAME_PROVIDED}*)
>> + dpkg --fsys-tarfile ${WORKDIR}/${KERNEL_DEB} | \
>> + tar xvf - -C "${DEPLOYDIR}" \
>> + --transform='s|^.*/||' \
>> + --wildcards ${DEPLOY_WILDCARDS}
>> + ;;
>> + esac
>> +}
>> +
>> +python do_copy_boot_files_setscene () {
>> + sstate_setscene(d)
>> +}
>> +addtask do_copy_boot_files_setscene
>> diff --git a/meta/classes-recipe/linux-kernel.bbclass b/meta/classes-recipe/linux-kernel.bbclass
>> index e4ae356d..32d10f68 100644
>> --- a/meta/classes-recipe/linux-kernel.bbclass
>> +++ b/meta/classes-recipe/linux-kernel.bbclass
>> @@ -3,6 +3,7 @@
>> # This software is a part of Isar.
>> # Copyright (c) Siemens AG, 2022
>> # Copyright (c) Mentor Graphics, a Siemens business, 2022
>> +# Copyright (C) 2022-2026 ilbers GmbH
>> #
>> # SPDX-License-Identifier: MIT
>>
>> @@ -337,3 +338,5 @@ do_dpkg_source:prepend() {
>> dpkg_configure_kernel
>> get_localversion_auto
>> }
>> +
>> +inherit linux-deploy
>> diff --git a/meta/recipes-kernel/linux/files/getkernel.sh b/meta/recipes-kernel/linux/files/getkernel.sh
>> new file mode 100755
>> index 00000000..7070dbc0
>> --- /dev/null
>> +++ b/meta/recipes-kernel/linux/files/getkernel.sh
>> @@ -0,0 +1,40 @@
>> +#!/bin/bash -e
>> +
>> +deb_cache="/var/cache/apt/archives"
>> +
>> +paths="/vmlinu[xz] /boot/vmlinu[xz]"
>> +if [ -n "$1" ]; then
>> + paths="/$1 /boot/$1 $paths"
>> +fi
>> +
>> +# Lookup for the kernel file
>> +for path in ${paths}; do
>> + kernel="$(realpath -q ${path})"
>> + if [ -f "${kernel}" ]; then
>> + break
>> + fi
>> +done
>> +
>> +# Obtain package name for the kernel file
>> +pkg="$(dpkg -S ${kernel} | cut -d':' -f1)"
>> +if [ -z "${pkg}" ]; then
>> + >&2 echo "No package providing ${kernel} found!"
>> + exit 1
>> +fi
>> +
>> +# Query for deb filename
>> +deb_name=$(dpkg-query -W -f='${Package}_${Version}_${Architecture}.deb\n' ${pkg})
>> +
>> +# Take care about special symbols
>> +deb_name="${deb_name//%/%25}"
>> +deb_name="${deb_name//:/%3a}"
>> +deb_name="${deb_name//~/%7e}"
>> +
>> +# Search for deb in cache dir
>> +deb_path="$(find ${deb_cache} -name "${deb_name}" 2>/dev/null | head -n1)"
>> +if [ ! -f "${deb_path}" ]; then
>> + >&2 echo "Package ${deb_name} not found in ${deb_cache}!"
>> + exit 1
>> +fi
>> +
>> +echo "${deb_path}"
>> diff --git a/meta/recipes-kernel/linux/files/rules.tmpl b/meta/recipes-kernel/linux/files/rules.tmpl
>> new file mode 100644
>> index 00000000..69d79bb5
>> --- /dev/null
>> +++ b/meta/recipes-kernel/linux/files/rules.tmpl
>> @@ -0,0 +1,12 @@
>> +#!/usr/bin/make -f
>> +
>> +KERNEL_PATH := $(shell ./debian/getkernel.sh ${KERNEL_FILE})
>> +DEB_NAME := ${KERNEL_DEB}
>> +
>> +binary:
>> + @[ -z "$(KERNEL_PATH)" ] && { echo "Kernel not found!"; exit 1; } || true
>> + cp "$(KERNEL_PATH)" ../$(DEB_NAME)
>> + echo "$(DEB_NAME) misc optional" > debian/files
>> +
>> +%:
>> + true
>> diff --git a/meta/recipes-kernel/linux/linux-distro.bb b/meta/recipes-kernel/linux/linux-distro.bb
>> index 8fc1bcb7..47fe3fb4 100644
>> --- a/meta/recipes-kernel/linux/linux-distro.bb
>> +++ b/meta/recipes-kernel/linux/linux-distro.bb
>> @@ -2,6 +2,7 @@
>> #
>> # This software is a part of Isar.
>> # Copyright (c) Siemens AG, 2018
>> +# Copyright (C) 2022-2026 ilbers GmbH
>> #
>> # SPDX-License-Identifier: MIT
>>
>> @@ -27,3 +28,29 @@ python() {
>> }
>>
>> inherit multiarch
>> +inherit dpkg
>> +inherit linux-deploy
>> +
>> +# Always use target arch for kernel package lookup
>> +ISAR_CROSS_COMPILE = "0"
>> +
>> +MAINTAINER = "isar-users <isar-users@googlegroups.com>"
>> +
>> +PN .= "-${KERNEL_NAME}"
>> +KERNEL_NAME_PROVIDED ??= "${KERNEL_NAME}"
>> +DEBIAN_BUILD_DEPENDS ?= "${@d.getVar('KERNEL_IMAGE_PKG') or ('linux-image-' + (d.getVar('KERNEL_NAME') or ''))}"
>> +
>> +FILESPATH:prepend = "${LAYERDIR_core}/recipes-kernel/linux/files:"
>> +
>> +SRC_URI = "file://getkernel.sh \
>> + file://rules.tmpl"
>> +
>> +TEMPLATE_VARS += "KERNEL_FILE KERNEL_DEB"
>> +TEMPLATE_FILES = "rules.tmpl"
>> +
>> +do_prepare_build[cleandirs] += "${S}/debian"
>> +do_prepare_build() {
>> + deb_debianize
>> + cp "${WORKDIR}/getkernel.sh" "${S}/debian/"
>> +}
>> +do_deploy_deb[noexec] = "1"
> That is definitely a hack. I would prefer if linux-distro can avoid
> inheriting dpkg, as this simply is not generating a package but just
> registering dependencies / provides.
I was experimenting a lot with other implementations and it looks like
this is
the only way which works for all the cases. We need to install kernel
package
(which actually can be not just linux-image, but something linux-image
package
depends on, or even separate packages for kernel and dtbs) into some
rootfs to
be sure we are deploying exact output files.
I'm also don't like this approach but we don't have any other options.
>
> Felix
>
>> diff --git a/testsuite/citest.py b/testsuite/citest.py
>> index 7d666880..5aa3e799 100644
>> --- a/testsuite/citest.py
>> +++ b/testsuite/citest.py
>> @@ -740,8 +740,6 @@ class DtbDeployTest(CIBaseTest):
>> self.init()
>> try:
>> self.perform_build_test(targets, image_install='')
>> - except exceptions.TestFail:
>> - self.cancel('KFAIL')
>> finally:
>> self.move_in_build_dir('tmp', 'tmp_dtbdeploy')
>>
>> --
>> 2.34.1
>>
>> --
>> 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 visit https://groups.google.com/d/msgid/isar-users/20260609084422.3948645-3-amikan%40ilbers.de.
--
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 visit https://groups.google.com/d/msgid/isar-users/3a696f95-0f63-43c9-a9c4-c75bf34a30ee%40ilbers.de.
next prev parent reply other threads:[~2026-06-30 12:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 8:44 [PATCH v11 0/3] " Anton Mikanovich
2026-06-09 8:44 ` [PATCH v11 1/3] meta: Fix do_copy_boot_files error for different distros of same machine Anton Mikanovich
2026-06-09 8:44 ` [PATCH v11 2/3] meta: Move kernel artifacts deployment from image recipe Anton Mikanovich
2026-06-29 16:04 ` 'MOESSBAUER, Felix' via isar-users
2026-06-30 12:21 ` Anton Mikanovich [this message]
2026-06-30 14:28 ` 'MOESSBAUER, Felix' via isar-users
2026-06-09 8:44 ` [PATCH v11 3/3] CI: Check kernel artifacts deployment Anton Mikanovich
2026-06-29 16:06 ` 'MOESSBAUER, Felix' via isar-users
2026-06-29 15:21 ` [PATCH v11 0/3] Move kernel artifacts deployment from image recipe Zhihang Wei
2026-06-29 15:54 ` 'MOESSBAUER, Felix' via isar-users
2026-06-30 12:21 ` Anton Mikanovich
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=3a696f95-0f63-43c9-a9c4-c75bf34a30ee@ilbers.de \
--to=amikan@ilbers.de \
--cc=felix.moessbauer@siemens.com \
--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