summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörg Behrmann <behrmann@physik.fu-berlin.de>2024-07-12 10:43:54 +0200
committerLennart Poettering <lennart@poettering.net>2024-07-15 10:16:36 +0200
commit99d4575e541fa1fb00dc80f7aad572f3a66db461 (patch)
tree1a2c41c4efe7e006e464ea702120675be9d40912
parentsysupdate: fix size_t specifier (diff)
downloadsystemd-99d4575e541fa1fb00dc80f7aad572f3a66db461.tar.xz
systemd-99d4575e541fa1fb00dc80f7aad572f3a66db461.zip
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
Diffstat (limited to '')
-rwxr-xr-xsrc/kernel-install/90-loaderentry.install.in5
-rwxr-xr-xsrc/kernel-install/90-uki-copy.install6
2 files changed, 11 insertions, 0 deletions
diff --git a/src/kernel-install/90-loaderentry.install.in b/src/kernel-install/90-loaderentry.install.in
index 766d321595..4ef6aca169 100755
--- a/src/kernel-install/90-loaderentry.install.in
+++ b/src/kernel-install/90-loaderentry.install.in
@@ -101,6 +101,11 @@ if [ -f "$TRIES_FILE" ]; then
echo "$TRIES_FILE does not contain an integer." >&2
exit 1
fi
+ 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
+ fi
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 d443c4b401..d6f71349cb 100755
--- a/src/kernel-install/90-uki-copy.install
+++ b/src/kernel-install/90-uki-copy.install
@@ -61,6 +61,12 @@ if [ -f "$TRIES_FILE" ]; then
echo "$TRIES_FILE does not contain an integer." >&2
exit 1
fi
+ 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
+ fi
+
UKI_FILE="$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION+$TRIES.efi"
else
UKI_FILE="$UKI_DIR/$ENTRY_TOKEN-$KERNEL_VERSION.efi"