From: Kairui Song Date: Mon, 15 Feb 2021 15:15:26 +0000 (+0800) Subject: feat: squash module follow --compress option X-Git-Tag: 054~326 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d05ffbd87bc27e27f517ebc3454d50729c687e6;p=thirdparty%2Fdracut.git feat: squash module follow --compress option 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. --- diff --git a/dracut.sh b/dracut.sh index a69e554d5..9b67e8734 100755 --- 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"