From: Jörg Behrmann Date: Fri, 23 Jan 2026 12:55:51 +0000 (+0100) Subject: kernel-install: handle removal unsuccessful UKIs and loader entries separately X-Git-Tag: v257.11~90 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d168dca1e3527c357440924c98f131dc21b09bc;p=thirdparty%2Fsystemd.git kernel-install: handle removal unsuccessful UKIs and loader entries separately When a tries file exists, 90-uki-copy.install removes a previous UKI of the same kernel version and all it's unbooted variants. This removal is guarded behind a check for the existence of the already booted UKI, i.e. if uki.efi already exists, uki.efi and uki+*.efi will be removed. This leaves the edge case that if uki.efi does not exist, but only an unbooted, e.g. uki+3.efi, it will not be removed. This is not a problem, if the number of tries is constant between both builds, since a new uki+3.efi would overwrite the existing one, but if the number of tries is changed to, e.g. uki+5.efi, we are left with both uki+3.efi and uki+5.efi. The same is done for loader entries. (cherry picked from commit cab4b9defdef1f9f9d3c31b262aed408a6616490) (cherry picked from commit 1567b00b632d426e50ee6a1cb75d906e2c8035ef) (cherry picked from commit 583b5ef3d3c5dfa66bd45c0307dbfd85912c339f) --- diff --git a/src/kernel-install/90-loaderentry.install.in b/src/kernel-install/90-loaderentry.install.in index 832a82794ca..c730ba894b8 100755 --- a/src/kernel-install/90-loaderentry.install.in +++ b/src/kernel-install/90-loaderentry.install.in @@ -106,8 +106,14 @@ if [ -f "$TRIES_FILE" ]; then if [ -f "$LOADER_ENTRY" ]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ echo "Removing previous loader entry '$LOADER_ENTRY' without boot counting." >&2 - rm -f "$LOADER_ENTRY" "${LOADER_ENTRY%.conf}+"*.conf + rm -f "$LOADER_ENTRY" fi + for loaderentry in "${LOADER_ENTRY%.conf}+"*.conf; do + [ "$loaderentry" = "${LOADER_ENTRY%.conf}+*.conf" ] && break + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ + echo "Removing previous loader entry '$loaderentry' that has not yet booted successfully." >&2 + rm -f "$loaderentry" + done LOADER_ENTRY="${LOADER_ENTRY%.conf}+$TRIES.conf" fi diff --git a/src/kernel-install/90-uki-copy.install b/src/kernel-install/90-uki-copy.install index 04bf5d1752f..f48417f85df 100755 --- a/src/kernel-install/90-uki-copy.install +++ b/src/kernel-install/90-uki-copy.install @@ -65,8 +65,14 @@ if [ -f "$TRIES_FILE" ]; then if [ -f "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi" ]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ echo "Removing previous UKI '$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi' without boot counting." >&2 - rm -f "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi" "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+"*.efi + rm -f "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi" fi + for uki in "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+"*.efi; do + [ "$uki" = "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+*.efi" ] && break + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ + echo "Removing previous UKI '$uki' that has not yet booted successfully." >&2 + rm -f "$uki" + done UKI_FILE="$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+$TRIES.efi" else