Skip to content

Commit d3a5e63

Browse files
ryncsnaafeijoo-suse
authored andcommitted
feat(dracut-init.sh): introduce a new helper require_kernel_modules
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 <kasong@tencent.com>
1 parent 6c42d37 commit d3a5e63

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

dracut-init.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,28 @@ require_any_binary() {
150150
return 0
151151
}
152152

153+
# helper function for check() in module-setup.sh
154+
# to check for required kernel modules
155+
# issues a standardized warning message
156+
require_kernel_modules() {
157+
# shellcheck disable=SC2154
158+
local _module_name="${moddir##*/}"
159+
local _ret=0
160+
161+
if [[ $1 == "-m" ]]; then
162+
_module_name="$2"
163+
shift 2
164+
fi
165+
166+
for mod in "$@"; do
167+
if ! check_kernel_module "$mod" &> /dev/null; then
168+
dinfo "dracut module '${_module_name#[0-9][0-9]}' will not be installed, because kernel module '$mod' is not available!"
169+
((_ret++))
170+
fi
171+
done
172+
return "$_ret"
173+
}
174+
153175
dracut_need_initqueue() {
154176
: > "$initdir/lib/dracut/need-initqueue"
155177
}

0 commit comments

Comments
 (0)