On Mon, Jun 12, 2023 at 10:37 PM Philipp Rudo <prudo(a)redhat.com> wrote:
Hi Pingfan,
as mentioned earlier there are several ShellCheck findings for
SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match
as patterns.
https://www.shellcheck.net/wiki/SC2295
I should have run it before sending you the code. Sorry for that.
Oh, my fault. I ran shellcheck on [v3 1/3], but forgot to run the
check against [v4 2/4] before sending out.
Appreciate for your help.
Thanks,
Pingfan
Thanks
Philipp
On Mon, 29 May 2023 18:02:43 +0800
Pingfan Liu <piliu(a)redhat.com> wrote:
> kdump_get_arch_recommend_crashkernel() expects the kernel version info,
> while _update_kernel() provides the absolute path, which contains the
> kernel version info.
>
> This patch introduce a dedicated function parse_kver_from_path() to
> extract the kernel info from the path
>
> Credit to Philipp, who contributes the original code.
>
> Signed-off-by: Pingfan Liu <piliu(a)redhat.com>
> ---
> kdump-lib.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 992e8d9..2dccc69 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -526,6 +526,49 @@ prepare_kdump_kernel()
> echo "$kdump_kernel"
> }
>
> +_is_valid_kver()
> +{
> + [[ -f /usr/lib/modules/$1/modules.dep ]]
> +}
> +
> +# This function is introduced since 64k variant may be installed on 4k or vice
versa
> +# $1 the kernel path name.
> +parse_kver_from_path()
> +{
> + local _img _kver
> +
> + [[ -z "$1" ]] && return
> +
> + _img=$1
> + BLS_ENTRY_TOKEN=$(</etc/machine-id)
> +
> + # Fedora standard installation, i.e. $BOOT/vmlinuz-<version>
> + _kver=${_img##*/vmlinuz-}
> + _kver=${_kver%$KDUMP_IMG_EXT}
> + if _is_valid_kver "$_kver"; then
> + echo "$_kver"
> + return
> + fi
> +
> + # BLS recommended image names, i.e. $BOOT/<token>/<version>/linux
> + _kver=${_img##*/$BLS_ENTRY_TOKEN/}
> + _kver=${_kver%%/*}
> + if _is_valid_kver "$_kver"; then
> + echo "$_kver"
> + return
> + fi
> +
> + # Fedora UKI installation, i.e.
$BOOT/efi/EFI/Linux/<token>-<version>.efi
> + _kver=${_img##*/$BLS_ENTRY_TOKEN-}
> + _kver=${_kver%.efi}
> + if _is_valid_kver "$_kver"; then
> + echo "$_kver"
> + return
> + fi
> +
> + ddebug "Could not parse version from $_img"
> +}
> +
> _get_kdump_kernel_version()
> {
> local _version _version_nondebug