From: Daniel Cordero Date: Fri, 24 Jan 2020 16:14:25 +0000 (+0000) Subject: dracut.sh: check kmoddir is properly formed X-Git-Tag: 050~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f668e7174e691869d00fcc94090ea85d3defe686;p=thirdparty%2Fdracut.git dracut.sh: check kmoddir is properly formed Due to the way dracut-install handles modules from custom kmoddirs, add a test that ensures the kmoddir argument seems sane. In addition to erroring out, provide some guidance on how to proceed, as well as a method of skipping the test via environment variable. --- diff --git a/dracut.sh b/dracut.sh index f44b6b471..6738dc91a 100755 --- a/dracut.sh +++ b/dracut.sh @@ -918,6 +918,21 @@ esac [[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1 +case "${drivers_dir}" in + ''|*lib/modules/${kernel}|*lib/modules/${kernel}/) ;; + *) + [[ "$DRACUT_KMODDIR_OVERRIDE" ]] || { + printf "%s\n" "dracut: -k/--kmoddir path must contain \"lib/modules\" as a parent of your kernel module directory," + printf "%s\n" "dracut: or modules may not be placed in the correct location inside the initramfs." + printf "%s\n" "dracut: was given: ${drivers_dir}" + printf "%s\n" "dracut: expected: $(dirname ${drivers_dir})/lib/modules/${kernel}" + printf "%s\n" "dracut: Please move your modules into the correct directory structure and pass the new location," + printf "%s\n" "dracut: or set DRACUT_KMODDIR_OVERRIDE=1 to ignore this check." + exit 1 + } + ;; +esac + readonly TMPDIR="$(realpath -e "$tmpdir")" [ -d "$TMPDIR" ] || { printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2