From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nrmmZ-0001Of-A6 for mharc-grub-devel@gnu.org; Thu, 19 May 2022 16:30:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrmmX-0001Kv-TZ for grub-devel@gnu.org; Thu, 19 May 2022 16:30:01 -0400 Received: from mail.efficios.com ([167.114.26.124]:38564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrmmW-00088y-85 for grub-devel@gnu.org; Thu, 19 May 2022 16:30:01 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id EB1733FF49A for ; Thu, 19 May 2022 16:29:57 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id uuKJoIqOnp6T for ; Thu, 19 May 2022 16:29:57 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 399D43FF499 for ; Thu, 19 May 2022 16:29:57 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 399D43FF499 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1652992197; bh=AwoktFQQ1UWpUD9HgtXomwCw59i3PgoXmRiuNGPnhOk=; h=Date:From:To:Message-ID:MIME-Version; b=nBFLCum1Kf4fyU9+QWoMK5pbB4yVZvKDPcLjxHQzzIT6e/CtyImFt0UdNd3C3TN1k iOvA9IS6B3mrviUQdEfdotb90rOWAc4ILw/+h6EdZ4R65KUKxt8051d9/wvsNAXnu9 pTZvCtX1DSehRNFMMUGHQfUzXTkqhUtogdSgQEkc2dc/uz8Drlk+TZH1o4s99SDYXe IOXs0UVg+DlG9AWrFKqlajqhHdzhiG8l38OfXbJiS/OjGscxrP/r12IJTJnyzjKgiv zV1/onYnDZru1UgB5d8+udbZtoeDWrXt2qWehT0/kW3F7ToXREm9LiWocECx9bMnF+ xBpeTGJqr+qDA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id P64CqJvfhpSD for ; Thu, 19 May 2022 16:29:57 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 2F5033FF498 for ; Thu, 19 May 2022 16:29:57 -0400 (EDT) Date: Thu, 19 May 2022 16:29:57 -0400 (EDT) From: Mathieu Desnoyers To: The development of GNU GRUB Message-ID: <721172156.62842.1652992197038.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20220505142456.58107-1-mathieu.desnoyers@efficios.com> Subject: Re: [PATCH v3] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4257 (ZimbraWebClient - FF100 (Linux)/8.8.15_GA_4257) Thread-Topic: grub-mkconfig linux: Fix quadratic algorithm for sorting menu items Thread-Index: KMaWt4mE+g5lBij/Olta5X7nW4LCcw== Received-SPF: pass client-ip=167.114.26.124; envelope-from=compudj@efficios.com; helo=mail.efficios.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: Thu, 19 May 2022 20:30:02 -0000 ----- 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