diff --git a/rust/agama-autoinstall/src/main.rs b/rust/agama-autoinstall/src/main.rs index ccb2c02a77..15a4b721a6 100644 --- a/rust/agama-autoinstall/src/main.rs +++ b/rust/agama-autoinstall/src/main.rs @@ -18,12 +18,16 @@ // To contact SUSE LLC about this file by physical or electronic mail, you may // find current contact information at www.suse.com. -use std::str::FromStr; +use std::{process::exit, str::FromStr, time::Duration}; use agama_autoinstall::{ConfigAutoLoader, ScriptsRunner}; use agama_lib::{auth::AuthToken, http::BaseHTTPClient, manager::ManagerHTTPClient}; -use agama_utils::{api::FinishMethod, kernel_cmdline::KernelCmdline}; +use agama_utils::{ + api::{status::Stage, FinishMethod}, + kernel_cmdline::KernelCmdline, +}; use anyhow::anyhow; +use tokio::time::sleep; const API_URL: &str = "http://localhost/api"; @@ -68,8 +72,30 @@ async fn main() -> anyhow::Result<()> { } } + // wait till config is properly set. + loop { + sleep(Duration::from_secs(1)).await; + let status = manager_client.status().await?; + if status.progresses.is_empty() { + break; + } + } + manager_client.install().await?; + // wait till install is done. + loop { + sleep(Duration::from_secs(1)).await; + let status = manager_client.status().await?; + if status.stage == Stage::Finished { + break; + } + if status.stage == Stage::Failed { + eprintln!("Installation failed"); + exit(1); + } + } + let method = args .get("inst.finish") .first() diff --git a/rust/agama-cli/src/error.rs b/rust/agama-cli/src/error.rs index cd79421bb5..b2afcb357a 100644 --- a/rust/agama-cli/src/error.rs +++ b/rust/agama-cli/src/error.rs @@ -27,8 +27,6 @@ pub enum CliError { Validation, #[error("Could not start the installation")] Installation, - #[error("The installation has not finished correctly")] - NotFinished, #[error("Could not read the password")] InteractivePassword(#[source] InquireError), #[error("Could not read the password from the standard input")] diff --git a/rust/agama-cli/src/lib.rs b/rust/agama-cli/src/lib.rs index 55585e661e..6487364019 100644 --- a/rust/agama-cli/src/lib.rs +++ b/rust/agama-cli/src/lib.rs @@ -35,7 +35,7 @@ use agama_lib::{ monitor::{Monitor, MonitorClient}, }; use agama_transfer::Transfer; -use agama_utils::api::{self, status::Stage, FinishMethod, IssueWithScope}; +use agama_utils::api::{status::Stage, FinishMethod, IssueWithScope}; use anyhow::Context; use clap::{Args, Parser}; use fluent_uri::UriRef; @@ -121,8 +121,8 @@ async fn install(http_client: BaseHTTPClient, monitor: MonitorClient) -> anyhow: return Err(CliError::Validation)?; } - let action = api::Action::Install; - http_client.post_void("/v2/action", &action).await?; + let manager = ManagerHTTPClient::new(http_client); + manager.install().await?; // wait a bit before start monitoring sleep(Duration::from_secs(1)).await; @@ -145,10 +145,7 @@ async fn finish( ) -> anyhow::Result<()> { wait_until_idle(monitor.clone()).await?; - if !manager.finish(method).await? { - eprintln!("Cannot finish the installation ({method})"); - return Err(CliError::NotFinished)?; - } + manager.finish(method).await?; Ok(()) } diff --git a/rust/agama-lib/src/manager/http_client.rs b/rust/agama-lib/src/manager/http_client.rs index 5d9fa0cb57..e16e931e86 100644 --- a/rust/agama-lib/src/manager/http_client.rs +++ b/rust/agama-lib/src/manager/http_client.rs @@ -21,8 +21,8 @@ use crate::{ http::{BaseHTTPClient, BaseHTTPClientError}, logs::LogsLists, - manager::InstallerStatus, }; +use agama_utils::api::{self, Status}; use reqwest::header::CONTENT_ENCODING; use std::path::{Path, PathBuf}; use std::{fs, io::Cursor, os::unix::fs::OpenOptionsExt}; @@ -61,15 +61,18 @@ impl ManagerHTTPClient { /// Starts the installation. pub async fn install(&self) -> Result<(), ManagerHTTPClientError> { - Ok(self.client.post_void("/manager/install", &()).await?) + let action = api::Action::Install; + self.client.post_void("/v2/action", &action).await?; + Ok(()) } /// Finishes the installation. /// /// * `method`: halt, reboot, stop or poweroff the system. - pub async fn finish(&self, method: FinishMethod) -> Result { - let method = Some(method); - Ok(self.client.post("/manager/finish", &method).await?) + pub async fn finish(&self, method: FinishMethod) -> Result<(), ManagerHTTPClientError> { + let action = api::Action::Finish(method); + self.client.post_void("/v2/action", &action).await?; + Ok(()) } /// Downloads package of logs from the backend @@ -123,11 +126,8 @@ impl ManagerHTTPClient { } /// Returns the installer status. - pub async fn status(&self) -> Result { - let status = self - .client - .get::("/manager/installer") - .await?; + pub async fn status(&self) -> Result { + let status = self.client.get::("/v2/status").await?; Ok(status) } } diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 41d49f23b6..4cf5d696be 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Jan 16 15:01:32 UTC 2026 - Josef Reidinger + +- Fix unattended installation +- Add first user to wheel group +- Implement using inst.install_url instead of Product repositories + ------------------------------------------------------------------- Wed Jan 14 23:27:16 UTC 2026 - Imobach Gonzalez Sosa