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.
This commit is contained in:
Jörg Behrmann
2026-01-27 15:53:48 +01:00
committed by Zbigniew Jędrzejewski-Szmek
parent 69d130aac5
commit cab4b9defd
2 changed files with 14 additions and 2 deletions
+7 -1
View File
@@ -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
+7 -1
View File
@@ -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