efiboot/autorm functions: ignore running kernel if it was removed

In the case were someone removes the current kernel we do not can
"keep" it anymore. While this was obviously no issue for the
autoremoval logic, it is an issue for the pve-efiboot-tool refresh
command, which reuses this helper to see which kernels it needs to
keep on the ESP.

Without this a running kernel was never removed from the EFI System
Partitions if de-installed from a host, so if it sorted as newest one
it was then booted again, which naturally confuses users (it was just
removed!!). So to ensure that we cannot get such zombie kernels
ensure that only installed kernels are included in the list.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-11-07 18:37:02 +01:00
parent 40cfed49af
commit 25c1475040

View File

@ -14,7 +14,7 @@ PMX_LOADER_CONF="loader/loader.conf"
# debian's apt package:
#
# Mark as not-for-autoremoval those kernel packages that are:
# - the currently booted version
# - the currently booted version, if still installed
# - the kernel version we've been called for
# - the latest kernel version (as determined by debian version number)
# - the second-latest kernel version
@ -37,6 +37,11 @@ kernel_keep_versions() {
# ignore the currently running version if attempting a reproducible build
if [ -n "${SOURCE_DATE_EPOCH}" ]; then
running_version=""
elif [ ! -e "/boot/vmlinuz-$running_version" ]; then
# ignore the current version if it got removed, the "auto-remove" logic
# will not be affected, because either it is installed and thus we keep
# it in the list, or it's already removed anyway
running_version=""
fi
latest_2_versions="$(echo "$sorted_list" | grep -E '^[^ ]+-pve' | head -n2 )"