Skip to content

Commit

Permalink
Rework weak modules logic
Browse files Browse the repository at this point in the history
- Fix variable check when determining if NO_WEAK_MODULES is set.
- kABI is available only on SUSE and RHEL platforms, so avoid setting parameters
  for all other distributions.
- For SUSE, use the new script provided in suse-module-tools and not the
  one provided by suse-module-tools-legacy.
  • Loading branch information
scaronni committed Jan 30, 2025
1 parent fdd5c0a commit c2e2096
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions dkms.in
Original file line number Diff line number Diff line change
Expand Up @@ -1512,9 +1512,9 @@ do_install()

# Add to kabi-tracking
if [[ -z $NO_WEAK_MODULES ]]; then
if [[ ${weak_modules} ]]; then
echo "Adding any weak-modules"
list_each_installed_module "$module" "$kernelver" "$arch" | ${weak_modules} ${weak_modules_no_initrd} --add-modules
if [[ ${weak_modules_add} ]]; then
echo "Adding linked weak modules..."
list_each_installed_module "$module" "$kernelver" "$arch" | ${weak_modules_add}
fi
fi

Expand Down Expand Up @@ -1723,9 +1723,9 @@ do_uninstall()
echo "Before uninstall, this module version was ACTIVE on this kernel."
# remove kabi-tracking if last instance removed
if [[ -z $NO_WEAK_MODULES ]]; then
if [[ ${weak_modules} ]] && (module_status_built $module $module_version |grep -q "installed"); then
echo "Removing any linked weak-modules"
list_each_installed_module "$module" "$1" "$2" | ${weak_modules} ${weak_modules_no_initrd} --remove-modules
if [[ ${weak_modules_remove} ]] && (module_status_built $module $module_version |grep -q "installed"); then
echo "Removing linked weak modules..."
list_each_installed_module "$module" "$1" "$2" | ${weak_modules_remove}
fi
fi

Expand Down Expand Up @@ -1906,8 +1906,8 @@ find_module_from_ko()
module_status_weak() {
# $1 = module, $2 = module version, $3 = kernel version weak installed to,
# $4 = kernel arch, $5 = kernel version built for
[[ -z $NO_WEAK_MODULES ]] || return 1
[[ $weak_modules ]] || return 1
[[ -n $NO_WEAK_MODULES ]] || return 1
[[ $weak_modules_add ]] && [[ $weak_modules_remove ]] || continue
local m
local v
local k
Expand Down Expand Up @@ -2714,7 +2714,6 @@ rm -f "$tmpfile"
# These can come from the environment or the config file
[[ ! ${ADDON_MODULES_DIR} && -e /etc/sysconfig/module-init-tools ]] && . /etc/sysconfig/module-init-tools
addon_modules_dir="${ADDON_MODULES_DIR}"
weak_modules="${WEAK_MODULES_BIN}"

# Source in configuration not related to signing
read_framework_conf $dkms_framework_nonsigning_variables
Expand All @@ -2741,13 +2740,12 @@ module_uncompressed_suffix=""
module_compressed_suffix=""
rpm_safe_upgrade=""
declare -a directive_array=() kernelver=() arch=()
weak_modules=''
weak_modules_add=''
weak_modules_remove=''
last_mvka=''
last_mvka_conf=''
try_source_tree=''
die_is_fatal="yes"
[ -x /sbin/weak-modules ] && weak_modules='/sbin/weak-modules'
[ -x /usr/lib/module-init-tools/weak-modules ] && weak_modules='/usr/lib/module-init-tools/weak-modules'
no_depmod=""
delayed_depmod=""
prepared_kernel="none"
Expand Down Expand Up @@ -2921,11 +2919,6 @@ if [[ $arch && $all ]]; then
"--all on the command line."
fi

# Since initramfs/initrd rebuild is not requested, skip it with Redhat's weak-modules
if [[ $weak_modules ]]; then
weak_modules_no_initrd="--no-initramfs"
fi

# Default to -j<number of CPUs>
parallel_jobs=${parallel_jobs:-$(get_num_cpus)}

Expand All @@ -2936,6 +2929,23 @@ parallel_jobs=${parallel_jobs:-$(get_num_cpus)}
[[ $action =~ kernel_(postinst|prerm) ]] && have_one_kernel "$action"

setup_kernels_arches "$action"

# Since initramfs/initrd rebuild is not requested, skip it with Redhat's weak-modules
if [[ $weak_modules ]]; then
case "$running_distribution" in
rhel*)
weak_modules_add='/usr/sbin/weak-modules --no-initramfs --add-modules' && return
weak_modules_remove='/usr/sbin/weak-modules --no-initramfs --remove-modules' && return
;;
sles* | suse* | opensuse*)
weak_modules_add='/usr/lib/module-init-tools/weak-modules2 --add-kernel-modules ${kernelver}' && return
weak_modules_remove='/usr/lib/module-init-tools/weak-modules2 --add-kernel-modules ${kernelver}' && return
;;
*)
;;
esac
fi

case "$action" in
remove | unbuild | uninstall)
check_module_args $action
Expand Down

0 comments on commit c2e2096

Please sign in to comment.