From 89b8779a84119abaa8c64efdf441342ba13ed6f9 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Sat, 20 Sep 2025 15:41:30 +0200 Subject: [PATCH] Support /usr/lib/modules/kmp as install path for KMPs Installing KMPs separately from the kernel they are built and using weak-updates for all kernel versions - including the one the module was originally built for. The weak-modules2 script already incorporates logic to create weak updates for only one module version (i.e. the latest one) per kernel version. This way - together with the use of a versioned installation directory using INSTALL_MOD_DIR during module installation it is possible to overcome the one KMP update per kernel version limitation (see discussion in jsc#PED-12049). Signed-off-by: Egbert Eich --- driver-check.sh | 2 +- weak-modules2 | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/driver-check.sh b/driver-check.sh index 925eaa1..45c176e 100644 --- a/driver-check.sh +++ b/driver-check.sh @@ -176,7 +176,7 @@ check_kmp() if ! rpm -q -R "$kmp" | grep -Eq "$req_re"; then error "$kmp does not have proper dependencies" fi - exec 3< <(sed -rn 's:^(/lib/modules)?/([^/]*)/(.*\.ko(\.[gx]z|\.zst)?)$:\1 \2 \3:p' \ + exec 3< <(sed -rn 's:^(/lib/modules(/kmp)?)?/([^/]*)/(.*\.ko(\.[gx]z|\.zst)?)$:\1 \3 \4:p' \ "$tmp/rpms/$kmp") while read prefix krel path <&3; do found_module=true diff --git a/weak-modules2 b/weak-modules2 index 23a023c..a91f69f 100644 --- a/weak-modules2 +++ b/weak-modules2 @@ -3,10 +3,10 @@ ############################################################################## # How it works: # * Kernels install modules below /lib/modules/$krel/kernel/. -# * KMPs install modules below /lib/modules/$krel/updates/ or .../extra/. +# * KMPs install modules below /lib/modules/[kmp/]$krel/updates/ or .../extra/. # * Symbolic links to modules of compatible KMPs are created under # /lib/modules/$krel/weak-updates/{updates,extra}/... (the original path -# below /lib/modules/$other_krel is used). +# below /lib/modules/[kmod/]$other_krel is used). # * Depmod searches the directories in this order: updates/, extra/, # weak-updates/, kernel/ (see /etd/depmod.conf or # /etc/depmod.d/00-system.conf for details). @@ -121,9 +121,11 @@ strip_mod_extensions() { # Name of the symlink that makes a module available to a given kernel symlink_to_module() { - local module=$1 krel=$2 + local module=$1 krel=$2 val - echo /lib/modules/$krel/weak-updates/${module#/lib/modules/*/} + val=${module#/lib/modules/} + val=${val#kmp/} + echo /lib/modules/$krel/weak-updates/${val#*/} } # Is a kmp already present in or linked to from this kernel? @@ -280,7 +282,7 @@ check_kmp() { local kmp=$1 # Make sure all modules are for the same kernel - set -- $(sed -re 's:^/lib/modules/([^/]+)/.*:\1:' \ + set -- $(sed -re 's:^/lib/modules(/kmp)?/([^/]+)/.*:\2:' \ $tmpdir/modules-$kmp \ | sort -u) if [ $# -ne 1 ]; then @@ -292,7 +294,7 @@ check_kmp() { dlog "check_kmp: $kmp contains modules for $1" # Make sure none of the modules are in kernel/ or weak-updates/ - if grep -qE -e '^/lib/modules/[^/]+/(kernel|weak-updates)/' \ + if grep -qE -e '^/lib/modules(/kmp)?/[^/]+/(kernel|weak-updates)/' \ $tmpdir/modules-$kmp; then echo "Error: package $kmp must not install modules into " \ "kernel/ or weak-updates/" >&2 @@ -317,7 +319,7 @@ find_kmps() { continue fi rpm -ql --nodigest --nosignature "$kmp" \ - | sed -nr 's:^(/usr)?(/lib/modules/[^/]+/.+\.ko)(\.[gx]z|\.zst)?$:\2\3:p' \ + | sed -nr 's:^(/usr)?(/lib/modules(/kmp)?/[^/]+/.+\.ko)(\.[gx]z|\.zst)?$:\2\4:p' \ > $tmpdir/modules-$kmp if [ $? != 0 ]; then echo "WARNING: $kmp does not contain any kernel modules" >&2