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 <prudo@redhat.com>
Reviewed-by: Pingfan Liu <piliu@redhat.com>
This commit is contained in:
Philipp Rudo 2023-09-06 10:49:37 +02:00 committed by Coiby Xu
parent 026edc2b59
commit bbda12a5ac
3 changed files with 4 additions and 4 deletions

View File

@ -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()

View File

@ -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

View File

@ -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