9f65cc
From a5b46f9fad27954206fe47dedcef350f77f244a0 Mon Sep 17 00:00:00 2001
9f65cc
From: Kairui Song <kasong@redhat.com>
9f65cc
Date: Mon, 8 Jun 2020 17:00:00 +0800
9f65cc
Subject: [PATCH] 99squash: improve pre-requirements check
9f65cc
9f65cc
Check for systemd-initrd and squashfs-tools in check() to fail early if
9f65cc
it won't work.
9f65cc
9f65cc
Signed-off-by: Kairui Song <kasong@redhat.com>
9f65cc
(cherry picked from commit cfd872392c59c96665c558899880d6b2980065bb)
9f65cc
9f65cc
Resolves: #1959336
9f65cc
---
9f65cc
 modules.d/99squash/module-setup.sh | 17 +++++++++++------
9f65cc
 1 file changed, 11 insertions(+), 6 deletions(-)
9f65cc
9f65cc
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
9f65cc
index 72fa81f0..6307377c 100644
9f65cc
--- a/modules.d/99squash/module-setup.sh
9f65cc
+++ b/modules.d/99squash/module-setup.sh
9f65cc
@@ -1,11 +1,21 @@
9f65cc
 #!/bin/bash
9f65cc
 
9f65cc
 check() {
9f65cc
+    if ! dracut_module_included "systemd-initrd"; then
9f65cc
+        derror "dracut-squash only supports systemd bases initramfs"
9f65cc
+        return 1
9f65cc
+    fi
9f65cc
+
9f65cc
+    if ! type -P mksquashfs >/dev/null || ! type -P unsquashfs >/dev/null ; then
9f65cc
+        derror "dracut-squash module requires squashfs-tools"
9f65cc
+        return 1
9f65cc
+    fi
9f65cc
+
9f65cc
     return 255
9f65cc
 }
9f65cc
 
9f65cc
 depends() {
9f65cc
-    echo "bash systemd systemd-initrd"
9f65cc
+    echo "bash systemd-initrd"
9f65cc
     return 0
9f65cc
 }
9f65cc
 
9f65cc
@@ -14,11 +24,6 @@ installkernel() {
9f65cc
 }
9f65cc
 
9f65cc
 install() {
9f65cc
-    if ! type -P mksquashfs >/dev/null || ! type -P unsquashfs >/dev/null ; then
9f65cc
-        derror "squash module requires squashfs-tools to be installed."
9f65cc
-        return 1
9f65cc
-    fi
9f65cc
-
9f65cc
     inst_multiple kmod modprobe mount mkdir ln echo
9f65cc
     inst $moddir/setup-squash.sh /squash/setup-squash.sh
9f65cc
     inst $moddir/clear-squash.sh /squash/clear-squash.sh
9f65cc