debian/extra/kernel-install.d/85-initrd.install: install default initrd with versioned basename, prefix postinst hook with zz-
Companion MR to bug: #1020396. Only the second patch is really necessary, but the first would be really nice too.
85-initrd.install was naively fixed in #970213 to only install the generated as the standard "initrd" fallback if none was passed, because otherwise it was duplicated as both "initrd" and "initrd-$KVER": this was fine at the time
debian/extra/kernel/post{inst,rm}.d/systemd-boot (74127387) and debian/extra/initramfs/post-update.d/systemd-boot (9a6d87f1) were added as part of #826045 to integrate with bootctl
But kernel/postinst runs kernel-install add "$1" "$2"
and initramfs/post-update runs kernel-install add "$1" "/boot/vmlinuz-$1" "$2"
The former installs:
/boot/efi/HASH/5.16.0-1-amd64/linux
/boot/efi/HASH/5.16.0-1-amd64/initrd
and the latter installs:
/boot/efi/HASH/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
/boot/efi/HASH/5.16.0-1-amd64/linux
So if both run, and they will on most installations, you get:
/boot/efi/HASH/5.16.0-1-amd64/initrd.img-5.16.0-1-amd64
/boot/efi/HASH/5.16.0-1-amd64/linux
/boot/efi/HASH/5.16.0-1-amd64/initrd
I.e. the initrd is duplicated, i.e. it's exactly what I was trying to avoid in #970213.
By using $KERNEL_INSTALL_STAGING_AREA
, available since systemd v251: https://github.com/systemd/systemd/commit/367165a4069ac0c04882a05a8a80f6afb1e42760; by just copying the file there we both simplify our code, defer to 90-loaderentry to correctly permission it, and simply never generate an unversioned initrd in the first place!
Transcript of installation:
nabijaczleweli@szarotka:/tmp$ kernel-install -v add $(uname -r) /boot/vmlinuz-$(uname -r)
Reading /usr/lib/kernel/install.conf…
BOOT_ROOT=/tmp/br set via environment or install.conf
machine-id adc518602b20465e982dd9c8266a32e3 acquired from /etc/machine-id
Entry-token candidates: adc518602b20465e982dd9c8266a32e3 debian Default
/tmp/br/adc518602b20465e982dd9c8266a32e3 not found…
/tmp/br/loader/entries not found…
/tmp/br/debian exists, using BOOT_ROOT=/tmp/br, ENTRY_TOKEN=debian
/tmp/br/debian exists, using layout=bls
Using ENTRY_DIR_ABS=/tmp/br/debian/5.19.0-1-amd64
Plugin files:
/usr/lib/kernel/install.d/50-depmod.install
/usr/lib/kernel/install.d/85-initrd.install
/usr/lib/kernel/install.d/90-loaderentry.install
+mkdir -v -p /tmp/br/debian/5.19.0-1-amd64
mkdir: created directory '/tmp/br/debian/5.19.0-1-amd64'
+/usr/lib/kernel/install.d/50-depmod.install add 5.19.0-1-amd64 /tmp/br/debian/5.19.0-1-amd64 /boot/vmlinuz-5.19.0-1-amd64
+depmod -a 5.19.0-1-amd64
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.dep.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.dep.bin.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.alias.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.alias.bin.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.softdep.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.symbols.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.symbols.bin.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.builtin.bin.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.builtin.alias.bin.8634.949744.1663726104, 301, 644): Permission denied
depmod: ERROR: openat(/lib/modules/5.19.0-1-amd64, modules.devname.8634.949744.1663726104, 301, 644): Permission denied
+/usr/lib/kernel/install.d/85-initrd.install add 5.19.0-1-amd64 /tmp/br/debian/5.19.0-1-amd64 /boot/vmlinuz-5.19.0-1-amd64
Installing '/boot/initrd.img-5.19.0-1-amd64'
+/usr/lib/kernel/install.d/90-loaderentry.install add 5.19.0-1-amd64 /tmp/br/debian/5.19.0-1-amd64 /boot/vmlinuz-5.19.0-1-amd64
chown: changing ownership of '/tmp/br/debian/5.19.0-1-amd64/linux': Operation not permitted
Installing /tmp/br/debian/5.19.0-1-amd64/initrd.img-5.19.0-1-amd64
chown: changing ownership of '/tmp/br/debian/5.19.0-1-amd64/initrd.img-5.19.0-1-amd64': Operation not permitted
Creating /tmp/br/loader/entries/debian-5.19.0-1-amd64.conf