public inbox for [email protected]
 help / color / mirror / Atom feed
From: Beru Shinsetsu <[email protected]>
To: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>, Borislav Petkov <[email protected]>,
	Dave Hansen <[email protected]>,
	[email protected], "H. Peter Anvin" <[email protected]>,
	[email protected],
	GNU/Weeb Mailing List <[email protected]>,
	Beru Shinsetsu <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH] boot install: Partially refactor the logic for detecting bootloader
Date: Wed, 16 Mar 2022 20:32:21 +0300	[thread overview]
Message-ID: <[email protected]> (raw)

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


             reply	other threads:[~2022-03-16 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 17:32 Beru Shinsetsu [this message]
2022-03-17 12:36 ` [PATCH] boot install: Partially refactor the logic for detecting bootloader 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox