Benjamin Drung 7f2ed354cc Avoid updating the initramfs twice for some cases
When installing/upgrading packages (e. g. a kernel and initramfs-tools),
the same initrd is generated twice:

```
$ apt-get install --no-install-recommends -y zstd initramfs-tools linux-image-generic
[...]
Setting up initramfs-tools-core (0.146) ...
Setting up initramfs-tools (0.146) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-6.12.20-amd64 (6.12.20-1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.12.20-amd64
I: /vmlinuz is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img is now a symlink to boot/initrd.img-6.12.20-amd64
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.12.20-amd64
Setting up linux-image-amd64 (6.12.20-1) ...
Processing triggers for initramfs-tools (0.146) ...
update-initramfs: Generating /boot/initrd.img-6.12.20-amd64
```

Remember the timestamp when the dpkg trigger is set in the file
`/run/update-initramfs.dpkg-trigger`. Then only update the initramfs if
it is not newer than the time the trigger was created.

This will solve the example given above:

```
$ apt-get install --no-install-recommends -y zstd initramfs-tools linux-image-generic
[...]
Setting up initramfs-tools-core (0.146) ...
Setting up initramfs-tools (0.146) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-6.12.20-amd64 (6.12.20-1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img.old is now a symlink to boot/initrd.img-6.12.20-amd64
I: /vmlinuz is now a symlink to boot/vmlinuz-6.12.20-amd64
I: /initrd.img is now a symlink to boot/initrd.img-6.12.20-amd64
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.12.20-amd64
Setting up linux-image-amd64 (6.12.20-1) ...
Processing triggers for libc-bin (2.41-6) ...
Processing triggers for initramfs-tools (0.146) ...
update-initramfs: /boot/initrd.img-6.12.20-amd64 has already been updated since Tue Mar 25 11:48:49 2025.
```

This approach will not help, when the update-initramfs trigger is set by
another package (e. g. clevis-initramfs). That would need support from
the dpkg trigger (see Debian bug #1099136).

LP: #1466965
2025-03-25 12:49:23 +01:00
2025-01-19 23:15:41 +01:00
2025-03-06 22:44:05 +01:00
2023-02-27 22:29:35 +10:00
Description
initramfs-tools
2 MiB
Languages
Shell 68.3%
Roff 22.3%
C 9.3%