Dave, I don't agree that there's a relevant difference here between flash-kernel and grub.
Grub: initrd not yet generated; grub postinst is called and adds kernel as first entry in grub.cfg; power event happens before kernel postinst is called; system fails to (noninteractively) boot.
flash-kernel: initrd not yet generated; flash-kernel postinst is called and writes kernel (without initramfs) to the boot partition; power event happens before kernel postinst is called; system fails to boot.
Both scenarios need to be guarded against, and we should use the same model for both (and any other bootloaders on other archs).
*Unfortunately*, it turns out that while Andy and I whiteboarded this about 5 years back, what we discussed never wound up being implemented in the kernel packages. I believe the plan at the time was to use a dpkg-divert in the kernel preinst to divert /boot/vmlinuz-$ver to /boot/vmlinuz-$ver.dpkg-something, and then to un-divert it in the postinst only after the initramfs has been generated. grub already has code to ignore the pattern vmlinuz*.dpkg-* so no further changes would be required for grub; and it would be easy to make flash-kernel match.
However, none of this matters so long as the kernel doesn't implement such an interface.
In any case, I'm not happy with the proposed implementation in flash-kernel. I think rooting around in the dpkg database is bad form. Ultimately, though, it's not my opinion on this that matters - we really need input from the Kernel Team here wrt what interface we're going to support between the packages. I subscribed Andy to the bug, but he hasn't replied yet; adding Dimitri as well.
Dave, I don't agree that there's a relevant difference here between flash-kernel and grub.
Grub: initrd not yet generated; grub postinst is called and adds kernel as first entry in grub.cfg; power event happens before kernel postinst is called; system fails to (noninteractively) boot.
flash-kernel: initrd not yet generated; flash-kernel postinst is called and writes kernel (without initramfs) to the boot partition; power event happens before kernel postinst is called; system fails to boot.
Both scenarios need to be guarded against, and we should use the same model for both (and any other bootloaders on other archs).
*Unfortunately*, it turns out that while Andy and I whiteboarded this about 5 years back, what we discussed never wound up being implemented in the kernel packages. I believe the plan at the time was to use a dpkg-divert in the kernel preinst to divert /boot/vmlinuz-$ver to /boot/vmlinuz- $ver.dpkg- something, and then to un-divert it in the postinst only after the initramfs has been generated. grub already has code to ignore the pattern vmlinuz*.dpkg-* so no further changes would be required for grub; and it would be easy to make flash-kernel match.
However, none of this matters so long as the kernel doesn't implement such an interface.
In any case, I'm not happy with the proposed implementation in flash-kernel. I think rooting around in the dpkg database is bad form. Ultimately, though, it's not my opinion on this that matters - we really need input from the Kernel Team here wrt what interface we're going to support between the packages. I subscribed Andy to the bug, but he hasn't replied yet; adding Dimitri as well.