Re: [RESEND RESEND RESEND PATCH] templates: introduce GRUB_TOP_LEVEL_* vars
Hi Oskari, On Fri, Sep 30, 2022 at 01:53:59AM -0500, Oskari Pirhonen wrote: > > I'm not too familiar with what end-users might want. If we want to make > > this more universal, we could either do GRUB_TOP_LEVEL_KERNEL and have > > that shared amongst all of the 10_* files or we could have multiple > > variables, e.g. GRUB_TOP_LEVEL_LINUX, GRUB_TOP_LEVEL_BSD, etc. > > > > A single GRUB_TOP_LEVEL or something is what I was thinking. I'm not > familiar with Xen, but based on your original patch, it may warrant its > own. I'm not familiar with Xen either. My understanding is that there can be parallel top-level entries so it deserves its own variable. > > > - What about for os-prober? My understanding is that it creates its own > > > top level entries as well. > > > > The same thing could work with os-prober, although it wouldn't be a > > cut-and-paste. > > > > os-prober would probably have its own GRUB_TOP_LEVEL_OS_PROBER or > something as well. Sounds good! > > I'm open to all ideas here and I can cook up the patches. The thing is > > that I'm not sure what the project's conventions are regarding > > too-granular/not-granular-enough configurations so some advice here > > would be very much appreciated! > > > > Generating a config for multiple OS's would use os-prober, so a single > "main" variable for top level entries would be simpler and should be > enough IMO. Thanks for the feedback! Patch coming soon. -Denton ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [RESEND RESEND RESEND PATCH] templates: introduce GRUB_TOP_LEVEL_* vars
On Thu, Sep 29, 2022 at 03:23:07 -0700, Denton Liu wrote: > Thanks for the response, Oskari! > > On Thu, Sep 29, 2022 at 01:08:03AM -0500, Oskari Pirhonen wrote: > > On Tue, Sep 27, 2022 at 05:30:45 -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_LINUX and GRUB_TOP_LEVEL_XEN variables to > > > allow users to specify the top-level entry. > > > > > > > A couple questions: > > > > - If all you're looking for is /boot/vmlinuz-linux to be booted, is > > setting GRUB_DEFAULT in /etc/default/grub "good enough" for your use > > case? > > I think it is "good enough" for what I need but it feels a little bit > weird that grub doesn't give the user any choice as to what the > top-level kernel is. > Perhaps no one has felt the need up until now ;) > > - Is it possible to make this solution more universal? Maybe BSD users > > would like to set their top level entry. > > I'm not too familiar with what end-users might want. If we want to make > this more universal, we could either do GRUB_TOP_LEVEL_KERNEL and have > that shared amongst all of the 10_* files or we could have multiple > variables, e.g. GRUB_TOP_LEVEL_LINUX, GRUB_TOP_LEVEL_BSD, etc. > A single GRUB_TOP_LEVEL or something is what I was thinking. I'm not familiar with Xen, but based on your original patch, it may warrant its own. > > - What about for os-prober? My understanding is that it creates its own > > top level entries as well. > > The same thing could work with os-prober, although it wouldn't be a > cut-and-paste. > os-prober would probably have its own GRUB_TOP_LEVEL_OS_PROBER or something as well. > I'm open to all ideas here and I can cook up the patches. The thing is > that I'm not sure what the project's conventions are regarding > too-granular/not-granular-enough configurations so some advice here > would be very much appreciated! > Generating a config for multiple OS's would use os-prober, so a single "main" variable for top level entries would be simpler and should be enough IMO. - Oskari signature.asc Description: PGP signature ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [RESEND RESEND RESEND PATCH] templates: introduce GRUB_TOP_LEVEL_* vars
Thanks for the response, Oskari! On Thu, Sep 29, 2022 at 01:08:03AM -0500, Oskari Pirhonen wrote: > On Tue, Sep 27, 2022 at 05:30:45 -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_LINUX and GRUB_TOP_LEVEL_XEN variables to > > allow users to specify the top-level entry. > > > > A couple questions: > > - If all you're looking for is /boot/vmlinuz-linux to be booted, is > setting GRUB_DEFAULT in /etc/default/grub "good enough" for your use > case? I think it is "good enough" for what I need but it feels a little bit weird that grub doesn't give the user any choice as to what the top-level kernel is. > - Is it possible to make this solution more universal? Maybe BSD users > would like to set their top level entry. I'm not too familiar with what end-users might want. If we want to make this more universal, we could either do GRUB_TOP_LEVEL_KERNEL and have that shared amongst all of the 10_* files or we could have multiple variables, e.g. GRUB_TOP_LEVEL_LINUX, GRUB_TOP_LEVEL_BSD, etc. > - What about for os-prober? My understanding is that it creates its own > top level entries as well. The same thing could work with os-prober, although it wouldn't be a cut-and-paste. I'm open to all ideas here and I can cook up the patches. The thing is that I'm not sure what the project's conventions are regarding too-granular/not-granular-enough configurations so some advice here would be very much appreciated! -Denton ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [RESEND RESEND RESEND PATCH] templates: introduce GRUB_TOP_LEVEL_* vars
On Tue, Sep 27, 2022 at 05:30:45 -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_LINUX and GRUB_TOP_LEVEL_XEN variables to > allow users to specify the top-level entry. > A couple questions: - If all you're looking for is /boot/vmlinuz-linux to be booted, is setting GRUB_DEFAULT in /etc/default/grub "good enough" for your use case? - Is it possible to make this solution more universal? Maybe BSD users would like to set their top level entry. - What about for os-prober? My understanding is that it creates its own top level entries as well. Note with the 1st question: I'm not saying GRUB_TOP_LEVEL_* is a bad idea. I'm just curious. - Oskari signature.asc Description: PGP signature ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[RESEND RESEND RESEND PATCH] 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`. 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_LINUX and GRUB_TOP_LEVEL_XEN variables to allow users to specify the top-level entry. Signed-off-by: Denton Liu --- docs/grub.texi | 5 + util/grub-mkconfig.in | 2 ++ util/grub-mkconfig_lib.in | 21 + util/grub.d/10_linux.in | 4 util/grub.d/20_linux_xen.in | 7 +++ 5 files changed, 39 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 107f66ebc..54bd32882 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1444,6 +1444,11 @@ for all respectively normal entries. The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. +@item GRUB_TOP_LEVEL_LINUX +@item GRUB_TOP_LEVEL_XEN +If this option is provided, the given image file will be made the top-level +entry if the image file is found in the scan. + @item GRUB_EARLY_INITRD_LINUX_CUSTOM @itemx GRUB_EARLY_INITRD_LINUX_STOCK List of space-separated early initrd images to be loaded from @samp{/boot}. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 62335d027..f7ad160b4 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -233,6 +233,8 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_TOP_LEVEL_LINUX \ + GRUB_TOP_LEVEL_XEN \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 634bc8a50..5be49a07c 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -218,6 +218,27 @@ version_sort () esac } +grub_move_entry_to_front () +{ + entry="$1" + shift + + entry_found=false + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then + entry_found=true +fi + done + + if [ "x$entry_found" = xtrue ]; then +echo "$entry" + fi + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then continue; fi +echo "$i" + done +} + # One layer of quotation is eaten by "" and the second by sed; so this turns # ' into \'. grub_quote () { diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c6a1ec935..05e01fc85 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -202,6 +202,10 @@ submenu_indentation="" reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_list}) +fi + is_top_level=true for linux in ${reverse_sorted_list}; do gettext_printf "Found linux image: %s\n" "$linux" >&2 diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 626aed40c..c32bb979f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -245,6 +245,13 @@ submenu_indentation="" reverse_sorted_xen_list=$(echo ${xen_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') reverse_sorted_linux_list=$(echo ${linux_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_XEN" != x ]; then + reverse_sorted_xen_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_XEN" ${reverse_sorted_xen_list}) +fi +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_linux_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_linux_list}) +fi + is_top_level=true for current_xen in ${reverse_sorted_xen_list}; do -- 2.37.3 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[RESEND RESEND PATCH] 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`. 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_LINUX and GRUB_TOP_LEVEL_XEN variables to allow users to specify the top-level entry. Signed-off-by: Denton Liu --- docs/grub.texi | 5 + util/grub-mkconfig.in | 2 ++ util/grub-mkconfig_lib.in | 21 + util/grub.d/10_linux.in | 4 util/grub.d/20_linux_xen.in | 7 +++ 5 files changed, 39 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 107f66ebc..54bd32882 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1444,6 +1444,11 @@ for all respectively normal entries. The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. +@item GRUB_TOP_LEVEL_LINUX +@item GRUB_TOP_LEVEL_XEN +If this option is provided, the given image file will be made the top-level +entry if the image file is found in the scan. + @item GRUB_EARLY_INITRD_LINUX_CUSTOM @itemx GRUB_EARLY_INITRD_LINUX_STOCK List of space-separated early initrd images to be loaded from @samp{/boot}. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 62335d027..f7ad160b4 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -233,6 +233,8 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_TOP_LEVEL_LINUX \ + GRUB_TOP_LEVEL_XEN \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 634bc8a50..5be49a07c 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -218,6 +218,27 @@ version_sort () esac } +grub_move_entry_to_front () +{ + entry="$1" + shift + + entry_found=false + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then + entry_found=true +fi + done + + if [ "x$entry_found" = xtrue ]; then +echo "$entry" + fi + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then continue; fi +echo "$i" + done +} + # One layer of quotation is eaten by "" and the second by sed; so this turns # ' into \'. grub_quote () { diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c6a1ec935..05e01fc85 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -202,6 +202,10 @@ submenu_indentation="" reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_list}) +fi + is_top_level=true for linux in ${reverse_sorted_list}; do gettext_printf "Found linux image: %s\n" "$linux" >&2 diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 626aed40c..c32bb979f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -245,6 +245,13 @@ submenu_indentation="" reverse_sorted_xen_list=$(echo ${xen_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') reverse_sorted_linux_list=$(echo ${linux_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_XEN" != x ]; then + reverse_sorted_xen_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_XEN" ${reverse_sorted_xen_list}) +fi +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_linux_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_linux_list}) +fi + is_top_level=true for current_xen in ${reverse_sorted_xen_list}; do -- 2.37.3 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[RESEND PATCH] 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`. 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_LINUX and GRUB_TOP_LEVEL_XEN variables to allow users to specify the top-level entry. Signed-off-by: Denton Liu --- docs/grub.texi | 5 + util/grub-mkconfig.in | 2 ++ util/grub-mkconfig_lib.in | 21 + util/grub.d/10_linux.in | 4 util/grub.d/20_linux_xen.in | 7 +++ 5 files changed, 39 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 107f66ebc..54bd32882 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1444,6 +1444,11 @@ for all respectively normal entries. The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. +@item GRUB_TOP_LEVEL_LINUX +@item GRUB_TOP_LEVEL_XEN +If this option is provided, the given image file will be made the top-level +entry if the image file is found in the scan. + @item GRUB_EARLY_INITRD_LINUX_CUSTOM @itemx GRUB_EARLY_INITRD_LINUX_STOCK List of space-separated early initrd images to be loaded from @samp{/boot}. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 62335d027..f7ad160b4 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -233,6 +233,8 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_TOP_LEVEL_LINUX \ + GRUB_TOP_LEVEL_XEN \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 634bc8a50..5be49a07c 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -218,6 +218,27 @@ version_sort () esac } +grub_move_entry_to_front () +{ + entry="$1" + shift + + entry_found=false + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then + entry_found=true +fi + done + + if [ "x$entry_found" = xtrue ]; then +echo "$entry" + fi + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then continue; fi +echo "$i" + done +} + # One layer of quotation is eaten by "" and the second by sed; so this turns # ' into \'. grub_quote () { diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c6a1ec935..05e01fc85 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -202,6 +202,10 @@ submenu_indentation="" reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_list}) +fi + is_top_level=true for linux in ${reverse_sorted_list}; do gettext_printf "Found linux image: %s\n" "$linux" >&2 diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 626aed40c..c32bb979f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -245,6 +245,13 @@ submenu_indentation="" reverse_sorted_xen_list=$(echo ${xen_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') reverse_sorted_linux_list=$(echo ${linux_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_XEN" != x ]; then + reverse_sorted_xen_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_XEN" ${reverse_sorted_xen_list}) +fi +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_linux_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_linux_list}) +fi + is_top_level=true for current_xen in ${reverse_sorted_xen_list}; do -- 2.37.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] 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`. 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_LINUX and GRUB_TOP_LEVEL_XEN variables to allow users to specify the top-level entry. Signed-off-by: Denton Liu --- docs/grub.texi | 5 + util/grub-mkconfig.in | 2 ++ util/grub-mkconfig_lib.in | 21 + util/grub.d/10_linux.in | 4 util/grub.d/20_linux_xen.in | 7 +++ 5 files changed, 39 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 107f66ebc..54bd32882 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1444,6 +1444,11 @@ for all respectively normal entries. The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. +@item GRUB_TOP_LEVEL_LINUX +@item GRUB_TOP_LEVEL_XEN +If this option is provided, the given image file will be made the top-level +entry if the image file is found in the scan. + @item GRUB_EARLY_INITRD_LINUX_CUSTOM @itemx GRUB_EARLY_INITRD_LINUX_STOCK List of space-separated early initrd images to be loaded from @samp{/boot}. diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 62335d027..f7ad160b4 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -233,6 +233,8 @@ export GRUB_DEFAULT \ GRUB_CMDLINE_NETBSD \ GRUB_CMDLINE_NETBSD_DEFAULT \ GRUB_CMDLINE_GNUMACH \ + GRUB_TOP_LEVEL_LINUX \ + GRUB_TOP_LEVEL_XEN \ GRUB_EARLY_INITRD_LINUX_CUSTOM \ GRUB_EARLY_INITRD_LINUX_STOCK \ GRUB_TERMINAL_INPUT \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 634bc8a50..5be49a07c 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -218,6 +218,27 @@ version_sort () esac } +grub_move_entry_to_front () +{ + entry="$1" + shift + + entry_found=false + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then + entry_found=true +fi + done + + if [ "x$entry_found" = xtrue ]; then +echo "$entry" + fi + for i in "$@"; do +if [ "x$i" = "x$entry" ]; then continue; fi +echo "$i" + done +} + # One layer of quotation is eaten by "" and the second by sed; so this turns # ' into \'. grub_quote () { diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c6a1ec935..05e01fc85 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -202,6 +202,10 @@ submenu_indentation="" reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_list}) +fi + is_top_level=true for linux in ${reverse_sorted_list}; do gettext_printf "Found linux image: %s\n" "$linux" >&2 diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 626aed40c..c32bb979f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -245,6 +245,13 @@ submenu_indentation="" reverse_sorted_xen_list=$(echo ${xen_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') reverse_sorted_linux_list=$(echo ${linux_list} | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') +if [ "x$GRUB_TOP_LEVEL_XEN" != x ]; then + reverse_sorted_xen_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_XEN" ${reverse_sorted_xen_list}) +fi +if [ "x$GRUB_TOP_LEVEL_LINUX" != x ]; then + reverse_sorted_linux_list=$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_LINUX" ${reverse_sorted_linux_list}) +fi + is_top_level=true for current_xen in ${reverse_sorted_xen_list}; do -- 2.37.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel