kernel/postinst.d: check for correct update-initramfs provider

Ubuntu's dracut package ships an `update-initramfs` command with the
same interface as initramfs-tools'. The difference is that it calls
dracut instead of mkinitramfs.

When installing dracut without purging initramfs-tools,
`/etc/kernel/postinst.d/initramfs-tools` will still execute
`update-initramfs` (in addition to dracut's kernel postinst hook).

So query the newly add `--version` parameter to determine which package
provided the `update-initramfs` script. Only run the kernel postinst
hook when the provider matches.
This commit is contained in:
Benjamin Drung 2025-03-24 11:31:13 +01:00
parent 65166a6ff3
commit 2334de30e4

View File

@ -6,6 +6,8 @@ bootopt=""
command -v update-initramfs >/dev/null 2>&1 || exit 0
test "$(update-initramfs --version | cut -d ' ' -f 1)" = initramfs-tools || exit 0
# passing the kernel version is required
if [ -z "${version}" ]; then
echo >&2 "W: initramfs-tools: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number"