From: srs5694 Date: Sun, 22 Nov 2015 02:55:21 +0000 (-0500) Subject: Fixed bugs in mkrlconf and refind-install that could cause kernel X-Git-Url: https://code.delx.au/refind/commitdiff_plain/16025084e9b3cf79dc13b84cd96ee850ff34296a Fixed bugs in mkrlconf and refind-install that could cause kernel options to be omitted from refind_linux.conf --- diff --git a/NEWS.txt b/NEWS.txt index 8ca9348..68893db 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,20 @@ 0.10.1 (??/??/201?): -------------------- +- Fixed bugs in mkrlconf and in refind-install that could cause some kernel + options to be excluded from refind_linux.conf. There were two trouble + conditions: + - Previously, these scripts assumed that the first option in + /proc/cmdline was the kernel's filename, but this isn't always the + case. (In particular, when gummiboot launches the kernel, this is not + true. It might be an incorrect assumption in some other cases, too.) + The fix involves checking for likely signs of a kernel filename before + discarding this first option. + - These scripts cut the "initrd=*" option from /proc/cmdline, but the + call to "sed" was overzealous and cut until the end of input. This + usually worked, since the initrd= option was usually last on the line; + but if it wasn't, any options following initrd= would be lost. + - Added "kernel*" as a matching pattern for Linux kernels, since this is what Gentoo uses by default. diff --git a/mkrlconf b/mkrlconf index 031c82a..9855dec 100755 --- a/mkrlconf +++ b/mkrlconf @@ -45,7 +45,12 @@ if [[ ! -f $RLConfFile || $1 == "--force" ]] ; then RootFS=$Uuid fi fi - DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/$/ /' | sed 's/initrd=.* //g' | sed 's/ *$//'` + FirstCmdlineOption=`cat /proc/cmdline | cut -d ' ' -f 1` + if [[ "$FirstCmdlineOption" =~ (vmlinuz|bzImage|kernel) ]] ; then + DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'` + else + DefaultOptions=`cat /proc/cmdline | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'` + fi echo "\"Boot with standard options\" \"$DefaultOptions\"" > $RLConfFile echo "\"Boot to single-user mode\" \"$DefaultOptions single\"" >> $RLConfFile echo "\"Boot with minimal options\" \"ro root=$RootFS\"" >> $RLConfFile diff --git a/refind-install b/refind-install index 2562d1e..f0fc2b2 100755 --- a/refind-install +++ b/refind-install @@ -1099,7 +1099,12 @@ GenerateRefindLinuxConf() { fi fi if [[ $RootDir == "/" ]] ; then - DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/$/ /' | sed 's/initrd=.* //g' | sed 's/ *$//'` + local FirstCmdlineOption=`cat /proc/cmdline | cut -d ' ' -f 1` + if [[ "$FirstCmdlineOption" =~ (vmlinuz|bzImage|kernel) ]] ; then + DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'` + else + DefaultOptions=`cat /proc/cmdline | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'` + fi else if [[ -f "$RootDir/etc/default/grub" ]] ; then # We want the default options used by the distribution, stored here....