grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3] templates: introduce GRUB_TOP_LEVEL_* vars


From: Daniel Kiper
Subject: Re: [PATCH v3] templates: introduce GRUB_TOP_LEVEL_* vars
Date: Fri, 14 Oct 2022 12:11:28 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Oct 05, 2022 at 02:22:38AM -0700, Denton Liu wrote:
> A user may wish to use an image that is not sorted as the "latest"
> version as the top-level entry. For example, in Arch Linux, if a user
> has the LTS and regular kernels installed, `/boot/vmlinuz-linux-lts`
> gets sorted as the "latest" compared to `/boot/vmlinuz-linux`. However,
> a user may wish to use the regular kernel as the default with the LTS
> only existing as a backup.
>
> Introduce the GRUB_TOP_LEVEL, GRUB_TOP_LEVEL_XEN and
> GRUB_TOP_LEVEL_OS_PROBER variables to allow users to specify the
> top-level entry.
>
> Create grub_move_to_front() as a helper function which moves entries to
> the front of a list. This function does the heavy lifting of moving
> the menu entry to the front in each script.
>
> In 10_netbsd, since there isn't an explicit list variable, extract the
> items that are being iterated through into a list so that we can
> optionally apply grub_move_to_front() to the list before the loop.
>
> Signed-off-by: Denton Liu <liu.denton@gmail.com>

I skimmed through the patch and it looks more or less good to me. Just
one nit below...

Please repost the patch by starting new thread instead of replying to
old one and add to CC following addresses: mathieu.desnoyers@efficios.com,
rharwood@redhat.com, samuel.thibault@ens-lyon.org, debian-bsd@lists.debian.org,
xen-devel@lists.xenproject.org.

[...]

> diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
> index 634bc8a50..f4ae41f86 100644
> --- a/util/grub-mkconfig_lib.in
> +++ b/util/grub-mkconfig_lib.in
> @@ -218,6 +218,30 @@ version_sort ()
>     esac
>  }
>
> +# Given an item as the first argument and a list as the subsequent arguments,
> +# returns the list with the first argument moved to the front if it exists in
> +# the list.
> +grub_move_to_front ()
> +{
> +  item="$1"
> +  shift
> +
> +  item_found=false
> +  for i in "$@"; do
> +    if [ "x$i" = "x$item" ]; then
> +      item_found=true
> +    fi
> +  done
> +
> +  if [ "x$item_found" = xtrue ]; then
> +    echo "$item"
> +  fi
> +  for i in "$@"; do
> +    if [ "x$i" = "x$item" ]; then continue; fi

I prefer

if [ "x$i" = "x$item" ]; then
  continue;
fi

Daniel



reply via email to

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