#1153125 systemd-boot: duplicate kernel-install/mkosi-initrd invocation with initramfs-tools and UKI

Package:
systemd-boot
Source:
systemd-boot
Description:
simple UEFI boot manager - tools and services
Submitter:
Julien Cassette
Date:
2026-11-05 20:41:03 UTC
Severity:
normal
#1153125#5
Date:
2026-11-05 20:39:57 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

I use Debian 13 with systemd-boot and UKIs generated by mkosi-initrd.

# /etc/kernel/install.conf
layout=uki
initrd_generator=mkosi-initrd
uki_generator=mkosi

During a kernel package configuration (dpkg-reconfigure linux-
image-6.12.115+deb13.1-amd64),
mkosi-initrd appears to run twice.

Before applying the workaround, these hooks were present:
/etc/kernel/postinst.d/initramfs-tools
/etc/kernel/postinst.d/zz-systemd-boot
/etc/initramfs/post-update.d/systemd-boot

/etc/kernel/postinst.d/initramfs-tools calls `update-initramfs`.
/etc/initramfs/post-update.d/systemd-boot contains a call to `kernel-install
add`.
/etc/kernel/postinst.d/zz-systemd-boot contains another call to `kernel-install
add`.

This appears to provide two paths to invoke kernel-install during the same
kernel package operation.

   * What exactly did you do (or not do) that was effective (or ineffective)?

I ran:
sudo dpkg-reconfigure linux-image-6.12.115+deb13.1-amd64

The output showed "update-initramfs: Generating ..." and two separate mkosi
workspaces.
Each workspace created microcode.initrd and initrd, compressed the initrd, and
invoked systemd-measure sign.

I then locally diverted the zz-systemd-boot hook:
sudo dpkg-divert --local --rename --add \
  --divert /etc/kernel/postinst.d/zz-systemd-boot.disabled \
  /etc/kernel/postinst.d/zz-systemd-boot

   * What was the outcome of this action?

With both hooks active, mkosi-initrd ran twice.
After diverting zz-systemd-boot, running dpkg-reconfigure caused mkosi-initrd
to run once.
The initrd and UKI were updated, and bootctl list showed the UKI as the default
entry.

   * What outcome did you expect instead?

I expected the kernel package configuration to generate and install the initrd
and UKI once.
Could the hooks coordinate to avoid invoking kernel-install twice for the same
kernel operation,
while still updating boot artifacts for standalone initramfs updates and normal
kernel installations?