All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Anis Bougrine <anis.bougrine10@gmail.com>,
	 openembedded-core@lists.openembedded.org
Cc: mathieu.dubois-briand@bootlin.com, peter.kjellerstedt@axis.com,
	Ross Burton	 <ross.burton@arm.com>
Subject: Re: [OE-core][PATCH v5 1/5] kernel-module-split.bbclass: add get_ext_mod function for module signing
Date: Wed, 26 Aug 2026 09:33:58 +0100	[thread overview]
Message-ID: <6511319d17498eae1dba2a199f07123ca8488454.camel@linuxfoundation.org> (raw)
In-Reply-To: <20260825204931.17628-2-anis.bougrine10@gmail.com>

On Tue, 2026-08-25 at 22:49 +0200, Anis Bougrine wrote:
> Fixes [YOCTO #12927]
> 
> Out-of-tree module Makefiles invoke the kernel Makefile by appending
> the M= (the module directory) variable to the MAKEFLAGS.
> However, they usually do not provide a modules_sign target. Therefore,
> the kernel modules_sign target has to be invoked manually after retrieving
> M= variable from package source code Makefile.
> 
> This function retrieves the M= variable from an external module Makefile.
> 
> Reported-by: Ross Burton <ross.burton@arm.com>
> Signed-off-by: Anis Bougrine <anis.bougrine10@gmail.com>
> ---
>  .../kernel-module-split.bbclass               | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/meta/classes-recipe/kernel-module-split.bbclass b/meta/classes-recipe/kernel-module-split.bbclass
> index ab2f0d1c37..bde7cd02dd 100644
> --- a/meta/classes-recipe/kernel-module-split.bbclass
> +++ b/meta/classes-recipe/kernel-module-split.bbclass
> @@ -42,6 +42,27 @@ KERNEL_MODULE_PACKAGE_PREFIX ?= ""
>  KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
>  KERNEL_MODULE_PROVIDE_VIRTUAL ?= "1"
>  
> +def get_ext_mod(d):
> +    """
> +    Extract the resolved Kbuild M= variable from an out of tree module Makefile variable database.
> +    """
> +    import re
> +    import bb.process
> +
> +    try:
> +        output = bb.process.run(
> +            "make -C %s --dry-run --print-data-base" % d.getVar("B")
> +        )[0]
> +    except bb.process.ExecutionError:
> +        return d.getVar("S")
> +
> +    for line in output.splitlines():
> +        m = re.match(r'^M\s*=\s*(.*)$', line)
> +        if m:
> +            return m.group(1).strip()
> +
> +    return d.getVar("S")
> +
>  python split_kernel_module_packages () {
>      import re
> 

Sorry, a couple of more things. I'm not sure if it helps but there is a
scripts/makefile-getvar which may be a simpler way to do this? It was
created for this kind of usage.

Also, we're aiming to move python functions into meta/lib/oe, probably
kernel.py in this case so new functions should really go in there.

Cheers,

Richard


  reply	other threads:[~2026-08-26  8:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 20:49 [OE-core][PATCH v5 0/5] Make signed kernel modules stripped Anis Bougrine
2026-08-25 20:49 ` [OE-core][PATCH v5 1/5] kernel-module-split.bbclass: add get_ext_mod function for module signing Anis Bougrine
2026-08-26  8:33   ` Richard Purdie [this message]
2026-08-26  9:55     ` Bougrine Anis
2026-08-25 20:49 ` [OE-core][PATCH v5 2/5] kernel: re-sign kernel modules after package stripping process Anis Bougrine
2026-08-25 20:49 ` [OE-core][PATCH v5 3/5] package.py: remove stripping and splitting skip for signed kernel modules Anis Bougrine
2026-08-25 20:49 ` [OE-core][PATCH v5 4/5] kernel: centralize kernel module installation path in one variable Anis Bougrine
2026-08-25 20:49 ` [OE-core][PATCH v5 5/5] documentation.conf: add documentation for KERNEL_MODULE_INSTALL_PREFIX variable Anis Bougrine
2026-08-25 21:03   ` Patchtest results for " patchtest
2026-08-26  7:24   ` Antonin Godard

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=6511319d17498eae1dba2a199f07123ca8488454.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=anis.bougrine10@gmail.com \
    --cc=mathieu.dubois-briand@bootlin.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=peter.kjellerstedt@axis.com \
    --cc=ross.burton@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.