public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] boot install: Partially refactor the logic for detecting bootloader
@ 2022-03-16 17:32 Beru Shinsetsu
  2022-03-17 12:36 ` Boris Petkov
  0 siblings, 1 reply; 7+ messages in thread
From: Beru Shinsetsu @ 2022-03-16 17:32 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	linux-kernel, GNU/Weeb Mailing List, Beru Shinsetsu,
	Alviro Iskandar Setiawan

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 <[email protected]>
Signed-off-by: Beru Shinsetsu <[email protected]>
---

  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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-20  9:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-16 17:32 [PATCH] boot install: Partially refactor the logic for detecting bootloader Beru Shinsetsu
2022-03-17 12:36 ` Boris Petkov
2022-03-17 13:16   ` Beru Shinsetsu
2022-03-17 13:42     ` Boris Petkov
2022-03-17 13:46       ` Beru Shinsetsu
2022-03-19 21:20         ` Borislav Petkov
2022-03-20  9:30           ` Beru Shinsetsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox