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. This commit introduce KERNEL_MODULE_INSTALL_PREFIX to resolve this issue. Signed-off-by: Anis Bougrine <[email protected]> --- meta/classes-recipe/kernel-arch.bbclass | 1 + meta/classes-recipe/kernel-module-split.bbclass | 2 +- meta/classes-recipe/kernel.bbclass | 12 ++++++------ meta/classes-recipe/module.bbclass | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass index 26b8a1a67f..91cceb8dc1 100644 --- a/meta/classes-recipe/kernel-arch.bbclass +++ b/meta/classes-recipe/kernel-arch.bbclass @@ -10,6 +10,7 @@ TARGET_CC_KERNEL_ARCH ?= "" TARGET_LD_KERNEL_ARCH ?= "" TARGET_AR_KERNEL_ARCH ?= "" TARGET_OBJCOPY_KERNEL_ARCH ?= "" +KERNEL_MODULE_INSTALL_PREFIX ?= "${nonarch_base_libdir}/modules/${KERNEL_VERSION}" KERNEL_CC:toolchain-gcc = "${CCACHE}${HOST_PREFIX}gcc ${TARGET_CC_KERNEL_ARCH} \ -fuse-ld=bfd ${DEBUG_PREFIX_MAP} \ diff --git a/meta/classes-recipe/kernel-module-split.bbclass b/meta/classes-recipe/kernel-module-split.bbclass index da7b30e99f..158fa98c50 100644 --- a/meta/classes-recipe/kernel-module-split.bbclass +++ b/meta/classes-recipe/kernel-module-split.bbclass @@ -82,7 +82,7 @@ post_strip_kernel_modules_signing(){ # be invoked manually after retrieving M= variable from package source code Makefile. oe_runmake \ -C ${KBUILD_OUTPUT} \ - MODLIB=${PKGD}${nonarch_base_libdir}/modules/${KERNEL_VERSION} \ + MODLIB=${PKGD}${KERNEL_MODULE_INSTALL_PREFIX} \ ${@'M=${@get_ext_mod(d)}' if not "virtual/kernel" in d.getVar('PROVIDES') else ''} \ modules_sign fi diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass index a82bdf7ecb..0a6d754108 100644 --- a/meta/classes-recipe/kernel.bbclass +++ b/meta/classes-recipe/kernel.bbclass @@ -453,11 +453,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}${KERNEL_MODULE_INSTALL_PREFIX} INSTALL_FW_PATH=${D}${firmwaredir} modules_install + rm -f "${D}${KERNEL_MODULE_INSTALL_PREFIX}/build" + rm -f "${D}${KERNEL_MODULE_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}${KERNEL_MODULE_INSTALL_PREFIX}/kernel" ] && find "${D}${KERNEL_MODULE_INSTALL_PREFIX}/kernel" -type d -empty -delete else bbnote "no modules to install" fi @@ -680,9 +680,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 = "${KERNEL_MODULE_INSTALL_PREFIX}/modules.order ${KERNEL_MODULE_INSTALL_PREFIX}/modules.builtin ${KERNEL_MODULE_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} ${KERNEL_MODULE_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" diff --git a/meta/classes-recipe/module.bbclass b/meta/classes-recipe/module.bbclass index ce5898125b..985c24bed5 100644 --- a/meta/classes-recipe/module.bbclass +++ b/meta/classes-recipe/module.bbclass @@ -46,7 +46,7 @@ module_do_compile() { module_do_install() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS - oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \ + oe_runmake DEPMOD=echo MODLIB="${D}${KERNEL_MODULE_INSTALL_PREFIX}" \ INSTALL_FW_PATH="${D}${firmwaredir}" \ CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \ STRIP="${KERNEL_STRIP}" \ -- 2.50.1 (Apple Git-155)
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#244363): https://lists.openembedded.org/g/openembedded-core/message/244363 Mute This Topic: https://lists.openembedded.org/mt/120933948/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
