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

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