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