lkml.org 
[lkml]   [2022]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] boot install: Partially refactor the logic for detecting bootloader
Date
While running `make install` after building the kernel and installing
modules on several distros like EndeavourOS, there would be a pretty
little output (To be exact, "Cannot find LILO") due to lack of LILO
bootloader, which is really uncommon for a user to have it while
GRUB is there. So, if LILO doesn't exist, instead of skipping other
bootloaders, check for `grub-mkconfig` using exit status of `which
grub-mkconfig` to see if we have it present in PATH and run it. All
GRUB installs must have it in PATH for other external scripts and
GRUB itself to handle it fine as well.

I have no idea why did the maintainer not consider this, even after
several posts done on several forums without an actual patch. See
appended link for more details on why is this required without
requiring user to run it themselves.

Link: https://serverfault.com/questions/383286/compiling-linux-kernel-make-install-asks-for-lilo-now-what

Also, put the `sync` command to the end of all commands, make sure
all copied files are properly written to disk for all cases, not only
when LILO is not found.

Suggested-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Beru Shinsetsu <windowz414@gnuweeb.org>
---

v2 -> v3
- Properly make use of GRUB config check and execute `echo` for
when LILO and GRUB are not found only when *both* are missing.
- Make the exit status check compatible with POSIX shell as
well.
- Upon Alviro's suggestion, put `sync` command to the very end,
to make sure all copied files are properly written to disk
unconditionally.

(Link v2: https://t.me/GNUWeeb/552772)
v1 -> v2
- Remove use of absolute path for grub-mkconfig check and use
`which` instead and check its exit status.
- Change commit message accordingly.
---
arch/x86/boot/install.sh | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/boot/install.sh b/arch/x86/boot/install.sh
index d13ec1c38640..2007c06dbbdd 100644
--- a/arch/x86/boot/install.sh
+++ b/arch/x86/boot/install.sh
@@ -54,6 +54,11 @@ if [ -x /sbin/lilo ]; then
elif [ -x /etc/lilo/install ]; then
/etc/lilo/install
else
- sync
- echo "Cannot find LILO."
+ which grub-mkconfig > /dev/null 2>&1
+ if [ "$?" -eq "0" ]; then
+ grub-mkconfig -o /etc/grub/grub.cfg
+ else
+ echo "Cannot find LILO or GRUB."
+ fi
fi
+sync
--
2.35.1
\
 
 \ /
  Last update: 2022-03-16 18:33    [W:0.073 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site