Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oeq0B-0006tS-Km for mharc-grub-devel@gnu.org; Sat, 01 Oct 2022 23:50:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oeq07-0006tE-ET for grub-devel@gnu.org; Sat, 01 Oct 2022 23:50:47 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:56069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oeq05-0002mC-Ch for grub-devel@gnu.org; Sat, 01 Oct 2022 23:50:47 -0400 Received: by mail-wm1-x333.google.com with SMTP id t4so5101522wmj.5 for ; Sat, 01 Oct 2022 20:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date; bh=b+NS1XMOLTZOWZ4sY/yqWPZ7BIlO4vQCHp0ykrZ/Ph4=; b=Lsiqdpr1AWLsYv7Hn14SeJtAfx6nhftfVssT7sDcSJ84+nr40szujGqWKm4aJePuFG 7QKwEvpqJZiHUxlv/0mGW6rzaVz9feYsZ2OC+LzvGTuGrvrYNUGHyHB0YX/NfWD3RWZJ zlapPTNVXtiPFeMps0ZxEh0/zX/8973O5PDpg57jT/eA1v17MfIXGFKdp4erIzI4Qe/w +Pze6daUWMsWHq4Zv6x7MmxgCEO0iWjo4AtTOCt6EBof/eFsizv2YyPQ/K12ZbMHhBnb exXsihxjqtozWmA2KjUHUt572h2jpO4xRlMQIvImFFJ1WOU38y3SUgMZqALSni8W1o8K GLmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=b+NS1XMOLTZOWZ4sY/yqWPZ7BIlO4vQCHp0ykrZ/Ph4=; b=GLq/htKCO4eQkhBXymskhU77eddVqX9eENLcZ91J1f4jjitebGZxfaXyQxzf0aObrB 5bqoHLXZxjB7xLDCjodGERczCxK8grOnklF0q/NN1OmfqpNRHqtJdluSU5mti65S1Tgd lVLf4y4zchqG2Bhg3AOOKqafbeiC+dwDMZJgIpelMTcSNqJjPplxBpyjUwpgpLjP+5Ic HCLKFgpUn3b8u+tUJx0PcUPIu0/y84XGLwFOTnTTeyWuYEa24rOG6c5HaoWXZRTSfIP9 MO2yrIwTH7BEOyiQyu7ynjd6NZCyXMJQ553YMPIxC0T7IXf/us39DTZQmipIMgGjJQ9Q v80A== X-Gm-Message-State: ACrzQf3ikiAGbEW4SjbiWBh14b2pfkWxi/P/KZFQPuqPfsrpeaBbSs1Z TM3Vzf6lsv6HTXSLUqfKEqT4Ih/ETYg= X-Google-Smtp-Source: AMsMyM7VE2olNdd09gJ+Z4LXvKe1WEuY6vYauffinYrd+ir6t5vXHMX3EDs/noYWCc9GWASqSaM+bw== X-Received: by 2002:a7b:cd14:0:b0:3b4:8680:79a7 with SMTP id f20-20020a7bcd14000000b003b4868079a7mr3122401wmj.28.1664682642586; Sat, 01 Oct 2022 20:50:42 -0700 (PDT) Received: from dj3ntoo (171.sub-72-110-15.myvzw.com. [72.110.15.171]) by smtp.gmail.com with ESMTPSA id fc15-20020a05600c524f00b003a319b67f64sm16304883wmb.0.2022.10.01.20.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 20:50:41 -0700 (PDT) Date: Sat, 1 Oct 2022 22:50:37 -0500 From: Oskari Pirhonen To: grub-devel@gnu.org Cc: Daniel Kiper , Denton Liu Subject: Re: [PATCH v2] templates: introduce GRUB_TOP_LEVEL_* vars Message-ID: Mail-Followup-To: grub-devel@gnu.org, Daniel Kiper , Denton Liu References: <20220821102421.169229-1-liu.denton@gmail.com> <20220930111111.67328-1-liu.denton@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QJYkH7uAo7e44Bc2" Content-Disposition: inline In-Reply-To: <20220930111111.67328-1-liu.denton@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=xxc3ncoredxx@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Oct 2022 03:50:47 -0000 --QJYkH7uAo7e44Bc2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 30, 2022 at 04:11:11 -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. >=20 > 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. >=20 > The only file that was tested is 10_linux. I do not have access to any > of the other images or systems so they remain untested. >=20 Blurbs like this should be placed below the "---" line so they don't show up in commit messages. A brief changelog summarizing the differences between patch versions is also nice (and belongs under the "---" as well) so readers don't have to hunt for the previous versions and analyze them to get an idea of the evolution of the patch. Bullet points is generally enough for this. > Signed-off-by: Denton Liu > --- (Example changelog) v3: - changes between v2 and v3 - ... v2: - use a more generic GRUB_TOP_LEVEL - ... > docs/grub.texi | 6 ++++++ > util/grub-mkconfig.in | 3 +++ > util/grub-mkconfig_lib.in | 21 +++++++++++++++++++++ > util/grub.d/10_hurd.in | 4 ++++ > util/grub.d/10_kfreebsd.in | 4 ++++ > util/grub.d/10_linux.in | 4 ++++ > util/grub.d/10_netbsd.in | 10 +++++++++- > util/grub.d/20_linux_xen.in | 7 +++++++ > util/grub.d/30_os-prober.in | 4 ++++ > 9 files changed, 62 insertions(+), 1 deletion(-) >=20 > diff --git a/docs/grub.texi b/docs/grub.texi > index 107f66ebc..16a445178 100644 > --- a/docs/grub.texi > +++ b/docs/grub.texi > @@ -1444,6 +1444,12 @@ for all respectively normal entries. > The values of these options replace the values of @samp{GRUB_CMDLINE_LIN= UX} > and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. > =20 > +@item GRUB_TOP_LEVEL > +@item GRUB_TOP_LEVEL_XEN > +@item GRUB_TOP_LEVEL_OS_PROBER > +If this option is provided, the given image file will be made the top-le= vel > +entry if the image file is found in the scan. I think explicitly mentioning that it's a _kernel_ image would be good. That way no one can complain when their cute_cat.png wasn't made into a top level entry. Also worth noting that you need to specify the path to the kernel, not just the file name. > + > @item GRUB_EARLY_INITRD_LINUX_CUSTOM > @itemx GRUB_EARLY_INITRD_LINUX_STOCK > List of space-separated early initrd images to be loaded from @samp{/boo= t}. > diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in > index 62335d027..32c480dae 100644 > --- a/util/grub-mkconfig.in > +++ b/util/grub-mkconfig.in > @@ -233,6 +233,9 @@ export GRUB_DEFAULT \ > GRUB_CMDLINE_NETBSD \ > GRUB_CMDLINE_NETBSD_DEFAULT \ > GRUB_CMDLINE_GNUMACH \ > + GRUB_TOP_LEVEL \ > + GRUB_TOP_LEVEL_XEN \ > + GRUB_TOP_LEVEL_OS_PROBER \ > 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 > } > =20 > +grub_move_entry_to_front () I think a better name would be just `grub_move_to_front`. It makes it more clear that this function can be used for more than just menu entries in case someone wants to use it for something else in the future. A short comment describing the arguments would be helpful for that too. Mention of this function is completely missing from the commit message. > +{ > + entry=3D"$1" > + shift > + > + entry_found=3Dfalse > + for i in "$@"; do > + if [ "x$i" =3D "x$entry" ]; then > + entry_found=3Dtrue > + fi > + done > + > + if [ "x$entry_found" =3D xtrue ]; then > + echo "$entry" > + fi > + for i in "$@"; do > + if [ "x$i" =3D "x$entry" ]; then continue; fi > + echo "$i" > + done > +} > + > # One layer of quotation is eaten by "" and the second by sed; so this t= urns > # ' into \'. > grub_quote () { > diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in > index 4294bbe4c..0ae5a3927 100644 > --- a/util/grub.d/10_hurd.in > +++ b/util/grub.d/10_hurd.in > @@ -205,6 +205,10 @@ submenu_indentation=3D"" > =20 > reverse_sorted_kernels=3D$(echo ${kernels} | tr ' ' '\n' | sed -e 's/\.o= ld$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') > =20 > +if [ "x$GRUB_TOP_LEVEL" !=3D x ]; then > + reverse_sorted_kernels=3D$(grub_move_entry_to_front "$GRUB_TOP_LEVEL" = ${reverse_sorted_kernels}) > +fi > + > is_top_level=3Dtrue > =20 > for kernel in ${reverse_sorted_kernels}; do > diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in > index 0a67decaa..506b2df66 100644 > --- a/util/grub.d/10_kfreebsd.in > +++ b/util/grub.d/10_kfreebsd.in > @@ -164,6 +164,10 @@ submenu_indentation=3D"" > =20 > reverse_sorted_list=3D$(echo ${list} | tr ' ' '\n' | sed -e 's/\.old$/ 1= /; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') > =20 > +if [ "x$GRUB_TOP_LEVEL" !=3D x ]; then > + reverse_sorted_list=3D$(grub_move_entry_to_front "$GRUB_TOP_LEVEL" ${r= everse_sorted_list}) > +fi > + > is_top_level=3Dtrue > =20 > for kfreebsd in ${reverse_sorted_list}; do > diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in > index c6a1ec935..a479c16af 100644 > --- a/util/grub.d/10_linux.in > +++ b/util/grub.d/10_linux.in > @@ -202,6 +202,10 @@ submenu_indentation=3D"" > =20 > reverse_sorted_list=3D$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/;= / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//') > =20 > +if [ "x$GRUB_TOP_LEVEL" !=3D x ]; then > + reverse_sorted_list=3D$(grub_move_entry_to_front "$GRUB_TOP_LEVEL" ${r= everse_sorted_list}) > +fi > + > is_top_level=3Dtrue > for linux in ${reverse_sorted_list}; do > gettext_printf "Found linux image: %s\n" "$linux" >&2 > diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in > index dc0cd1b17..4eae58e82 100644 > --- a/util/grub.d/10_netbsd.in > +++ b/util/grub.d/10_netbsd.in > @@ -147,10 +147,18 @@ pattern=3D"^ELF[^,]*executable.*statically linked" > submenu_indentation=3D"" > =20 > is_top_level=3Dtrue > -for k in /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do > +grub_top_level_found=3Dfalse > +for k in "$GRUB_TOP_LEVEL" /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do > if ! grub_file_is_not_garbage "$k" ; then > continue > fi > + if [ "x$GRUB_TOP_LEVEL" =3D "x$k" ] ; then > + if [ "x$grub_top_level_found" =3D xfalse ] ; then > + grub_top_level_found=3Dtrue > + else > + continue > + fi > + fi > if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; = then > continue > fi > 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=3D"" > reverse_sorted_xen_list=3D$(echo ${xen_list} | tr ' ' '\n' | sed -e 's/\= =2Eold$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$= //') > reverse_sorted_linux_list=3D$(echo ${linux_list} | tr ' ' '\n' | sed -e = 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ = 2$//') > =20 > +if [ "x$GRUB_TOP_LEVEL_XEN" !=3D x ]; then > + reverse_sorted_xen_list=3D$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_= XEN" ${reverse_sorted_xen_list}) > +fi > +if [ "x$GRUB_TOP_LEVEL_LINUX" !=3D x ]; then > + reverse_sorted_linux_list=3D$(grub_move_entry_to_front "$GRUB_TOP_LEVE= L_LINUX" ${reverse_sorted_linux_list}) > +fi Here you've still got GRUB_TOP_LEVEL_LINUX but it's not documented above. Is it meant to have its own, or did you just forget to replace it with GRUB_TOP_LEVEL when going through them? > + > is_top_level=3Dtrue > =20 > for current_xen in ${reverse_sorted_xen_list}; do > diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in > index daa603778..9b2a96bd0 100644 > --- a/util/grub.d/30_os-prober.in > +++ b/util/grub.d/30_os-prober.in > @@ -113,6 +113,10 @@ EOF > =20 > used_osprober_linux_ids=3D > =20 > +if [ "x$GRUB_TOP_LEVEL_OS_PROBER" !=3D x ]; then > + OSPROBED=3D$(grub_move_entry_to_front "$GRUB_TOP_LEVEL_OS_PROBER" ${OS= PROBED}) > +fi > + > for OS in ${OSPROBED} ; do > DEVICE=3D"`echo ${OS} | cut -d ':' -f 1`" > LONGNAME=3D"`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" > --=20 > 2.37.3 >=20 - Oskari --QJYkH7uAo7e44Bc2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQfOU+JeXjo4uxN6vCp8he9GGIfEQUCYzkKiQAKCRCp8he9GGIf EQllAP97gn3aQCX4+JQygMNsNixs5m/eNThMsSvfxdEZJdaeNQD/fb5ruY0OX8kL QXLgni7gLEaQ8/+ySEgA3puU3pG7yQM= =Mp6j -----END PGP SIGNATURE----- --QJYkH7uAo7e44Bc2--