This patch will make zstd as recommended instead of required for
kexec-tools. If zstd command/package is unavaliable, it can failback to invoke
gzip when making kdump initramfs.
Fixes: 0311f6e ("Set zstd as the default compression method for kdump initrd")
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
kdump-lib.sh | 5 +++++
kexec-tools.spec | 2 +-
mkdumprd | 4 +++-
mkfadumprd | 11 +++++++----
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 6415dda..2ea51be 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -31,6 +31,11 @@ is_squash_available()
done
}
+is_zstd_command_available()
+{
+ [[ -x "$(command -v zstd)" ]]
+}
+
perror_exit()
{
derror "$@"
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 90f9355..367929a 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -71,7 +71,7 @@ Requires: dracut >= 050
Requires: dracut-network >= 050
Requires: dracut-squash >= 050
Requires: ethtool
-Requires: zstd
+Recommends: zstd
Recommends: grubby
BuildRequires: make
BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex
lzo-devel snappy-devel libzstd-devel
diff --git a/mkdumprd b/mkdumprd
index 9c26ecc..70aeb4c 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -432,7 +432,9 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target
if ! have_compression_in_dracut_args; then
- add_dracut_arg "--compress" "zstd"
+ if is_squash_available || is_zstd_command_available; then
+ add_dracut_arg "--compress" "zstd"
+ fi
fi
if [[ -n $extra_modules ]]; then
diff --git a/mkfadumprd b/mkfadumprd
index 16fdacc..251d4c4 100644
--- a/mkfadumprd
+++ b/mkfadumprd
@@ -60,10 +60,13 @@ _dracut_isolate_args=(
if is_squash_available; then
_dracut_isolate_args+=(--add squash)
-fi
-
-if ! have_compression_in_dracut_args; then
- _dracut_isolate_args+=(--compress zstd)
+ if ! have_compression_in_dracut_args; then
+ _dracut_isolate_args+=(--compress zstd)
+ fi
+else
+ if ! have_compression_in_dracut_args && is_zstd_command_available; then
+ _dracut_isolate_args+=(--compress zstd)
+ fi
fi
if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@"
"$TARGET_INITRD"; then
--
2.33.1
Show replies by date