File 0525-backport-bail-out-if-module-directory-does-not-exist.patch of Package dracut.12460

From cb1c81fc7f6bc72a72de1f87847924572aa39b54 Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <dmolkentin@suse.com>
Date: Thu, 29 Jun 2017 17:18:37 +0200
Subject: [PATCH] backport: bail out if module directory does not exist

this basically reverts commit
05214a0bedc084a41c35a128609745ad04a0c6cf

if people want to build the initramfs without kernel modules,
then --no-kernel should be specified

Upstream-Commit: 106255afd46ea2be1d035aca0c5695186a3f2c41
---
 dracut.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/dracut.sh b/dracut.sh
index 1016d5ae..492ecbf7 100755
--- a/dracut.sh
+++ b/dracut.sh
@@ -632,12 +632,6 @@ if ! [[ $kernel ]]; then
     kernel=$(uname -r)
 fi
 
-if [[ $kernel ]]; then
-    if ! [[ -d /lib/modules/$kernel ]] && [[ $no_kernel != yes ]]; then
-        printf -- "Kernel version $kernel has no module directory /lib/modules/$kernel\n" >&2
-    fi
-fi
-
 if ! [[ $outfile ]]; then
     [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
 
@@ -892,6 +886,12 @@ else
     exit 1
 fi
 
+if [[ $no_kernel != yes ]] && ! [[ -d $srcmods ]]; then
+    printf "%s\n" "dracut: Cannot find module directory $srcmods" >&2
+    printf "%s\n" "dracut: and --no-kernel was not specified" >&2
+    exit 1
+fi
+
 if ! [[ $print_cmdline ]]; then
     inst /bin/sh
     if ! $DRACUT_INSTALL ${initdir:+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null; then
-- 
2.12.3