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