]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat: squash module follow --compress option
authorKairui Song <kasong@redhat.com>
Mon, 15 Feb 2021 15:15:26 +0000 (23:15 +0800)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Tue, 9 Mar 2021 13:40:35 +0000 (13:40 +0000)
Try to make mksquashfs follow --compress option if squash module is
included, if not specified or invalid, fall back to use mksquashfs's
default compressor.

dracut.sh

index a69e554d5dce04123238ce1ce14ceec0393dfd5c..9b67e8734e75c69fc19b66b1fd96f92c98684b78 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -2033,12 +2033,22 @@ fi
 
 if dracut_module_included "squash"; then
     dinfo "*** Squashing the files inside the initramfs ***"
+    declare squash_compress_arg
+    # shellcheck disable=SC2086
+    if [[ $compress ]]; then
+        if ! mksquashfs /dev/null "$DRACUT_TMPDIR"/.squash-test.img -no-progress -comp $compress &>/dev/null; then
+            dwarn "mksquashfs doesn't support compressor '$compress', failing back to default compressor."
+        else
+            squash_compress_arg="$compress"
+        fi
+    fi
+
+    # shellcheck disable=SC2086
     if ! mksquashfs "$squash_dir" "$squash_img" \
-        -no-xattrs -no-exports -noappend -always-use-fragments \
-        -comp xz -Xdict-size 100% -no-progress \
-        > /dev/null; then
-        dfatal "dracut: Failed making squash image"
-        exit 1
+        -no-xattrs -no-exports -noappend -no-recovery -always-use-fragments \
+        -no-progress ${squash_compress_arg:+-comp $squash_compress_arg} 1> /dev/null; then
+            dfatal "dracut: Failed making squash image"
+            exit 1
     fi
 
     rm -rf "$squash_dir"