]> git.ipfire.org Git - thirdparty/grub.git/commit
templates: Introduce GRUB_TOP_LEVEL_* vars
authorDenton Liu <liu.denton@gmail.com>
Mon, 24 Oct 2022 10:46:42 +0000 (03:46 -0700)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 14 Nov 2022 15:54:12 +0000 (16:54 +0100)
commit62037e01b296fe772c1724343cf75b75ea52e220
tree0372ba4cf86046548102aebf2cf5035be3a4d55c
parenta85714545fe57a86d14ee231a4cd312158101d43
templates: Introduce GRUB_TOP_LEVEL_* vars

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", meaning
the LTS kernel becomes the top-level entry. However, a user may wish to
use the regular kernel as the top-level default with the LTS only
existing as a backup.

This need can be seen in Arch Linux's AUR with two user-submitted
packages[0][1] providing an update hook which patches /etc/grub.d/10_linux
to move the desired kernel to the top-level. This patch serves to solve
this in a more generic way.

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.

[0]: https://aur.archlinux.org/packages/grub-linux-default-hook
[1]: https://aur.archlinux.org/packages/grub-linux-rt-default-hook

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Reviewed-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
docs/grub.texi
util/grub-mkconfig.in
util/grub-mkconfig_lib.in
util/grub.d/10_hurd.in
util/grub.d/10_kfreebsd.in
util/grub.d/10_linux.in
util/grub.d/10_netbsd.in
util/grub.d/20_linux_xen.in
util/grub.d/30_os-prober.in