diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 87289cef7e..ac170bce1d 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -19,6 +19,7 @@ dependencies = [ "anyhow", "tempfile", "tokio", + "tracing", "url", ] @@ -246,14 +247,11 @@ dependencies = [ "anyhow", "async-trait", "gettext-rs", - "libsystemd", "strum", "tempfile", "thiserror 2.0.18", "tokio", "tracing", - "tracing-journald", - "tracing-subscriber", ] [[package]] @@ -314,7 +312,6 @@ dependencies = [ "http-body-util", "hyper 1.8.1", "hyper-util", - "libsystemd", "openssl", "pam", "pin-project", @@ -332,8 +329,6 @@ dependencies = [ "tower", "tower-http", "tracing", - "tracing-journald", - "tracing-subscriber", "url", "utoipa", "zbus", @@ -430,12 +425,14 @@ version = "0.1.0" dependencies = [ "agama-locale-data", "agama-transfer", + "anyhow", "async-trait", "camino", "cidr", "fluent-uri 0.4.1", "fs-err", "gettext-rs", + "libsystemd", "macaddr", "merge", "regex", @@ -450,6 +447,8 @@ dependencies = [ "tokio", "tokio-test", "tracing", + "tracing-journald", + "tracing-subscriber", "url", "utoipa", "uuid", diff --git a/rust/agama-autoinstall/Cargo.toml b/rust/agama-autoinstall/Cargo.toml index eaa74df14e..58f7da3a89 100644 --- a/rust/agama-autoinstall/Cargo.toml +++ b/rust/agama-autoinstall/Cargo.toml @@ -11,5 +11,6 @@ agama-transfer = { path = "../agama-transfer" } anyhow = { version = "1.0.98" } tempfile = "3.20.0" tokio = "1.46.0" +tracing = "0.1.44" url = "2.5.4" agama-l10n = { path = "../agama-l10n" } diff --git a/rust/agama-autoinstall/src/auto_loader.rs b/rust/agama-autoinstall/src/auto_loader.rs index 1c5921e85c..b8838cd053 100644 --- a/rust/agama-autoinstall/src/auto_loader.rs +++ b/rust/agama-autoinstall/src/auto_loader.rs @@ -23,10 +23,16 @@ use agama_lib::http::BaseHTTPClient; use anyhow::anyhow; /// List of pre-defined locations for profiles. -const PREDEFINED_LOCATIONS: [&str; 6] = [ +const PREDEFINED_LOCATIONS: [&str; 9] = [ + // OEM drive (pre-installed systems) "label://OEMDRV/autoinst.jsonnet", "label://OEMDRV/autoinst.json", "label://OEMDRV/autoinst.xml", + // root of the installation medium + "file:///run/initramfs/live/autoinst.jsonnet", + "file:///run/initramfs/live/autoinst.json", + "file:///run/initramfs/live/autoinst.xml", + // root filesystem (squashfs image) "file:///autoinst.jsonnet", "file:///autoinst.json", "file:///autoinst.xml", @@ -75,14 +81,14 @@ impl ConfigAutoLoader { /// Loads configuration files specified by the user. async fn load_user_config(&self, loader: ConfigLoader, urls: &[String]) -> anyhow::Result<()> { for url in urls { - println!("Loading configuration from {url}"); + tracing::info!("Loading configuration from {url}"); while let Err(error) = loader.load(url).await { - eprintln!("Could not load configuration from {url}: {error}"); + tracing::error!("Could not load configuration from {url}: {error}"); if !self.should_retry(url, &error.to_string()).await? { return Err(error); } } - println!("Configuration loaded from {url}"); + tracing::info!("Configuration loaded from {url}"); } Ok(()) } @@ -92,10 +98,10 @@ impl ConfigAutoLoader { for url in PREDEFINED_LOCATIONS { match loader.load(url).await { Ok(()) => { - println!("Configuration loaded from {url}"); + tracing::info!("Configuration loaded from {url}"); return Ok(()); } - Err(_) => println!("Could not load the configuration from {url}"), + Err(_) => tracing::info!("No config loaded from {url}"), } } Err(anyhow!("No configuration was found")) diff --git a/rust/agama-autoinstall/src/main.rs b/rust/agama-autoinstall/src/main.rs index def378c937..4ed9df2163 100644 --- a/rust/agama-autoinstall/src/main.rs +++ b/rust/agama-autoinstall/src/main.rs @@ -25,8 +25,10 @@ use agama_lib::{auth::AuthToken, http::BaseHTTPClient, manager::ManagerHTTPClien use agama_utils::{ api::{status::Stage, FinishMethod}, kernel_cmdline::KernelCmdline, + logging::init_logging, }; use anyhow::anyhow; +use anyhow::Context; use tokio::time::sleep; const API_URL: &str = "http://localhost/api"; @@ -43,6 +45,8 @@ pub fn insecure_from(cmdline: &KernelCmdline, key: &str) -> bool { #[tokio::main] async fn main() -> anyhow::Result<()> { + init_logging().context("Could not initialize the logger")?; + let args = KernelCmdline::parse()?; let http = build_base_client()?; let manager_client = ManagerHTTPClient::new(http.clone()); @@ -51,9 +55,9 @@ async fn main() -> anyhow::Result<()> { let script_insecure = insecure_from(&args, "inst.script_insecure"); let mut runner = ScriptsRunner::new(http.clone(), "/run/agama/inst-scripts", script_insecure); for url in scripts { - println!("Running script from {}", &url); + tracing::info!("Running script from {}", &url); if let Err(error) = runner.run(&url).await { - eprintln!("Error running the script from {url}: {}", error); + tracing::error!("Error running the script from {url}: {}", error); } } @@ -61,17 +65,23 @@ async fn main() -> anyhow::Result<()> { let loader = ConfigAutoLoader::new(http.clone(), auto_insecure)?; let urls = args.get("inst.auto"); if let Err(error) = loader.load(&urls).await { - eprintln!("Skipping the auto-installation: {error}"); + if urls.is_empty() { + tracing::info!("No configuration found in the predefined locations"); + return Ok(()); + } + + tracing::error!("Skipping the auto-installation: {error}"); return Ok(()); } if let Some(should_install) = args.get("inst.install").first() { if should_install == "0" { - println!("Skipping the auto-installation on user's request (inst.install=0)"); + tracing::info!("Not starting the auto-installation on user's request (inst.install=0)"); return Ok(()); } } + tracing::info!("Waiting for the installer to get ready"); // wait till config is properly set. loop { sleep(Duration::from_secs(1)).await; @@ -81,6 +91,7 @@ async fn main() -> anyhow::Result<()> { } } + tracing::info!("Starting the auto-installation"); manager_client.install().await?; // wait till install is done. @@ -91,7 +102,7 @@ async fn main() -> anyhow::Result<()> { break; } if status.stage == Stage::Failed { - eprintln!("Installation failed"); + tracing::error!("Installation failed"); exit(1); } } diff --git a/rust/agama-lib/Cargo.toml b/rust/agama-lib/Cargo.toml index e4c9d1fe2f..c37bb6ceac 100644 --- a/rust/agama-lib/Cargo.toml +++ b/rust/agama-lib/Cargo.toml @@ -20,7 +20,7 @@ tempfile = "3.13.0" thiserror = "2.0.12" tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] } tokio-stream = "0.1.16" -tracing = "0.1.40" +tracing = "0.1.44" url = { version = "2.5.2", features = ["serde"] } utoipa = { version = "5.2.0", features = ["url"] } zbus = { version = "5", default-features = false, features = ["tokio"] } diff --git a/rust/agama-proxy/Cargo.toml b/rust/agama-proxy/Cargo.toml index 2e7e855822..869bf8698f 100644 --- a/rust/agama-proxy/Cargo.toml +++ b/rust/agama-proxy/Cargo.toml @@ -9,12 +9,9 @@ agama-utils = { version = "0.1.0", path = "../agama-utils" } anyhow = "1.0.100" async-trait = "0.1.89" gettext-rs = "0.7.7" -libsystemd = "0.7.2" strum = "0.27.2" thiserror = "2.0.18" tracing = "0.1.44" -tracing-journald = "0.3.2" -tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } [[bin]] name = "agama-proxy-setup" diff --git a/rust/agama-proxy/src/main.rs b/rust/agama-proxy/src/main.rs index 2c62c9b15a..f4c161cdf6 100644 --- a/rust/agama-proxy/src/main.rs +++ b/rust/agama-proxy/src/main.rs @@ -19,37 +19,8 @@ // find current contact information at www.suse.com. use agama_proxy::model::ProxyConfig; +use agama_utils::logging::init_logging; use anyhow::Context; -use libsystemd::logging; -use tracing::level_filters::LevelFilter; -use tracing_subscriber::{prelude::*, EnvFilter}; - -/// Initializes the logging mechanism. -/// -/// It is based on [Tracing](https://github.com/tokio-rs/tracing), part of the Tokio ecosystem. -pub fn init_logging() -> anyhow::Result<()> { - let filter = EnvFilter::builder() - .with_default_directive(LevelFilter::INFO.into()) - .with_env_var("AGAMA_LOG") - .from_env_lossy(); - - if logging::connected_to_journal() { - let journald = tracing_journald::layer().context("could not connect to journald")?; - tracing_subscriber::registry() - .with(filter) - .with(journald) - .init(); - } else { - let subscriber = tracing_subscriber::fmt() - .with_env_filter(filter) - .with_file(true) - .with_line_number(true) - .compact() - .finish(); - tracing::subscriber::set_global_default(subscriber)?; - } - Ok(()) -} fn main() -> Result<(), Box> { init_logging().context("Could not initialize the logger")?; diff --git a/rust/agama-server/Cargo.toml b/rust/agama-server/Cargo.toml index 055852665c..cdaa872d67 100644 --- a/rust/agama-server/Cargo.toml +++ b/rust/agama-server/Cargo.toml @@ -30,8 +30,6 @@ tower-http = { version = "0.6.2", features = [ "trace", "set-header", ] } -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } -tracing-journald = "0.3.0" tracing = "0.1.40" clap = { version = "4.5.19", features = ["derive", "wrap_help"] } tower = { version = "0.5.2", features = ["util"] } @@ -51,7 +49,6 @@ tokio-openssl = "0.6.5" futures-util = { version = "0.3.30", default-features = false, features = [ "alloc", ] } -libsystemd = "0.7.0" gethostname = "1.0.0" tokio-util = "0.7.12" url = "2.5.2" diff --git a/rust/agama-server/src/agama-web-server.rs b/rust/agama-server/src/agama-web-server.rs index f04f3bacfd..73cb1d4f64 100644 --- a/rust/agama-server/src/agama-web-server.rs +++ b/rust/agama-server/src/agama-web-server.rs @@ -28,10 +28,9 @@ use agama_l10n::helpers as l10n_helpers; use agama_lib::{auth::AuthToken, connection_to}; use agama_server::{ cert::Certificate, - logs::init_logging, web::{self}, }; -use agama_utils::api::event::Receiver; +use agama_utils::{api::event::Receiver, logging::init_logging}; use anyhow::Context; use axum::{ extract::Request as AxumRequest, diff --git a/rust/agama-server/src/lib.rs b/rust/agama-server/src/lib.rs index d26506b109..e85189c1b9 100644 --- a/rust/agama-server/src/lib.rs +++ b/rust/agama-server/src/lib.rs @@ -21,7 +21,6 @@ pub mod cert; pub mod dbus; pub mod error; -pub mod logs; pub mod profile; pub mod web; pub use web::service; diff --git a/rust/agama-utils/Cargo.toml b/rust/agama-utils/Cargo.toml index a8758816b7..f177c0b5e0 100644 --- a/rust/agama-utils/Cargo.toml +++ b/rust/agama-utils/Cargo.toml @@ -7,6 +7,7 @@ edition.workspace = true [dependencies] agama-locale-data = { path = "../agama-locale-data" } agama-transfer = { path = "../agama-transfer" } +anyhow = { version = "1.0.98" } async-trait = "0.1.89" camino = "1.2.1" serde = { version = "1.0.228", features = ["derive"] } @@ -20,7 +21,10 @@ zbus = "5.7.1" zvariant = "5.5.2" gettext-rs = { version = "0.7.2", features = ["gettext-system"] } regex = "1.12.2" -tracing = "0.1.41" +libsystemd = "0.7.2" +tracing = "0.1.44" +tracing-journald = "0.3.2" +tracing-subscriber = { version = "0.3.22", features = ["env-filter"] } serde_yaml = "0.9.34" uuid = { version = "1.10.0", features = ["v4"] } cidr = { version = "0.3.1", features = ["serde"] } diff --git a/rust/agama-utils/src/kernel_cmdline.rs b/rust/agama-utils/src/kernel_cmdline.rs index 941c568a65..c35af64cc1 100644 --- a/rust/agama-utils/src/kernel_cmdline.rs +++ b/rust/agama-utils/src/kernel_cmdline.rs @@ -49,7 +49,7 @@ impl KernelCmdline { /// * `content`: file containing the kernel's cmdline arguments. pub fn parse_file>(file: P) -> std::io::Result { let content = std::fs::read_to_string(&file) - .inspect_err(|e| tracing::warn!("Could not read cmdline args file {e}",))?; + .inspect_err(|e| tracing::warn!("Could not read cmdline args file: {e}",))?; Ok(Self::parse_str(&content)) } diff --git a/rust/agama-utils/src/lib.rs b/rust/agama-utils/src/lib.rs index 60569c6df1..10a0ce0d8c 100644 --- a/rust/agama-utils/src/lib.rs +++ b/rust/agama-utils/src/lib.rs @@ -29,6 +29,7 @@ pub mod dbus; pub mod issue; pub mod kernel_cmdline; pub mod licenses; +pub mod logging; pub mod openapi; pub mod products; pub mod progress; diff --git a/rust/agama-server/src/logs.rs b/rust/agama-utils/src/logging.rs similarity index 100% rename from rust/agama-server/src/logs.rs rename to rust/agama-utils/src/logging.rs diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 5cb3e7fbd5..36af300af9 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Apr 7 16:55:22 UTC 2026 - Ladislav Slezák + +- Automatically try loading the autoinstallation profile from the + root of the installation medium (jsc#PED-16010) +- Use journal logging with more details in the autoinstallation + CLI tool (log to stdout when running manually) + ------------------------------------------------------------------- Tue Mar 24 13:01:38 UTC 2026 - Ladislav Slezák