Skip to content

Commit

Permalink
fix(dracut.sh): check availability of configured compression
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mwilck authored and johannbg committed Nov 26, 2021
1 parent 06d47de commit bdac657
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdac657

Please sign in to comment.