From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 25A608607 for ; Wed, 21 Jun 2023 16:32:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0F2121F414 for ; Wed, 21 Jun 2023 16:32:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 21 Jun 2023 16:32:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1BF6E4261E for ; Wed, 21 Jun 2023 16:32:55 +0200 (CEST) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Wed, 21 Jun 2023 16:32:25 +0200 Message-Id: <20230621143227.1510250-2-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621143227.1510250-1-s.ivanov@proxmox.com> References: <20230621143227.1510250-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.098 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH 1/3] boot-tool: disarm upstream systemd-boot hookscripts X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2023 14:32:56 -0000 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] https://github.com/systemd/systemd/blob/8a38b62f37189b071a30f208530ce5dc278e521e/src/shared/find-esp.c#L503 [1] https://github.com/systemd/systemd/blob/8a38b62f37189b071a30f208530ce5dc278e521e/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 Signed-off-by: Stoiko Ivanov --- src/proxmox-boot/zz-proxmox-boot | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/proxmox-boot/zz-proxmox-boot b/src/proxmox-boot/zz-proxmox-boot index c6c708c..c72f9ef 100755 --- a/src/proxmox-boot/zz-proxmox-boot +++ b/src/proxmox-boot/zz-proxmox-boot @@ -191,6 +191,27 @@ 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 + grep -q "$marker" "$hookfile" && continue + 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" + done + +} + set -- $DEB_MAINT_PARAMS mode="${1#\'}" mode="${mode%\'}" @@ -203,12 +224,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 -- 2.30.2