This is a patch that fixes kernel and initrd search and menu entry naming.
The patch is self-explanatory.
Please enjoy reading it.
The patch is attached as an attachment.
util/grub-mkconfig_lib.in +37 -3
@@ -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