mirror of
https://git.proxmox.com/git/proxmox-kernel-helper
synced 2025-10-04 08:21:14 +00:00
boot-tool: disarm upstream systemd-boot hookscripts
With Debian Bookworm systemd-boot is a separate binary-package, instead of part of the main systemd package. Since it's not installed by default, Debian-upstream has added hook-scripts to the package, which manage kernel copying to the esp (kernel-install). The hookscripts print a warning if the ESP is not mounted at $SYSTEMD_ESP_PATH or /boot/efi, /efi or /boot - through `bootctl is-installed --quiet` [0,1]. This patch adds a function, which disables the hookscripts from upstream if /etc/kernel/proxmox-boot-uuids is present. It adds an explanation as marker and 'exit 0' on top of the script, so that users know why the scripts were touched (e.g. when a new systemd-boot hookscript version from upstream asks what to do with the local modifications) While editing shell-script hooks from other packages is quite brittle it still seems like the best option, to support most use-cases (including users, who don't use proxmox-boot-tool, but want to manually install systemd-boot). Alternatives considered: * dpkg-divert for all hookscripts - sadly the Debian policy manual warns against this * adding Replaces: systemd-boot to d/control - afaict this would need systemd-boot to also declare this for proxmox-kernel-helper [3] Tested on 2 VMs installed with the 8.0 ISO (once with legacy once with uefi boot) [0]8a38b62f37/src/shared/find-esp.c (L503)
[1]8a38b62f37/src/boot/bootctl.c (L90)
[2] https://www.debian.org/doc/debian-policy/ap-pkg-diversions.html [3] https://www.debian.org/doc/debian-policy/ch-relationships.html Reported-by: Aaron Lauterer <a.lauterer@proxmox.com> Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com> [T: avoid potential false exit code, use if ] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
47b6607049
commit
a3c1ce92db
@ -191,6 +191,28 @@ remove_old_kernels_legacy() {
|
||||
|
||||
}
|
||||
|
||||
disable_systemd_boot_hook() {
|
||||
|
||||
if [ ! -f "${ESP_LIST}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
marker="# This hookfile has been disabled by proxmox-boot-tool"
|
||||
for hookfile in \
|
||||
"/etc/initramfs/post-update.d/systemd-boot" \
|
||||
"/etc/kernel/postinst.d/zz-systemd-boot" \
|
||||
"/etc/kernel/postrm.d/zz-systemd-boot" ; \
|
||||
do
|
||||
if ! grep -q "$marker" "$hookfile"; then
|
||||
warn " Disabling upstream hook $hookfile"
|
||||
printf "#!/bin/sh\n\n%s\nexit 0\n" "$marker" > "$hookfile.pbt.tmp"
|
||||
cat "$hookfile" >> "$hookfile.pbt.tmp"
|
||||
mv "$hookfile.pbt.tmp" "$hookfile"
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
set -- $DEB_MAINT_PARAMS
|
||||
mode="${1#\'}"
|
||||
mode="${mode%\'}"
|
||||
@ -203,12 +225,14 @@ case $0:$mode in
|
||||
reexec_in_mountns "$@"
|
||||
BOOT_KVERS="$(boot_kernel_list "$@")"
|
||||
update_esps
|
||||
disable_systemd_boot_hook
|
||||
;;
|
||||
*/postrm.d/*:|*/postrm.d/*:remove)
|
||||
reexec_in_mountns "$@"
|
||||
# no newly installed kernel
|
||||
BOOT_KVERS="$(boot_kernel_list)"
|
||||
update_esps
|
||||
disable_systemd_boot_hook
|
||||
;;
|
||||
esac
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user