1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

kernel-install: restore priority of check for /boot/loader/entries

Before 9e82a74cb0, we had a check like the
following:

if [[ -d /efi/loader/entries ]] || [[ -d /efi/$MACHINE_ID ]]; then
    ENTRY_DIR_ABS="/efi/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/loader/entries ]] || [[ -d /boot/$MACHINE_ID ]]; then
    ENTRY_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
elif [[ -d /boot/efi/loader/entries ]] || [[ -d /boot/efi/$MACHINE_ID ]]; then
    ENTRY_DIR_ABS="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
…

In stock Fedora 34-, /efi isn't used, but grub creates /boot/loader/entries and
installs kernels and initrds directly in /boot. Thus the second arm of the
check wins, and we end up with BOOT_ROOT=/boot.

After 9e82a74cb0, we iterate over the inner
directory first and over the second directory later:

[ -d /efi/<machine-id> ]
[ -d /boot/efi/<machine-id> ]
[ -d /boot/<machine-id> ]
[ -d /efi/Default ]
[ -d /boot/efi/Default ]
[ -d /boot/Default ]
[ -d /efi/loader/entries ]
[ -d /boot/efi/loader/entries ]
[ -d /boot/loader/entries ]

This was partially reverted by 447a822f8e which
removed Default from the list, and a5307e173b,
which moved checks for /boot up, so we ended up with:

[ -d /efi/<machine-id> ]
[ -d /boot/<machine-id> ]
[ -d /boot/efi/<machine-id> ]
[ -d /efi/loader/entries ]
[ -d /boot/loader/entries ]
[ -d /boot/efi/loader/entries ]

6637cf9db6 added autodetection of an entry
token, so we end up checking the following suffixes:

<machine-id>, $IMAGE_ID, $ID, Default

But the important unchanged characteristic is that we iterate over the suffix
first. Sadly this breaks Fedora, because we find /boot/efi/<machine-id> before
we could find /boot/loader/entries. It seems that every possible aspect of
behaviour matters for somebody, so we need to keep the original order of
detection.

With the patch:

[ -d /efi/<machine-id> ]
...
[ -d /efi/loader/entries ]
[ -d /boot/<machine-id> ]
...
[ -d /boot/loader/entries ]
[ -d /boot/efi/<machine-id> ]
...
[ -d /boot/efi/loader/entries ]

Note that we need to check for "loader/entries" too, even though it is not
an entry-token candidate, so that we get the same detection priority as
before.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2071034.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-05-19 22:22:44 +02:00
parent eb45cf97a9
commit 1b43f86893

View File

@ -177,8 +177,8 @@ else
BOOT_ROOT_SEARCH="/efi /boot /boot/efi"
fi
for suff in $ENTRY_TOKEN_SEARCH; do
for pref in $BOOT_ROOT_SEARCH; do
for pref in $BOOT_ROOT_SEARCH; do
for suff in $ENTRY_TOKEN_SEARCH; do
if [ -d "$pref/$suff" ]; then
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="$pref"
[ -z "$ENTRY_TOKEN" ] && ENTRY_TOKEN="$suff"
@ -189,21 +189,18 @@ for suff in $ENTRY_TOKEN_SEARCH; do
else
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "$pref/$suff not found…"
fi
if [ -d "$pref/loader/entries" ]; then
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="$pref"
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "$pref/loader/entries exists, using BOOT_ROOT=$BOOT_ROOT"
break 2
else
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "$pref/loader/entries not found…"
fi
done
done
[ -z "$BOOT_ROOT" ] && for pref in "/efi" "/boot" "/boot/efi"; do
if [ -d "$pref/loader/entries" ]; then
BOOT_ROOT="$pref"
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "$pref/loader/entries exists, using BOOT_ROOT=$BOOT_ROOT"
break
else
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "$pref/loader/entries not found…"
fi
done
[ -z "$BOOT_ROOT" ] && for pref in "/efi" "/boot/efi"; do
if mountpoint -q "$pref"; then
BOOT_ROOT="$pref"