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