Skip to content

Commit

Permalink
feat(dracut-init.sh): introduce a new helper require_kernel_modules
Browse files Browse the repository at this point in the history
Some dracut modules won't work without certain kernel modules,
this helper will be helpful for checking such kernel configs in
check() and error out early.

Signed-off-by: Kairui Song <[email protected]>
  • Loading branch information
ryncsn authored and aafeijoo-suse committed Dec 21, 2022
1 parent 6c42d37 commit d3a5e63
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dracut-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ require_any_binary() {
return 0
}

# helper function for check() in module-setup.sh
# to check for required kernel modules
# issues a standardized warning message
require_kernel_modules() {
# shellcheck disable=SC2154
local _module_name="${moddir##*/}"
local _ret=0

if [[ $1 == "-m" ]]; then
_module_name="$2"
shift 2
fi

for mod in "$@"; do
if ! check_kernel_module "$mod" &> /dev/null; then
dinfo "dracut module '${_module_name#[0-9][0-9]}' will not be installed, because kernel module '$mod' is not available!"
((_ret++))
fi
done
return "$_ret"
}

dracut_need_initqueue() {
: > "$initdir/lib/dracut/need-initqueue"
}
Expand Down

0 comments on commit d3a5e63

Please sign in to comment.