1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

Merge pull request #26648 from bluca/kernel_install_guid

kernel-install: also try to find $BOOT by partition GUID
This commit is contained in:
Luca Boccassi 2023-03-07 11:26:12 +00:00 committed by GitHub
commit 0531ac585a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -206,6 +206,7 @@ else
BOOT_ROOT_SEARCH="/efi /boot /boot/efi"
fi
# First search for existing setups in any of the known directories.
for pref in $BOOT_ROOT_SEARCH; do
for suff in $ENTRY_TOKEN_SEARCH; do
if [ -d "$pref/$suff" ]; then
@ -215,7 +216,7 @@ for pref in $BOOT_ROOT_SEARCH; do
log_verbose "$pref/$suff exists, using BOOT_ROOT=$BOOT_ROOT, ENTRY_TOKEN=$ENTRY_TOKEN"
break 2
else
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "$pref/$suff not found…"
log_verbose "$pref/$suff not found…"
fi
if [ -d "$pref/loader/entries" ]; then
@ -228,6 +229,24 @@ for pref in $BOOT_ROOT_SEARCH; do
done
done
# If we haven't found anything, and if we have lsblk, use the partition GUID to
# search for XBOOTLDR (first) or ESP (as a fallback).
if [ -z "$BOOT_ROOT" ] && command -v lsblk >/dev/null 2>&1; then
for guid in bc13c2ff-59e6-4262-a352-b275fd6f7172 c12a7328-f81f-11d2-ba4b-00a0c93ec93b; do
eval "$(lsblk --pairs --output MOUNTPOINT,PARTTYPE | grep "$guid")"
BOOT_ROOT="$MOUNTPOINT"
unset MOUNTPOINT
unset PARTTYPE
if [ -n "$BOOT_ROOT" ]; then
log_verbose "$BOOT_ROOT is a mount point for partition GUID $guid, using BOOT_ROOT=$BOOT_ROOT"
break
fi
done
fi
# Finally if we still haven't found anything, check if /efi or /boot/efi are mountpoints
# and if so, assume they point to the ESP.
[ -z "$BOOT_ROOT" ] && for pref in "/efi" "/boot/efi"; do
if mountpoint -q "$pref"; then
BOOT_ROOT="$pref"
@ -238,16 +257,15 @@ done
fi
done
# If all else fails, install on /boot.
if [ -z "$BOOT_ROOT" ]; then
BOOT_ROOT="/boot"
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "KERNEL_INSTALL_BOOT_ROOT autodection yielded no candidates, using \"$BOOT_ROOT\""
log_verbose "KERNEL_INSTALL_BOOT_ROOT autodetection yielded no candidates, using \"$BOOT_ROOT\""
fi
if [ -z "$ENTRY_TOKEN" ]; then
ENTRY_TOKEN="$MACHINE_ID"
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "No entry-token candidate matched, using \"$ENTRY_TOKEN\" from machine-id"
log_verbose "No entry-token candidate matched, using \"$ENTRY_TOKEN\" from machine-id"
fi
if [ -z "$layout" ]; then
@ -266,8 +284,7 @@ if [ -z "$layout" ]; then
# have no idea what that means, let's stay away from it by default.
layout="other"
fi
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "$BOOT_ROOT/loader/entries.srel with '$ENTRIES_SREL' found, using layout=$layout"
log_verbose "$BOOT_ROOT/loader/entries.srel with '$ENTRIES_SREL' found, using layout=$layout"
elif [ -d "$BOOT_ROOT/$ENTRY_TOKEN" ]; then
# If the metadata in $BOOT_ROOT doesn't tell us anything, then check if