Bug#759308: Add option for substring match to prefer Linux kernel versions
Doug Brunner
doug.a.brunner at gmail.com
Tue Aug 26 03:00:07 UTC 2014
Package: grub-common
Version: 2.02~beta2-11
Severity: wishlist
I (and apparently a number of others, see e.g. http://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry) found myself needing to change the Linux kernel version GRUB sets as default. The process is rather clunky and error-prone; you have to figure out where in the GRUB menu it will appear, then enter that in /etc/default/grub, and if the menu position changes due to new kernels added to the system you have to do it all over again. I had older kernels with a distinctive local version naming scheme that I wanted preferred over the stock kernels, but it could also be used to specify a particular kernel version.
Testing: Kernels that do not have the substring from GRUB_LINUX_PREF_VERSION_SUBSTR should be ordered below kernels that do. The group of kernels with the substring should be sorted by version, as should kernels without. Specify GRUB_LINUX_PREF_VERSION_SUBSTR=foo in /etc/default/grub and run update-grub.
Patch against git c5b76152c1f9d0cdb999e27a82ea520ab5c4faa4 to implement change follows:
---
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index ccce9e5..d31f65c 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -242,7 +242,8 @@ export GRUB_DEFAULT \
GRUB_OS_PROBER_SKIP_LIST \
GRUB_DISABLE_SUBMENU \
GRUB_RECORDFAIL_TIMEOUT \
- GRUB_RECOVERY_TITLE
+ GRUB_RECOVERY_TITLE \
+ GRUB_LINUX_PREF_VERSION_SUBSTR
if test "x${grub_cfg}" != "x"; then
rm -f "${grub_cfg}.new"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 79fa03a..74b26b6 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -269,13 +269,28 @@ EOF
# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
submenu_indentation=""
+pref_list=""
+non_pref_list=""
+for entry in $list; do
+ if [[ "$entry" == *$GRUB_LINUX_PREF_VERSION_SUBSTR* ]]; then
+ pref_list="$pref_list $entry"
+ else
+ non_pref_list="$non_pref_list $entry"
+ fi
+done
+
is_top_level=true
-while [ "x$list" != "x" ] ; do
- linux=`version_find_latest $list`
+while [ "x$pref_list$non_pref_list" != "x" ] ; do
+ if [ "x$pref_list" != "x" ]; then
+ linux=`version_find_latest $pref_list`
+ pref_list=`echo $pref_list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
+ else
+ linux=`version_find_latest $non_pref_list`
+ non_pref_list=`echo $non_pref_list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
+ fi
case $linux in
*.efi.signed)
# We handle these in linux_entry.
- list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
continue
;;
esac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20140825/f3da787e/attachment-0001.html>
More information about the Pkg-grub-devel
mailing list