From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH v3] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items
Date: Thu, 19 May 2022 16:29:57 -0400 (EDT) [thread overview]
Message-ID: <721172156.62842.1652992197038.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <YnRXgHt9ghSd5Q+C@dj3ntoo>
----- On May 5, 2022, at 7:02 PM, Oskari Pirhonen xxc3ncoredxx@gmail.com wrote:
> On Thu, May 05, 2022 at 10:24:56AM -0400, Mathieu Desnoyers wrote:
[...]
>
> Instead of creating a separate function, would it be better to let
> `version_sort()` accept an argument/set of arguments?
>
>> +
>> version_test_numeric ()
>> {
>> version_test_numeric_a="$1"
>> diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
>> index ca068038e..8178318f5 100644
>> --- a/util/grub.d/10_linux.in
>> +++ b/util/grub.d/10_linux.in
>> @@ -195,9 +195,15 @@ title_correction_code=
>> # yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
>> submenu_indentation=""
>>
>> +# Perform a reverse version sort on the entire list.
>> +# Temporarily replace the '.old' suffix by ' 1' and append ' 2' for all
>> +# other files to order the '.old' files after their non-old counterpart
>> +# in reverse-sorted order.
>> +
>> +reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/' -e '/
>> 1$/! s/$/ 2/' | version_reverse_sort | sed -e 's/ 1$/.old/' -e 's/ 2$//')
>
> That way you could do something like this instead:
>
> ... | version_sort -r | ...
>
> - Oskari
>
Done (for next version of patch),
Thanks!
Mathieu
>> +
>> is_top_level=true
>> -while [ "x$list" != "x" ] ; do
>> - linux=`version_find_latest $list`
>> +for linux in $reverse_sorted_list; do
>> gettext_printf "Found linux image: %s\n" "$linux" >&2
>> basename=`basename $linux`
>> dirname=`dirname $linux`
>> @@ -293,8 +299,6 @@ while [ "x$list" != "x" ] ; do
>> linux_entry "${OS}" "${version}" recovery \
>> "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
>> fi
>> -
>> - list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
>> done
>>
>> # If at least one kernel was found, then we need to
>> --
>> 2.30.2
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2022-05-19 20:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 14:24 [PATCH v3] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items Mathieu Desnoyers
2022-05-05 15:04 ` Robbie Harwood
2022-05-05 23:02 ` Oskari Pirhonen
2022-05-19 20:29 ` Mathieu Desnoyers [this message]
2022-05-19 18:36 ` Daniel Kiper
2022-05-19 20:52 ` Mathieu Desnoyers
2022-05-20 5:00 ` Oskari Pirhonen
2022-05-20 11:01 ` Daniel Kiper
2022-05-20 14:33 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=721172156.62842.1652992197038.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.