]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: handle removal unsuccessful UKIs and loader entries separately
authorJörg Behrmann <behrmann@physik.fu-berlin.de>
Fri, 23 Jan 2026 12:55:51 +0000 (13:55 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 27 Jan 2026 14:53:48 +0000 (15:53 +0100)
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.

src/kernel-install/90-loaderentry.install.in
src/kernel-install/90-uki-copy.install

index 6945a0fd288eccc34a7421227d326c61fc3382a5..66cfec888625ff129b4be45a3c34c1f9da3badb7 100755 (executable)
@@ -115,8 +115,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
 
index 90aa876e6afda982120af50606c3cf454abd3d75..a55c7b8e84d807394556284388333878f9f53f2e 100755 (executable)
@@ -70,8 +70,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