]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut.sh: check kmoddir is properly formed
authorDaniel Cordero <dracut@0xdc.io>
Fri, 24 Jan 2020 16:14:25 +0000 (16:14 +0000)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 27 Jan 2020 08:02:46 +0000 (09:02 +0100)
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.

dracut.sh

index f44b6b471509775c93e5adfd19c7de607b38b274..6738dc91a90d2f706abd257b4aac024088a55b76 100755 (executable)
--- 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