Hi, I just noticed that when purging an installed kernel, the
/etc/kernel/postrm.d/systemd-boot hook runs twice; here's an example:
# apt purge linux-image-5.17.0-1-amd64
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
linux-image-5.17.0-1-amd64*
0 upgraded, 0 newly installed, 1 to remove and 37 not upgraded.
After this operation, 454 MB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 221345 files and directories currently installed.)
Removing linux-image-5.17.0-1-amd64 (5.17.3-1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-5.18.0-2-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-5.18.0-2-amd64
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.17.0-1-amd64
/etc/kernel/postrm.d/systemd-boot:
Removing kernel version 5.17.0-1-amd64 from systemd-boot...
(Reading database ... 216472 files and directories currently installed.)
Purging configuration files for linux-image-5.17.0-1-amd64 (5.17.3-1) ...
/etc/kernel/postrm.d/systemd-boot:
Removing kernel version 5.17.0-1-amd64 from systemd-boot...
I don't personally know well enough how these scripts are invoked and I can't
propose a solution, but the scripts suggested by Andre and Sam in bug #826045
seem to not have this issue.