From: Anis Bougrine <anis.bougrine10@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: antonin.godard@bootlin.com, bruce.ashfield@gmail.com,
jose.quaresma@oss.qualcomm.com,
richard.purdie@linuxfoundation.org,
Anis Bougrine <anis.bougrine10@gmail.com>
Subject: [OE-core][PATCH v4 3/4] kernel: centralize kernel module installation path in one variable
Date: Sat, 22 Aug 2026 02:26:00 +0200 [thread overview]
Message-ID: <20260822002601.90667-4-anis.bougrine10@gmail.com> (raw)
In-Reply-To: <20260822002601.90667-1-anis.bougrine10@gmail.com>
The kernel module installation path is currently defined in multiple
places, although it is used 10 times throughout the code. This
increases the risk of bugs due to inconsistencies or desynchronization.
Centralizing the path in a single variable makes the code more
reliable and easier to maintain.
Signed-off-by: Anis Bougrine <anis.bougrine10@gmail.com>
---
changes in v4:
- Re-sign kernel modules after package stripping process
- Remove package-stripping skip in package.py
- Add MOD_INSTALL_PREFIX variable
changes in v3:
- Fixing rebase issue.
changes in v2:
- Use the conditional INSTALL_MOD_STRIP environment variable to avoid
duplicating the oe_runmake call.
- Use `scripts/config` script instead of grepping .config file.
---
meta/classes-recipe/kernel-module-split.bbclass | 4 +++-
meta/classes-recipe/kernel.bbclass | 13 +++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/meta/classes-recipe/kernel-module-split.bbclass b/meta/classes-recipe/kernel-module-split.bbclass
index 253a723b95..061522fc22 100644
--- a/meta/classes-recipe/kernel-module-split.bbclass
+++ b/meta/classes-recipe/kernel-module-split.bbclass
@@ -48,6 +48,8 @@ KERNEL_MODULE_PACKAGE_SUFFIX ?= "-${KERNEL_VERSION}"
KERNEL_MODULE_PROVIDE_VIRTUAL ?= "1"
# Sign kernel modules if auto-signing is enabled in the kernel config
+# MOD_INSTALL_PREFIX must be the same at installation and signing time.
+MOD_INSTALL_PREFIX ?= "${nonarch_base_libdir}/modules/${KERNEL_VERSION}"
post_strip_kernel_modules_signing(){
# Read .config values
is_modules="$(${S}/scripts/config --file ${B}/.config --state MODULES)"
@@ -58,7 +60,7 @@ post_strip_kernel_modules_signing(){
# Sign modules under ${PKGD}
oe_runmake \
-C ${B} \
- MODLIB=${PKGD}${nonarch_base_libdir}/modules/${KERNEL_VERSION} \
+ MODLIB=${PKGD}${MOD_INSTALL_PREFIX} \
modules_sign
fi
}
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index a82bdf7ecb..18bad854ce 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -38,6 +38,7 @@ S = "${STAGING_KERNEL_DIR}"
B = "${WORKDIR}/build"
KBUILD_OUTPUT = "${B}"
OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT"
+MOD_INSTALL_PREFIX = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}"
# we include gcc above, we dont need virtual/libc
INHIBIT_DEFAULT_DEPS = "1"
@@ -453,11 +454,11 @@ kernel_do_install() {
#
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
- oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${firmwaredir} modules_install
- rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
- rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
+ oe_runmake DEPMOD=echo MODLIB=${D}${MOD_INSTALL_PREFIX} INSTALL_FW_PATH=${D}${firmwaredir} modules_install
+ rm -f "${D}${MOD_INSTALL_PREFIX}/build"
+ rm -f "${D}${MOD_INSTALL_PREFIX}/source"
# Remove empty module directories to prevent QA issues
- [ -d "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" ] && find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
+ [ -d "${D}${MOD_INSTALL_PREFIX}/kernel" ] && find "${D}${MOD_INSTALL_PREFIX}/kernel" -type d -empty -delete
else
bbnote "no modules to install"
fi
@@ -680,9 +681,9 @@ EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs d
# kernel-image becomes kernel-image-${KERNEL_VERSION}
PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules ${KERNEL_PACKAGE_NAME}-dbg"
FILES:${PN} = ""
-FILES:${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin.modinfo"
+FILES:${KERNEL_PACKAGE_NAME}-base = "${MOD_INSTALL_PREFIX}/modules.order ${MOD_INSTALL_PREFIX}/modules.builtin ${MOD_INSTALL_PREFIX}/modules.builtin.modinfo"
FILES:${KERNEL_PACKAGE_NAME}-image = ""
-FILES:${KERNEL_PACKAGE_NAME}-dev = "/${KERNEL_IMAGEDEST}/System.map* /${KERNEL_IMAGEDEST}/Module.symvers* /${KERNEL_IMAGEDEST}/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
+FILES:${KERNEL_PACKAGE_NAME}-dev = "/${KERNEL_IMAGEDEST}/System.map* /${KERNEL_IMAGEDEST}/Module.symvers* /${KERNEL_IMAGEDEST}/config* ${KERNEL_SRC_PATH} ${MOD_INSTALL_PREFIX}/build"
FILES:${KERNEL_PACKAGE_NAME}-vmlinux = "/${KERNEL_IMAGEDEST}/vmlinux-${KERNEL_VERSION_NAME}"
FILES:${KERNEL_PACKAGE_NAME}-modules = ""
FILES:${KERNEL_PACKAGE_NAME}-dbg = "/usr/lib/debug /usr/src/debug"
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-08-22 0:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 0:25 [OE-core][PATCH v4 0/4] Make signed kernel modules stripped Anis Bougrine
2026-08-22 0:25 ` [OE-core][PATCH v4 1/4] kernel.bbclass: re-sign kernel modules after package stripping process Anis Bougrine
2026-08-22 0:25 ` [OE-core][PATCH v4 2/4] package.py: remove stripping and splitting skip for signed kernel modules Anis Bougrine
2026-08-22 0:26 ` Anis Bougrine [this message]
2026-08-24 18:57 ` [OE-core][PATCH v4 3/4] kernel: centralize kernel module installation path in one variable Richard Purdie
2026-08-22 0:26 ` [OE-core][PATCH v4 4/4] documentation.conf: add documentation for MOD_INSTALL_PREFIX variable Anis Bougrine
2026-08-22 16:12 ` [OE-core][PATCH v4 0/4] Make signed kernel modules stripped Mathieu Dubois-Briand
2026-08-24 0:03 ` Bougrine Anis
2026-08-25 18:33 ` Peter Kjellerstedt
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=20260822002601.90667-4-anis.bougrine10@gmail.com \
--to=anis.bougrine10@gmail.com \
--cc=antonin.godard@bootlin.com \
--cc=bruce.ashfield@gmail.com \
--cc=jose.quaresma@oss.qualcomm.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=richard.purdie@linuxfoundation.org \
/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