Skip to content

Commit bdac657

Browse files
mwilckjohannbg
authored andcommitted
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.
1 parent 06d47de commit bdac657

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dracut.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,13 @@ if [[ $create_early_cpio == yes ]]; then
23502350
fi
23512351
fi
23522352
2353+
if [[ $compress && $compress != cat ]]; then
2354+
if ! command -v "${compress%% *}" &> /dev/null; then
2355+
derror "dracut: cannot execute compression command '$compress', falling back to default"
2356+
compress=
2357+
fi
2358+
fi
2359+
23532360
if ! [[ $compress ]]; then
23542361
# check all known compressors, if none specified
23552362
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

0 commit comments

Comments
 (0)