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 # }}}