Skip to contentSkip to conversation

This is a patch that fixes kernel and initrd search and menu entry naming.

PATCH crocket 1 participant 1 message Jan 2, 2011

lore
Share & tools
lore

crocket

author
#0 lore raw

The patch is self-explanatory.
Please enjoy reading it.

The patch is attached as an attachment.

util/grub-mkconfig_lib.in +37 -3
diff -Naur grub-a/util/grub-mkconfig_lib.in grub-b/util/grub-mkconfig_lib.in
@@ -159,12 +159,30 @@
   fi
 }
 
-version_test_gt ()
+version_alphanumeric_test_gt ()
 {
   local a=`echo $1 | sed -e "s/[^-]*-//"`
   local b=`echo $2 | sed -e "s/[^-]*-//"`
+
+  version_test_gt "$a" "$b"
+  return $?
+}
+
+version_numeric_test_gt ()
+{
+  local a=`echo $1 | sed -e "s/[^0-9]*-//"`
+  local b=`echo $2 | sed -e "s/[^0-9]*-//"`
+
+  version_test_gt "$a" "$b"
+  return $?
+}
+
+version_test_gt()
+{
+  local a=$1
+  local b=$2
   local cmp=gt
-  if [ "x$b" = "x" ] ; then
+  if [ "$b" = "" ]; then
     return 0
   fi
   case $a:$b in
@@ -179,11 +197,27 @@
 version_find_latest ()
 {
   local a=""
+  local numeric_ver=""
+  local latest_kernels=""
+
+  # There can be kernels with the same version but different configurations.
+  # Such instances are vmlinuz-generic-2.6.36.1 and vmlinuz-huge-2.6.36.1
+  # So we find out the latest kernel version first.
   for i in $@ ; do
-    if version_test_gt "$i" "$a" ; then
+    if version_numeric_test_gt "$i" "$a" ; then
       a="$i"
     fi
   done
+  
+  numeric_ver="$(echo $a | sed "s,[^0-9]*-\([.0-9]*\).*,\1,")"
+  latest_kernels=$(echo $@ | tr " " "\n" | sed -n "/$numeric_ver/ p" | tr "\n" " ")
+  # Filter the kernel of the highest alphanumerical rank among the latest kernels.
+  for i in $latest_kernels; do
+    if version_alphanumeric_test_gt "$i" "$a" ; then
+      a="$i"
+    fi
+  done
+
   echo "$a"
 }
 
util/grub.d/10_linux.in +26 -16

68 lines not on this page · raw message