From: Zbigniew Jędrzejewski-Szmek Date: Thu, 19 May 2022 20:22:44 +0000 (+0200) Subject: kernel-install: restore priority of check for /boot/loader/entries X-Git-Tag: v251~3^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b43f868934e971480249a6e0fa2f45da906ea2e;p=thirdparty%2Fsystemd.git kernel-install: restore priority of check for /boot/loader/entries Before 9e82a74cb0f08a288f9db228a0b5bec8a7188cdb, 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 9e82a74cb0f08a288f9db228a0b5bec8a7188cdb, we iterate over the inner directory first and over the second directory later: [ -d /efi/ ] [ -d /boot/efi/ ] [ -d /boot/ ] [ -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 447a822f8ee47b63a4cae00423c4d407bfa5e516 which removed Default from the list, and a5307e173bf86d695fe85b8e15e91126e8618a14, which moved checks for /boot up, so we ended up with: [ -d /efi/ ] [ -d /boot/ ] [ -d /boot/efi/ ] [ -d /efi/loader/entries ] [ -d /boot/loader/entries ] [ -d /boot/efi/loader/entries ] 6637cf9db67237857279262d93ee0e39023c5b85 added autodetection of an entry token, so we end up checking the following suffixes: , $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/ 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/ ] ... [ -d /efi/loader/entries ] [ -d /boot/ ] ... [ -d /boot/loader/entries ] [ -d /boot/efi/ ] ... [ -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. --- diff --git a/src/kernel-install/kernel-install.in b/src/kernel-install/kernel-install.in index 9fa12f6fe81..f43c6b8b42f 100755 --- a/src/kernel-install/kernel-install.in +++ b/src/kernel-install/kernel-install.in @@ -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,19 +189,16 @@ for suff in $ENTRY_TOKEN_SEARCH; do else [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "$pref/$suff 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 + 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/efi"; do