Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ jobs:
# use the "stable" tool chain (installed by default) instead of the "nightly" default in tarpaulin
RUSTC_BOOTSTRAP: 1
RUSTUP_TOOLCHAIN: stable
RUST_BACKTRACE: 1
RUST_BACKTRACE: full
RUSTFLAGS: --cfg ci

# send the code coverage for the Rust part to the coveralls.io
Expand Down
68 changes: 56 additions & 12 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"agama-autoinstall",
"agama-cli",
"agama-files",
"agama-l10n",
"agama-lib",
"agama-locale-data",
Expand All @@ -10,6 +11,7 @@ members = [
"agama-server",
"agama-software",
"agama-storage",
"agama-transfer",
"agama-utils",
"xtask",
"zypp-agama",
Expand Down
1 change: 1 addition & 0 deletions rust/agama-autoinstall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition.workspace = true
[dependencies]
agama-lib = { path = "../agama-lib" }
agama-utils = { path = "../agama-utils" }
agama-transfer = { path = "../agama-transfer" }
anyhow = { version = "1.0.98" }
tempfile = "3.20.0"
thiserror = "2.0.12"
Expand Down
13 changes: 9 additions & 4 deletions rust/agama-autoinstall/src/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use std::{
process::Output,
};

use agama_lib::{http::BaseHTTPClient, utils::Transfer};
use agama_lib::http::BaseHTTPClient;
use agama_transfer::Transfer;
use agama_utils::command::run_with_retry;
use anyhow::anyhow;
use url::Url;

Expand Down Expand Up @@ -60,6 +62,8 @@ impl ScriptsRunner {
/// It downloads the script from the given URL to the runner directory.
/// It saves the stdout, stderr and exit code to separate files.
///
/// It will retry if it cannot run the script.
///
/// * url: script URL, supporting agama-specific schemes.
pub async fn run(&mut self, url: &str) -> anyhow::Result<()> {
create_dir_all(&self.path)?;
Expand All @@ -69,9 +73,9 @@ impl ScriptsRunner {
let path = self.path.join(&file_name);
self.save_script(url, &path).await?;

let output = std::process::Command::new(&path).output()?;
let command = tokio::process::Command::new(&path);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change all std::Commands to tokio::Command due to async nature?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely. I will check them in a separate PR.

let output = run_with_retry(command).await?;
self.save_logs(&path, output)?;

Ok(())
}

Expand All @@ -98,11 +102,12 @@ impl ScriptsRunner {
async fn save_script(&self, url: &str, path: &PathBuf) -> anyhow::Result<()> {
let mut file = Self::create_file(&path, 0o700)?;
while let Err(error) = Transfer::get(url, &mut file, self.insecure) {
eprintln!("Could not load configuration from {url}: {error}");
eprintln!("Could not load the script from {url}: {error}");
if !self.should_retry(&url, &error.to_string()).await? {
return Err(anyhow!(error));
}
}
file.sync_all()?;
Comment thread
imobachgs marked this conversation as resolved.
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions rust/agama-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
clap = { version = "4.5.19", features = ["derive", "wrap_help"] }
agama-lib = { path = "../agama-lib" }
agama-utils = { path = "../agama-utils" }
agama-transfer = { path = "../agama-transfer" }
serde_json = "1.0.128"
indicatif = "0.17.8"
thiserror = "2.0.12"
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-cli/src/cli_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// To contact SUSE LLC about this file by physical or electronic mail, you may
// find current contact information at www.suse.com.

use agama_lib::utils::Transfer;
use agama_transfer::Transfer;
use anyhow::Context;
use std::{
collections::HashMap,
Expand Down
3 changes: 2 additions & 1 deletion rust/agama-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use agama_lib::auth::AuthToken;
use agama_lib::context::InstallationContext;
use agama_lib::manager::{FinishMethod, ManagerHTTPClient};
use agama_lib::monitor::{Monitor, MonitorClient};
use agama_transfer::Transfer;
use anyhow::Context;
use auth_tokens_file::AuthTokensFile;
use clap::{Args, Parser};
Expand All @@ -40,8 +41,8 @@ mod progress;
mod questions;

use crate::error::CliError;
use agama_lib::error::ServiceError;
use agama_lib::http::{BaseHTTPClient, WebSocketClient};
use agama_lib::{error::ServiceError, utils::Transfer};
use auth::run as run_auth_cmd;
use commands::Commands;
use config::run as run_config_cmd;
Expand Down
18 changes: 18 additions & 0 deletions rust/agama-files/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "agama-files"
version = "0.1.0"
rust-version.workspace = true
edition.workspace = true

[dependencies]
agama-software = { version = "0.1.0", path = "../agama-software" }
agama-utils = { path = "../agama-utils" }
async-trait = "0.1.89"
tempfile = "3.23.0"
thiserror = "2.0.17"
tokio = { version = "1.48.0", features = ["sync"] }

[dev-dependencies]
tokio-test = "0.4.4"
test-context = "0.4.1"
serde_json = "1.0.145"
Loading
Loading