mirror of
https://salsa.debian.org/kernel-team/initramfs-tools.git
synced 2026-01-26 07:37:54 +00:00
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
This commit is contained in:
parent
40694280ef
commit
7f2ed354cc
9
debian/initramfs-tools.postinst
vendored
9
debian/initramfs-tools.postinst
vendored
@ -7,8 +7,13 @@ if [ "x$1" != xtriggered ]; then
|
||||
# this activates the trigger, if triggers are working
|
||||
update-initramfs -u
|
||||
else
|
||||
# force it to actually happen
|
||||
DPKG_MAINTSCRIPT_PACKAGE='' update-initramfs -u
|
||||
# The /run/update-initramfs.dpkg-trigger file is just a workaround.
|
||||
# The timestamp should be provided directly by the dpkg trigger.
|
||||
# See https://bugs.debian.org/1099136
|
||||
timestamp=$(stat -c %Y /run/update-initramfs.dpkg-trigger 2>/dev/null || true)
|
||||
# force it to actually happen (if not already updated since activation)
|
||||
DPKG_MAINTSCRIPT_PACKAGE='' update-initramfs -u -s "$timestamp"
|
||||
rm -f /run/update-initramfs.dpkg-trigger
|
||||
fi
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
@ -14,6 +14,10 @@ set -e
|
||||
if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ] && [ $# = 1 ] && [ "$1" = -u ]; then
|
||||
if dpkg-trigger --no-await update-initramfs; then
|
||||
echo "update-initramfs: deferring update (trigger activated)"
|
||||
# The /run/update-initramfs.dpkg-trigger file is just a workaround.
|
||||
# The timestamp should be provided directly by the dpkg trigger.
|
||||
# See https://bugs.debian.org/1099136
|
||||
touch /run/update-initramfs.dpkg-trigger
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user