You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
76 lines
2.8 KiB
2 years ago
|
From d044a59e1098c3497e76c3ebdef88036378e6c26 Mon Sep 17 00:00:00 2001
|
||
|
From: Lennart Poettering <lennart@poettering.net>
|
||
|
Date: Thu, 10 Feb 2022 14:27:22 +0100
|
||
|
Subject: [PATCH] kernel-install: search harder for kernel image/initrd drop-in
|
||
|
dir
|
||
|
|
||
|
If not explicitly configured, let's search a bit harder for the
|
||
|
ENTRY_TOKEN, and let's try the machine ID, the IMAGE_ID and ID fields of
|
||
|
/etc/os-release and finally "Default", all below potential $XBOOTLDR.
|
||
|
|
||
|
(cherry picked from commit 6637cf9db67237857279262d93ee0e39023c5b85)
|
||
|
|
||
|
Related: #2065061
|
||
|
---
|
||
|
src/kernel-install/kernel-install | 27 ++++++++++++++++++++++++---
|
||
|
1 file changed, 24 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
|
||
|
index 75a31c62d4..c42c40592a 100755
|
||
|
--- a/src/kernel-install/kernel-install
|
||
|
+++ b/src/kernel-install/kernel-install
|
||
|
@@ -103,29 +103,50 @@ fi
|
||
|
# for naming the .conf boot loader spec entry. Typically this is just the
|
||
|
# machine ID, but it can be anything else, too, if we are told so.
|
||
|
[ -z "$ENTRY_TOKEN" ] && [ -r /etc/kernel/entry-token ] && read -r ENTRY_TOKEN </etc/kernel/entry-token
|
||
|
-[ -z "$ENTRY_TOKEN" ] && ENTRY_TOKEN="$MACHINE_ID"
|
||
|
+if [ -z "$ENTRY_TOKEN" ]; then
|
||
|
+ # If not configured explicitly, then use a few candidates: the machine ID,
|
||
|
+ # the IMAGE_ID= and ID= fields from /etc/os-release and finally the fixed
|
||
|
+ # string "Default"
|
||
|
+ ENTRY_TOKEN_SEARCH="$MACHINE_ID"
|
||
|
+ [ -r /etc/os-release ] && . /etc/os-release
|
||
|
+ [ -n "$IMAGE_ID" ] && ENTRY_TOKEN_SEARCH="$ENTRY_TOKEN_SEARCH $IMAGE_ID"
|
||
|
+ [ -n "$ID" ] && ENTRY_TOKEN_SEARCH="$ENTRY_TOKEN_SEARCH $ID"
|
||
|
+ ENTRY_TOKEN_SEARCH="$ENTRY_TOKEN_SEARCH Default"
|
||
|
+else
|
||
|
+ ENTRY_TOKEN_SEARCH="$ENTRY_TOKEN"
|
||
|
+fi
|
||
|
|
||
|
# NB: The $MACHINE_ID is guaranteed to be a valid machine ID, but
|
||
|
# $ENTRY_TOKEN can be any string that fits into a VFAT filename, though
|
||
|
# typically is just the machine ID.
|
||
|
|
||
|
-[ -z "$BOOT_ROOT" ] && for suff in "$ENTRY_TOKEN" "loader/entries"; do
|
||
|
- for pref in "/efi" "/boot" "/boot/efi" ; do
|
||
|
+[ -z "$BOOT_ROOT" ] && for suff in $ENTRY_TOKEN_SEARCH; do
|
||
|
+ for pref in "/efi" "/boot" "/boot/efi"; do
|
||
|
if [ -d "$pref/$suff" ]; then
|
||
|
BOOT_ROOT="$pref"
|
||
|
+ ENTRY_TOKEN="$suff"
|
||
|
break 2
|
||
|
fi
|
||
|
done
|
||
|
done
|
||
|
|
||
|
+[ -z "$BOOT_ROOT" ] && for pref in "/efi" "/boot" "/boot/efi"; do
|
||
|
+ if [ -d "$pref/loader/entries" ]; then
|
||
|
+ BOOT_ROOT="$pref"
|
||
|
+ break
|
||
|
+ fi
|
||
|
+done
|
||
|
+
|
||
|
[ -z "$BOOT_ROOT" ] && for pref in "/efi" "/boot/efi"; do
|
||
|
if mountpoint -q "$pref"; then
|
||
|
BOOT_ROOT="$pref"
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
+
|
||
|
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/boot"
|
||
|
|
||
|
+[ -z "$ENTRY_TOKEN" ] && ENTRY_TOKEN="$MACHINE_ID"
|
||
|
|
||
|
if [ -z "$layout" ]; then
|
||
|
# Administrative decision: if not present, some scripts generate into /boot.
|