From 060b33c6d7683b5d762be96a3382dc6061f79f6f Mon Sep 17 00:00:00 2001 From: Ionen Wolkens Date: Tue, 30 May 2023 16:46:02 -0400 Subject: linux-mod-r1.eclass: generate and install depmod.d files Sneaking in another quick improvement while the eclass still has low tree usage, file is not *essential* so it can wait till next merge of the package to be active. e.g. if have (filesystem order): /lib/modules/6.3.4/not-right/ryzen_smu.ko /lib/modules/6.3.4/extra/ryzen_smu.ko It will load not-right/ryzen_smu.ko by default. But with /lib/depmod.d/ryzen_smu.conf having: override ryzen_smu 6.3.4 extra We more deterministically get extra's. Lacking this can be a problem when either want to override the kernel's own modules, or if portage left over behind modules in an outdated directory due to the default UNINSTALL_IGNORE for modules. Can be worse with e.g. nvidia given loading the wrong version of the module means everything will fail. And not everyone upgrade their kernel regularly to cleanup, some also install modules that aren't tracked by portage in different subdirs (including nvidia's...) which is not entirely surprising considering many build their kernel without portage/dist-kernel. Signed-off-by: Ionen Wolkens --- eclass/linux-mod-r1.eclass | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass index d665c42f9dd8..c914a7223efb 100644 --- a/eclass/linux-mod-r1.eclass +++ b/eclass/linux-mod-r1.eclass @@ -544,6 +544,7 @@ modules_post_process() { (( ${#mods[@]} )) || die "${FUNCNAME[0]} was called with no installed modules under ${path}" + _modules_process_depmod.d "${mods[@]#"${path}/"}" _modules_process_strip "${mods[@]}" _modules_process_sign "${mods[@]}" _modules_sanity_modversion "${mods[@]}" # after strip/sign in case broke it @@ -850,6 +851,27 @@ _modules_process_compress() { fi } +# @FUNCTION: _modules_process_depmod.d +# @USAGE: ... +# @INTERNAL +# @DESCRIPTION: +# Generate a depmod.d file to ensure priority if duplicate modules +# exist, such as stale modules in different directories, or to +# override the kernel's own modules. +_modules_process_depmod.d() { + ( + [[ ${SLOT%/*} == 0 ]] && slot= || slot=-${SLOT%/*} + insinto /lib/depmod.d + newins - ${PN}${slot}.conf < <( + echo "# Automatically generated by linux-mod-r1.eclass for ${CATEGORY}/${PN}" + for mod; do + [[ ${mod} =~ ^(.+)/(.+).ko$ ]] && + echo "override ${BASH_REMATCH[2]} ${KV_FULL} ${BASH_REMATCH[1]}" + done + ) + ) +} + # @FUNCTION: _modules_process_sign # @USAGE: ... # @INTERNAL -- cgit v1.2.3-65-gdbad