From 65537f8fe638f20a637c64d222044631ec5fea90 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Thu, 20 Jul 2023 14:59:31 +0200 Subject: [PATCH] Keep 4 old versions of kernels --- debian/create-efi-kernel | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/create-efi-kernel b/debian/create-efi-kernel index 007ae7b..8edd6ff 100755 --- a/debian/create-efi-kernel +++ b/debian/create-efi-kernel @@ -32,7 +32,12 @@ while IFS= read -r OLD_EFI_ENTRY; do done < "${temp_efi_list_file}" # }}} # Clean old kernels {{{ -## Remove all unified kernels +## Rename last version of generic kernel for backup +mv -- "${EFI_MOUNT_PATH}/EFI/debian/linux.debian.efi" "${EFI_MOUNT_PATH}/EFI/debian/backup.debian.efi.$(date +%Y%m%d-%H%M)" +## Keep only the 4 more recent backup kernels +find "${EFI_MOUNT_PATH}/EFI/debian" -type f -iname "backup.debian.efi.*" | sort --reverse --numeric-sort -- | tail --lines=+5 -- | xargs --replace={} rm -- {} + +## Remove all previous unified kernels with version in filename find "${EFI_MOUNT_PATH}/EFI/debian" -type f -iname "linux.debian.*.efi" -delete # }}}