grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] util/grub.d/10_linux: Improve initramfs detection


From: Daniel Kiper
Subject: Re: [PATCH] util/grub.d/10_linux: Improve initramfs detection
Date: Thu, 24 Mar 2022 18:11:25 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Mar 16, 2022 at 11:21:51PM -0500, Oskari Pirhonen wrote:
> Prefer using a *.old initramfs for *.old kernels if it exists. Otherwise
> look for an initramfs without the suffix.
>
> Also add detection for initramfs of the form *.img.old. For example,
> Gentoo's sys-kernel/genkernel installs it as initramfs-*.img and moves
> any existing one to initramfs-*.img.old.
>
> Signed-off-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
> ---
>  util/grub.d/10_linux.in | 41 ++++++++++++++++++++++++++++-------------

You should update the util/grub.d/20_linux_xen.in too.

>  1 file changed, 28 insertions(+), 13 deletions(-)
>
> diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> index ca068038e..4a666c317 100644
> --- a/util/grub.d/10_linux.in
> +++ b/util/grub.d/10_linux.in
> @@ -215,19 +215,34 @@ while [ "x$list" != "x" ] ; do
>    done
>
>    initrd_real=
> -  for i in "initrd.img-${version}" "initrd-${version}.img" 
> "initrd-${version}.gz" \
> -        "initrd-${version}" "initramfs-${version}.img" \
> -        "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
> -        "initrd-${alt_version}" "initramfs-${alt_version}.img" \
> -        "initramfs-genkernel-${version}" \
> -        "initramfs-genkernel-${alt_version}" \
> -        "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
> -        "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
> -    if test -e "${dirname}/${i}" ; then
> -      initrd_real="${i}"
> -      break
> -    fi
> -  done
> +  # Prefer to match *.old kernel with *.old initramfs if it exists
> +  if [ "${alt_version}" != "${version}" ]; then
> +    for i in "initrd.img-${version}" "initrd-${version}.img" \
> +          "initrd-${alt_version}.img.old" "initrd-${version}.gz" \
> +          "initrd-${alt_version}.gz.old" "initrd-${version}" \

Why do you change order of images in comparison to the original above?
I think it should be more or less *${version} *${alt_version}.img.old
*${alt_version}.gz.old *${alt_version} and so on...

> +          "initramfs-${version}.img" "initramfs-${alt_version}.img.old" \
> +          "initramfs-genkernel-${version}" \
> +          "initramfs-genkernel-${GENKERNEL_ARCH}-${version}"; do
> +      if test -e "${dirname}/${i}" ; then
> +        initrd_real="${i}"
> +        break
> +      fi
> +    done
> +  fi
> +
> +  # alt_version == version or *.old initramfs not found
> +  # use alt_version to handle both cases at once
> +  if [ -z "${initrd_real}" ]; then
> +    for i in "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
> +          "initrd-${alt_version}.gz" "initrd-${alt_version}" \
> +          "initramfs-${alt_version}.img" 
> "initramfs-genkernel-${alt_version}" \
> +          "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
> +      if test -e "${dirname}/${i}" ; then
> +        initrd_real="${i}"
> +        break
> +      fi
> +    done
> +  fi

Daniel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]