Skip to content

Commit 475497b

Browse files
mwilckjohannbg
authored andcommitted
fix(dracut.sh): check kernel zstd support early
Rather than checking late and falling back to "cat" if the kernel doesn't support zstd decompression, do this early, and use the fallback code path.
1 parent bdac657 commit 475497b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

dracut.sh

+12-5
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,17 @@ if [[ $create_early_cpio == yes ]]; then
23502350
fi
23512351
fi
23522352
2353+
if check_kernel_config CONFIG_RD_ZSTD; then
2354+
DRACUT_KERNEL_RD_ZSTD=yes
2355+
else
2356+
DRACUT_KERNEL_RD_ZSTD=
2357+
fi
2358+
2359+
if [[ $compress == $DRACUT_COMPRESS_ZSTD* && ! $DRACUT_KERNEL_RD_ZSTD ]]; then
2360+
dwarn "dracut: kernel has no zstd support compiled in."
2361+
compress=
2362+
fi
2363+
23532364
if [[ $compress && $compress != cat ]]; then
23542365
if ! command -v "${compress%% *}" &> /dev/null; then
23552366
derror "dracut: cannot execute compression command '$compress', falling back to default"
@@ -2360,6 +2371,7 @@ fi
23602371
if ! [[ $compress ]]; then
23612372
# check all known compressors, if none specified
23622373
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
2374+
[[ $i != "$DRACUT_COMPRESS_ZSTD" || $DRACUT_KERNEL_RD_ZSTD ]] || continue
23632375
command -v "$i" &> /dev/null || continue
23642376
compress="$i"
23652377
break
@@ -2406,11 +2418,6 @@ case $compress in
24062418
;;
24072419
esac
24082420
2409-
if [[ $compress == $DRACUT_COMPRESS_ZSTD* ]] && ! check_kernel_config CONFIG_RD_ZSTD; then
2410-
dwarn "dracut: kernel has no zstd support compiled in."
2411-
compress="cat"
2412-
fi
2413-
24142421
if [[ -n $enhanced_cpio ]]; then
24152422
if [[ $compress == "cat" ]]; then
24162423
# dracut-cpio appends by default, so any ucode remains

0 commit comments

Comments
 (0)