Blame SOURCES/0241-10_linux_bls-use-grub2-rpm-sort-instead-of-ls-vr-to-.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Javier Martinez Canillas <javierm@redhat.com>
8631a2
Date: Tue, 16 Oct 2018 15:48:15 +0200
8631a2
Subject: [PATCH] 10_linux_bls: use grub2-rpm-sort instead of ls -vr to sort
8631a2
 entries
8631a2
8631a2
Using ls -vr is wrong since it's not the same than the RPM sort algorithm.
8631a2
8631a2
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
8631a2
---
8631a2
 util/grub.d/10_linux_bls.in | 18 +++++++++++++++---
8631a2
 1 file changed, 15 insertions(+), 3 deletions(-)
8631a2
8631a2
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
f6e916
index 8a3379578..1bc97f298 100644
8631a2
--- a/util/grub.d/10_linux_bls.in
8631a2
+++ b/util/grub.d/10_linux_bls.in
8631a2
@@ -151,10 +151,22 @@ read_config()
8631a2
 
8631a2
 populate_menu()
8631a2
 {
8631a2
-    entries_path="/boot/loader/entries"
8631a2
+    blsdir="/boot/loader/entries"
8631a2
+    local -a files
8631a2
+    local IFS=$'\n'
8631a2
     gettext_printf "Generating boot entries from BLS files...\n" >&2
8631a2
-    for config in $(ls -v -r $entries_path/*.conf); do
8631a2
-        read_config ${config}
8631a2
+
8631a2
+    files=($(for bls in ${blsdir}/*.conf ; do
8631a2
+        if ! [[ -e "${bls}" ]] ; then
8631a2
+            continue
8631a2
+        fi
8631a2
+        bls="${bls%.conf}"
8631a2
+        bls="${bls##*/}"
8631a2
+        echo "${bls}"
8631a2
+    done | ${kernel_sort} | tac)) || :
8631a2
+
8631a2
+    for bls in "${files[@]}" ; do
8631a2
+        read_config "${blsdir}/${bls}.conf"
8631a2
         menu="${menu}menuentry '${title}' {\n"
8631a2
         menu="${menu}\t linux ${linux} ${options}\n"
8631a2
         if [ -n "${initrd}" ] ; then