From: Zhihang Wei <wzh@ilbers.de>
To: Jan Kiszka <jan.kiszka@siemens.com>,
isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH] meta: kernel: Make specifying KERNEL_CONFIG_FRAGMENTS more flexible
Date: Wed, 25 Mar 2026 16:22:56 +0100 [thread overview]
Message-ID: <4327810b-f425-4602-a7a2-c9a40de071b3@ilbers.de> (raw)
In-Reply-To: <f8937fee-2491-49ed-9086-7be1f481a60a@siemens.com>
On 3/23/26 08:03, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> This allows to add kernel config fragments from other sources than just
> individual files in SRC_URI.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> isar-cip-core will first use this, currently externalizing part of its
> in-tree fragments to the cip-kernel-config repo.
>
> RECIPE-API-CHANGELOG.md | 9 +++++
> meta/classes-recipe/linux-kernel.bbclass | 37 ++++++++++++-------
> .../linux/files/debian/isar/configure.tmpl | 2 +-
> 3 files changed, 33 insertions(+), 15 deletions(-)
>
> diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
> index e44b4b9d..2eff4fc3 100644
> --- a/RECIPE-API-CHANGELOG.md
> +++ b/RECIPE-API-CHANGELOG.md
> @@ -972,3 +972,12 @@ we introduce the variables ``MMAPTOPT_NOEXPKEYSIGN`` and ``DISTRO_MM_OPTS``.
> While the former provides an argument to disable the key expiry checking, the
> latter allows users to inject custom options into ``mmdebstrap``. For details,
> see ``man mmdebstrap``. Use with care!
> +
> +### Provide additional fragments via KERNEL_CONFIG_FRAGMENTS
> +
> +Custom kernel builds can now inject config fragments into the build which were
> +not provided via individual SRC_URI entries. If a kernel source tree contains a
> +fragment, this can be specified via adding `${S}/path/to/fragment.cfg` to
> +`KERNEL_CONFIG_FRAGMENTS`. If a fragment was checked out into ${WORKDIR} as
> +part of a repository, a tarball, or some other directory structure, just
> +specify it relative to ${WORKDIR} in `KERNEL_CONFIG_FRAGMENTS`.
> diff --git a/meta/classes-recipe/linux-kernel.bbclass b/meta/classes-recipe/linux-kernel.bbclass
> index 6e383408..9429996f 100644
> --- a/meta/classes-recipe/linux-kernel.bbclass
> +++ b/meta/classes-recipe/linux-kernel.bbclass
> @@ -83,7 +83,7 @@ TEMPLATE_VARS += " \
> KERNEL_LIBC_DEV_ARCH \
> LINUX_VERSION_EXTENSION \
> KERNEL_NAME_PROVIDED \
> - KERNEL_CONFIG_FRAGMENTS \
> + KCONFIG_FRAGMENTS \
> KCFLAGS \
> KAFLAGS \
> DISTRIBUTOR \
> @@ -214,8 +214,10 @@ KERNEL_ARCH ??= "${@get_kernel_arch(d)}"
> # set KERNEL_FILE without depending on package arch used in bitbake.conf
> KERNEL_FILE:forcevariable = "${@ 'vmlinux' if d.getVar('KERNEL_ARCH') in ['mipsel', 'riscv', 'arm64'] else 'vmlinuz'}"
>
> +KERNEL_CONFIG_FRAGMENTS ?= ""
> +
> def config_fragments(d):
> - fragments = []
> + fragments = d.getVar('KERNEL_CONFIG_FRAGMENTS').split()
> sources = d.getVar("SRC_URI").split()
> for s in sources:
> _, _, local, _, _, parm = bb.fetch.decodeurl(s)
> @@ -284,17 +286,21 @@ def get_kernel_config_target(d):
>
> return config_target
>
> -def get_kernel_config_fragments(d):
> - src_frags = " ".join(config_fragments(d))
> - out_frags = " ".join(map(lambda frag: 'debian/fragments/' + frag, config_fragments(d)))
> -
> - linux_version_extension = d.getVar('LINUX_VERSION_EXTENSION')
> - if linux_version_extension:
> - out_frags += " debian/isar/version.cfg"
> +KERNEL_CONFIG_FRAGMENTS:append = " \
> + ${@'${S}/debian/isar/version.cfg' if d.getVar('LINUX_VERSION_EXTENSION') else ''}"
>
> - return out_frags
> +def get_kernel_config_fragments(d):
> + out_frags = ""
> + S = d.getVar('S') + '/'
> + for frag in config_fragments(d):
> + if frag.startswith(S):
> + out_frags += ' ' + frag[len(S):]
> + else:
> + out_frags += ' debian/fragments/' + frag
> + return out_frags.strip()
>
> -KERNEL_CONFIG_FRAGMENTS = "${@get_kernel_config_fragments(d)}"
> +# internal list of config fragments
> +KCONFIG_FRAGMENTS = "${@get_kernel_config_fragments(d)}"
>
> dpkg_configure_kernel() {
> grep -q "KERNEL_CONFIG_TARGET=" ${S}/debian/isar/configure ||
> @@ -313,9 +319,12 @@ EOF
> src_frags="${@ " ".join(config_fragments(d)) }"
> rm -rf ${S}/debian/fragments
> for frag in ${src_frags}; do
> - basedir=$(dirname ${frag})
> - mkdir -p ${S}/debian/fragments/${basedir}
> - cp ${WORKDIR}/${frag} ${S}/debian/fragments/${basedir}/
> + # skip frag if it starts with ${S}, thus is part of the sources
> + if [ "${frag#${S}}" = "$frag" ]; then
> + basedir=$(dirname ${frag})
> + mkdir -p ${S}/debian/fragments/${basedir}
> + cp ${WORKDIR}/${frag} ${S}/debian/fragments/${basedir}/
> + fi
> done
> }
>
> diff --git a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl
> index 73f554ed..75c920b8 100644
> --- a/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl
> +++ b/meta/recipes-kernel/linux/files/debian/isar/configure.tmpl
> @@ -26,7 +26,7 @@ do_configure() {
> # Process kernel config target and fragments
> ${MAKE} O=${KERNEL_BUILD_DIR} ${KERNEL_CONFIG_TARGET}
> ./scripts/kconfig/merge_config.sh -O ${KERNEL_BUILD_DIR}/ \
> - ${KERNEL_BUILD_DIR}/.config ${KERNEL_CONFIG_FRAGMENTS}
> + ${KERNEL_BUILD_DIR}/.config ${KCONFIG_FRAGMENTS}
> fi
>
> # Stop tracing
Could you add a test case for this usage?
Zhihang
--
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/4327810b-f425-4602-a7a2-c9a40de071b3%40ilbers.de.
next prev parent reply other threads:[~2026-03-25 15:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 7:03 'Jan Kiszka' via isar-users
2026-03-25 15:22 ` Zhihang Wei [this message]
2026-03-27 16:58 ` [PATCH] meta-isar: linux-mainline: Adjust config fragment usage 'Jan Kiszka' via isar-users
2026-04-01 15:43 ` Zhihang Wei
2026-04-01 15:43 ` [PATCH] meta: kernel: Make specifying KERNEL_CONFIG_FRAGMENTS more flexible Zhihang Wei
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=4327810b-f425-4602-a7a2-c9a40de071b3@ilbers.de \
--to=wzh@ilbers.de \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.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