From 53200215c3200bcf3110ae264efe3bbaf14ef6e0 Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Sun, 17 Nov 2024 23:31:00 -0300 Subject: [PATCH] feat(bootc): add Bootc support + docs Co-authored-by: Steve Lau --- config.example.toml | 5 +++++ src/config.rs | 10 ++++++++++ src/steps/os/linux.rs | 14 +++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 080f53ac..ddbddd22 100644 --- a/config.example.toml +++ b/config.example.toml @@ -172,6 +172,11 @@ # rpm_ostree = false +# For Fedora/CentOS/RHEL Atomic variants, if `bootc` is available and this configuration entry is set to true, use +# it to do the update. +# (default: false) +# bootc = false + # nix_arguments = "--flake" # nix_env_arguments = "--prebuilt-only" diff --git a/src/config.rs b/src/config.rs index eab7b336..62e3dc02 100644 --- a/src/config.rs +++ b/src/config.rs @@ -358,6 +358,7 @@ pub struct Linux { redhat_distro_sync: Option, suse_dup: Option, rpm_ostree: Option, + bootc: Option, #[merge(strategy = crate::utils::merge_strategies::string_append_opt)] emerge_sync_flags: Option, @@ -1457,6 +1458,15 @@ impl Config { .unwrap_or(false) } + /// Use bootc in *when bootc is detected* (default: false) + pub fn bootc(&self) -> bool { + self.config_file + .linux + .as_ref() + .and_then(|linux| linux.bootc) + .unwrap_or(false) + } + /// Determine if we should ignore failures for this step pub fn ignore_failure(&self, step: Step) -> bool { self.config_file diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 80430006..b2b502bf 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -225,7 +225,12 @@ fn upgrade_wolfi_linux(ctx: &ExecutionContext) -> Result<()> { } fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> { - if let Some(ostree) = which("rpm-ostree") { + if let Some(bootc) = which("bootc") { + if ctx.config().bootc() { + let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?; + return ctx.run_type().execute(sudo).arg(&bootc).arg("upgrade").status_checked(); + } + } else if let Some(ostree) = which("rpm-ostree") { if ctx.config().rpm_ostree() { let mut command = ctx.run_type().execute(ostree); command.arg("upgrade"); @@ -298,6 +303,13 @@ fn upgrade_nilrt(ctx: &ExecutionContext) -> Result<()> { } fn upgrade_fedora_immutable(ctx: &ExecutionContext) -> Result<()> { + if let Some(bootc) = which("bootc") { + if ctx.config().bootc() { + let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?; + return ctx.run_type().execute(sudo).arg(&bootc).arg("upgrade").status_checked(); + } + } + let ostree = require("rpm-ostree")?; let mut command = ctx.run_type().execute(ostree); command.arg("upgrade");