all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/3] pbs3to4: bootloader: only allow systemd-boot before upgrade when used
Date: Mon, 18 Aug 2025 21:40:26 +0200	[thread overview]
Message-ID: <20250818194026.840749-4-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20250818194026.840749-1-s.ivanov@proxmox.com>

This carries over the changes from pve-manager:
7e168453 ("pve8to9: only allow systemd-boot when it is actually used before upgrade")

additionally it pushes the check for systemd-boot being present to the
bottom (there is an early return for the single case which is not
problematic (used by p-b-t on a system still on bookworm) - and logs a
failure with a link to the upgrade guide in all cases.
The previous suggestion of installing systemd-boot-tools and
systemd-boot-efi explicitly is not fitting when systemd-boot is not
really used for booting (mostly: secure-boot enabled p-b-t setups)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/bin/pbs3to4.rs | 61 +++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git a/src/bin/pbs3to4.rs b/src/bin/pbs3to4.rs
index e700c832..e3cd43c9 100644
--- a/src/bin/pbs3to4.rs
+++ b/src/bin/pbs3to4.rs
@@ -206,11 +206,12 @@ impl Checker {
         self.output
             .log_info("Checking bootloader configuration...")?;
 
-        let sd_boot_installed = Path::new("/usr/share/doc/systemd-boot/changelog.Debian.gz").is_file();
+        let sd_boot_installed =
+            Path::new("/usr/share/doc/systemd-boot/changelog.Debian.gz").is_file();
 
         if !Path::new("/sys/firmware/efi").is_dir() {
             if sd_boot_installed {
-                self.output.log_info(
+                self.output.log_warn(
                     "systemd-boot package installed on legacy-boot system is not \
                     necessary, consider removing it",
                 )?;
@@ -225,29 +226,25 @@ impl Checker {
         if Path::new("/etc/kernel/proxmox-boot-uuids").is_file() {
             // PBS packages version check needs to be run before
             if !self.upgraded {
-                self.output
-                    .log_skip("not yet upgraded, systemd-boot still needed for bootctl")?;
-                return Ok(());
-            }
-            if sd_boot_installed {
-                self.output.log_fail(
-                    "systemd-boot meta-package installed. This will cause issues on upgrades of \
-                    boot-related packages.\n\
-                    Install 'systemd-boot-efi' and 'systemd-boot-tools' explicitly and remove \
-                    'systemd-boot'",
-                )?;
-                return Ok(());
+                let mut sd_boot_used = false;
+                let output = std::process::Command::new("proxmox-boot-tool")
+                    .arg("status")
+                    .output()
+                    .map_err(|err| {
+                        format_err!("failed to retrieve proxmox-boot-tool status - {err}")
+                    })?;
+                let re = Regex::new(r"configured with:.* (uefi|systemd-boot) \(versions:")
+                    .expect("failed to proxmox-boot-tool status");
+                if !re.is_match(std::str::from_utf8(&output.stdout)?) {
+                    sd_boot_used = true;
+                }
+                if sd_boot_used {
+                    self.output
+                        .log_skip("not yet upgraded, systemd-boot still needed for bootctl")?;
+                    return Ok(());
+                }
             }
         } else {
-            if sd_boot_installed {
-                self.output.log_fail(
-                    "systemd-boot meta-package installed. This will cause problems on upgrades of other \
-                    boot-related packages.\n\
-                    Remove the 'systemd-boot' package.\n\
-                    See https://pbs.proxmox.com/wiki/Upgrade_from_3_to_4#sd-boot-warning for more information."
-                )?;
-                boot_ok = false;
-            }
             if !Path::new("/usr/share/doc/grub-efi-amd64/changelog.Debian.gz").is_file() {
                 self.output.log_warn(
                     "System booted in uefi mode but grub-efi-amd64 meta-package not installed, \
@@ -276,12 +273,20 @@ impl Checker {
                     boot_ok = false;
                 }
             }
-            if boot_ok {
-                self.output
-                    .log_pass("bootloader packages installed correctly")?;
-            }
         }
-
+        if sd_boot_installed {
+            self.output.log_fail(
+                "systemd-boot meta-package installed. This will cause problems on upgrades of other \
+                boot-related packages.\n\
+                Remove the 'systemd-boot' package.\n\
+                See https://pbs.proxmox.com/wiki/Upgrade_from_3_to_4#sd-boot-warning for more information."
+            )?;
+            boot_ok = false;
+        }
+        if boot_ok {
+            self.output
+                .log_pass("bootloader packages installed correctly")?;
+        }
         Ok(())
     }
 
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2025-08-18 19:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-18 19:40 [pbs-devel] [PATCH proxmox-backup 0/3] pbs3to4: rework bootloader checks Stoiko Ivanov
2025-08-18 19:40 ` [pbs-devel] [PATCH proxmox-backup 1/3] pbs3to4: fix logic error and typo in log message Stoiko Ivanov
2025-08-18 19:40 ` [pbs-devel] [PATCH proxmox-backup 2/3] pbs3to4: use boolean variable for systemd-boot installation state Stoiko Ivanov
2025-08-18 19:40 ` Stoiko Ivanov [this message]
2025-08-21 14:18 ` [pbs-devel] superseded: [PATCH proxmox-backup 0/3] pbs3to4: rework bootloader checks Stoiko Ivanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250818194026.840749-4-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal