mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-22 23:32:39 +00:00
templates/kfreebsd: Fix quadratic algorithm for sorting menu items
The current implementation of the 10_kfreebsd script implements its menu items sorting in bash with a quadratic algorithm, calling "sed", "sort", "head", and "grep" to compare versions between individual lines, which is annoyingly slow for kernel developers who can easily end up with 50-100 kernels in their boot partition. This fix is ported from the 10_linux script, which has a similar quadratic code pattern. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: debian-bsd@lists.debian.org Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
6f27d70a72
commit
709c197944
1 file changed
+8
-4
@@ -157,10 +157,16 @@ title_correction_code=
|
|||||||
# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
|
# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
|
||||||
submenu_indentation=""
|
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/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//')
|
||||||
|
|
||||||
is_top_level=true
|
is_top_level=true
|
||||||
|
|
||||||
while [ "x$list" != "x" ] ; do
|
for kfreebsd in ${reverse_sorted_list}; do
|
||||||
kfreebsd=`version_find_latest $list`
|
|
||||||
gettext_printf "Found kernel of FreeBSD: %s\n" "$kfreebsd" >&2
|
gettext_printf "Found kernel of FreeBSD: %s\n" "$kfreebsd" >&2
|
||||||
basename=`basename $kfreebsd`
|
basename=`basename $kfreebsd`
|
||||||
dirname=`dirname $kfreebsd`
|
dirname=`dirname $kfreebsd`
|
||||||
@@ -238,8 +244,6 @@ while [ "x$list" != "x" ] ; do
|
|||||||
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
|
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
|
||||||
kfreebsd_entry "${OS}" "${version}" recovery "-s"
|
kfreebsd_entry "${OS}" "${version}" recovery "-s"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
list=`echo $list | tr ' ' '\n' | fgrep -vx "$kfreebsd" | tr '\n' ' '`
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# If at least one kernel was found, then we need to
|
# If at least one kernel was found, then we need to
|
||||||
|
|||||||
Reference in new issue
Block a user