diff --git a/rust/agama-autoinstall/src/main.rs b/rust/agama-autoinstall/src/main.rs index 15a4b721a6..348301873b 100644 --- a/rust/agama-autoinstall/src/main.rs +++ b/rust/agama-autoinstall/src/main.rs @@ -18,14 +18,11 @@ // To contact SUSE LLC about this file by physical or electronic mail, you may // find current contact information at www.suse.com. -use std::{process::exit, str::FromStr, time::Duration}; +use std::{process::exit, time::Duration}; use agama_autoinstall::{ConfigAutoLoader, ScriptsRunner}; use agama_lib::{auth::AuthToken, http::BaseHTTPClient, manager::ManagerHTTPClient}; -use agama_utils::{ - api::{status::Stage, FinishMethod}, - kernel_cmdline::KernelCmdline, -}; +use agama_utils::{api::status::Stage, kernel_cmdline::KernelCmdline}; use anyhow::anyhow; use tokio::time::sleep; @@ -96,12 +93,7 @@ async fn main() -> anyhow::Result<()> { } } - let method = args - .get("inst.finish") - .first() - .and_then(|m| FinishMethod::from_str(m).ok()) - .unwrap_or_default(); - manager_client.finish(method).await?; + manager_client.finish(None).await?; Ok(()) } diff --git a/rust/agama-cli/src/commands.rs b/rust/agama-cli/src/commands.rs index c36622dee9..b7a40a57d5 100644 --- a/rust/agama-cli/src/commands.rs +++ b/rust/agama-cli/src/commands.rs @@ -111,12 +111,13 @@ pub enum Commands { /// /// stop - do not reboot and the Agama backend continues running. /// - /// reboot - reboot into the installed system. + /// reboot - reboot into the installed system. This value is the + /// default. It can be overriden by setting the inst.finish + /// kernel command-line argument. /// /// halt - halt the installed machine. /// /// poweroff - power off the installed machine. - #[clap(default_value = "reboot")] method: Option, }, diff --git a/rust/agama-cli/src/lib.rs b/rust/agama-cli/src/lib.rs index 4c78ad7d3b..9f1272f1b9 100644 --- a/rust/agama-cli/src/lib.rs +++ b/rust/agama-cli/src/lib.rs @@ -143,7 +143,7 @@ async fn install(http_client: BaseHTTPClient, monitor: MonitorClient) -> anyhow: async fn finish( manager: ManagerHTTPClient, monitor: MonitorClient, - method: FinishMethod, + method: Option, ) -> anyhow::Result<()> { wait_until_idle(monitor.clone()).await?; @@ -299,7 +299,6 @@ pub async fn run_command(cli: Cli) -> anyhow::Result<()> { let (client, monitor) = build_clients(api_url, cli.opts.insecure).await?; let manager = ManagerHTTPClient::new(client.clone()); let _ = wait_until_idle(monitor.clone()).await; - let method = method.unwrap_or_default(); finish(manager, monitor, method).await?; } Commands::Questions(subcommand) => { diff --git a/rust/agama-lib/src/manager/http_client.rs b/rust/agama-lib/src/manager/http_client.rs index 5111854e2a..a14d1426b2 100644 --- a/rust/agama-lib/src/manager/http_client.rs +++ b/rust/agama-lib/src/manager/http_client.rs @@ -67,7 +67,7 @@ impl ManagerHTTPClient { /// Finishes the installation. /// /// * `method`: halt, reboot, stop or poweroff the system. - pub async fn finish(&self, method: FinishMethod) -> Result<(), ManagerHTTPClientError> { + pub async fn finish(&self, method: Option) -> Result<(), ManagerHTTPClientError> { let action = api::Action::Finish(method); self.client.post_void("/v2/action", &action).await?; Ok(()) diff --git a/rust/agama-manager/src/service.rs b/rust/agama-manager/src/service.rs index 9dd81af502..6c1f1b6f05 100644 --- a/rust/agama-manager/src/service.rs +++ b/rust/agama-manager/src/service.rs @@ -32,7 +32,9 @@ use agama_utils::{ Action, Config, Event, FinishMethod, Issue, IssueMap, Proposal, Scope, Status, SystemInfo, }, arch::Arch, - issue, licenses, + issue, + kernel_cmdline::KernelCmdline, + licenses, products::{self, ProductSpec}, progress, question, }; @@ -40,7 +42,7 @@ use async_trait::async_trait; use merge::Merge; use network::NetworkSystemClient; use serde_json::Value; -use std::{collections::HashMap, process::Command, sync::Arc}; +use std::{collections::HashMap, process::Command, str::FromStr, sync::Arc}; use tokio::sync::{broadcast, RwLock}; #[derive(Debug, thiserror::Error)] @@ -884,16 +886,26 @@ impl MessageHandler for Service { /// Implements the finish action. struct FinishAction { - method: FinishMethod, + method: Option, } impl FinishAction { - pub fn new(method: FinishMethod) -> Self { + pub fn new(method: Option) -> Self { Self { method } } pub fn run(self) { - let option = match self.method { + let method = self.method.unwrap_or_else(|| { + let inst_finish_method = KernelCmdline::parse() + .ok() + .and_then(|a| a.get_last("inst.finish")) + .and_then(|m| FinishMethod::from_str(&m).ok()); + inst_finish_method.unwrap_or_default() + }); + + tracing::info!("Finishing the installation process ({})", method); + + let option = match method { FinishMethod::Halt => Some("-H"), FinishMethod::Reboot => Some("-r"), FinishMethod::Poweroff => Some("-P"), @@ -904,7 +916,6 @@ impl FinishAction { if let Some(switch) = option { command.arg(switch); } else { - tracing::info!("Stopped as requested"); return; } diff --git a/rust/agama-utils/src/api/action.rs b/rust/agama-utils/src/api/action.rs index 8da323024f..ca29f8cf46 100644 --- a/rust/agama-utils/src/api/action.rs +++ b/rust/agama-utils/src/api/action.rs @@ -38,7 +38,7 @@ pub enum Action { #[serde(rename = "install")] Install, #[serde(rename = "finish")] - Finish(FinishMethod), + Finish(Option), } /// Finish method @@ -58,13 +58,13 @@ pub enum Action { #[strum(serialize_all = "camelCase")] #[serde(rename_all = "camelCase")] pub enum FinishMethod { - // Halt the system + /// Halt the system Halt, - // Reboots the system + /// Reboots the system #[default] Reboot, - // Do nothing at the end of the installation + /// Do nothing at the end of the installation Stop, - // Poweroff the system + /// Poweroff the system Poweroff, } diff --git a/rust/package/agama.changes b/rust/package/agama.changes index edf88d50ea..f16735dd61 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Mar 6 10:28:09 UTC 2026 - Imobach Gonzalez Sosa + +- Honor inst.finish in interactive installation (jsc#PED-15031). + ------------------------------------------------------------------- Thu Mar 5 15:27:13 UTC 2026 - Imobach Gonzalez Sosa