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 <prudo(a)redhat.com>
Reviewed-by: Pingfan Liu <piliu(a)redhat.com>
---
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 f79c13a..42844c8 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
--
2.40.0