From: Martin Wilck Date: Fri, 19 Nov 2021 11:47:32 +0000 (+0100) Subject: fix(dracut.sh): check availability of configured compression X-Git-Tag: 056~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdac657bf65615438942a872491a818750735014;p=thirdparty%2Fdracut.git fix(dracut.sh): check availability of configured compression If the configured compression command is unavailable, reset $compress, and fall back to auto-detection. This allows building an initramfs even if the configured compression command is not installed. This can happen e.g. if the distribution uses a preconfigured default, but the user deinstalled the respective tool. --- diff --git a/dracut.sh b/dracut.sh index 387f5bbe0..c6089ba63 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2350,6 +2350,13 @@ if [[ $create_early_cpio == yes ]]; then fi fi +if [[ $compress && $compress != cat ]]; then + if ! command -v "${compress%% *}" &> /dev/null; then + derror "dracut: cannot execute compression command '$compress', falling back to default" + compress= + fi +fi + if ! [[ $compress ]]; then # check all known compressors, if none specified for i in $DRACUT_COMPRESS_PIGZ $DRACUT_COMPRESS_GZIP $DRACUT_COMPRESS_LZ4 $DRACUT_COMPRESS_LZOP $DRACUT_COMPRESS_ZSTD $DRACUT_COMPRESS_LZMA $DRACUT_COMPRESS_XZ $DRACUT_COMPRESS_LBZIP2 $DRACUT_COMPRESS_BZIP2 $DRACUT_COMPRESS_CAT; do