Skip to content

Commit 59aad95

Browse files
behrmannbluca
authored andcommitted
kernel-install: Remove existing loader entries and UKIs
When boot counting is enabled, adding a new loader entry or UKI can conflict with an existing one that has booted successfully and therefore has its boot counter removed. systemd-bless-boot will fail to bless the new successful boot, since a file without a boot counter already exists. Since kernel-install will clobber existing files without boot counting, we should therefore remove files without a boot count as well, when we add a file with one. Fixes: #33504 (cherry picked from commit 99d4575) (cherry picked from commit b786185) (cherry picked from commit 85ca158)
1 parent 43a6208 commit 59aad95

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ if [ -f "$TRIES_FILE" ]; then
101101
echo "$TRIES_FILE does not contain an integer." >&2
102102
exit 1
103103
fi
104+
if [ -f "$LOADER_ENTRY" ]; then
105+
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
106+
echo "Removing previous loader entry '$LOADER_ENTRY' without boot counting." >&2
107+
rm -f "$LOADER_ENTRY" "${LOADER_ENTRY%.conf}+"*.conf
108+
fi
104109
LOADER_ENTRY="${LOADER_ENTRY%.conf}+$TRIES.conf"
105110
fi
106111

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ if [ -f "$TRIES_FILE" ]; then
6161
echo "$TRIES_FILE does not contain an integer." >&2
6262
exit 1
6363
fi
64+
if [ -f "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi" ]; then
65+
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
66+
echo "Removing previous UKI '$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi' without boot counting." >&2
67+
rm -f "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi" "$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+"*.efi
68+
fi
69+
6470
UKI_FILE="$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+$TRIES.efi"
6571
else
6672
UKI_FILE="$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi"

0 commit comments

Comments
 (0)