From bbda12a5acbd30a58ad6b3eb4e1313045f402646 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:37 +0200 Subject: [PATCH] kdump-lib: make is_zstd_command_available more generic There is value to use the function in other places as well. For example it can be used to check whether optional dependencies, like grubby, are installed. Thus make it more generic so it can be reused in later commits. Signed-off-by: Philipp Rudo Reviewed-by: Pingfan Liu --- kdump-lib.sh | 4 ++-- mkdumprd | 2 +- mkfadumprd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index 634bd22..d314157 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -48,9 +48,9 @@ is_squash_available() done } -is_zstd_command_available() +has_command() { - [[ -x "$(command -v zstd)" ]] + [[ -x $(command -v "$1") ]] } dracut_have_option() diff --git a/mkdumprd b/mkdumprd index f93874d..4feac28 100644 --- a/mkdumprd +++ b/mkdumprd @@ -443,7 +443,7 @@ handle_default_dump_target if ! have_compression_in_dracut_args; then if is_squash_available && dracut_have_option "--squash-compressor"; then add_dracut_arg "--squash-compressor" "zstd" - elif is_zstd_command_available; then + elif has_command zstd; then add_dracut_arg "--compress" "zstd" fi fi diff --git a/mkfadumprd b/mkfadumprd index 719e150..dd6840f 100755 --- a/mkfadumprd +++ b/mkfadumprd @@ -64,7 +64,7 @@ _dracut_isolate_args=( # Use zstd compression method, if available if ! have_compression_in_dracut_args; then - if is_zstd_command_available; then + if has_command zstd; then _dracut_isolate_args+=(--compress zstd) fi fi