diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8fe5e071..c6dbdf71 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust-toolchain: [stable, stable 12 months ago] + rust-toolchain: [stable, "1.88.0"] steps: - name: Install libudev run: | diff --git a/.github/workflows/clippy-linting.yml b/.github/workflows/clippy-linting.yml index c731d44a..68ee2e2b 100644 --- a/.github/workflows/clippy-linting.yml +++ b/.github/workflows/clippy-linting.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust-toolchain: [stable, stable 12 months ago] + rust-toolchain: [stable, "1.88.0"] steps: - name: Install libudev run: | diff --git a/Cargo.toml b/Cargo.toml index 1504117e..31693d8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "azure-init" version = "0.1.1" edition = "2021" -rust-version = "1.74" +rust-version = "1.88" repository = "https://github.com/Azure/azure-init/" homepage = "https://github.com/Azure/azure-init/" license = "MIT" @@ -19,9 +19,7 @@ clap = { version = "4.5.21", features = ["derive", "cargo", "env"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tokio-util = "0.7" -# Pin sysinfo to <=0.36 for MSRV issues with Rust < 1.85.0. -# This should be unpinned around 2026-02-17 if we continue with our ~1 year MSRV policy -sysinfo = "=0.36" +sysinfo = "0.38" [dev-dependencies] assert_cmd = "2.0.16" @@ -30,7 +28,8 @@ predicates-core = "1.0.8" predicates-tree = "1.0.11" tempfile = "3.3.0" -# Pin idna_adapter to <=1.2.0 for MSRV issues with cargo-clippy of Rust 1.78.0. +# Pin idna_adapter to <=1.2.0 for MSRV issues with older Rust versions. +# With MSRV 1.88, this pin may no longer be necessary. idna_adapter = "<=1.2.0" [dependencies.libazureinit] @@ -61,7 +60,3 @@ useradd = [] systemd_linux = ["passwd", "hostnamectl", "useradd"] default = ["systemd_linux"] - -[build-dependencies] -vergen = { version = "9.0.6", features = ["build", "cargo", "rustc", "si"] } -vergen-gitcl = "1" diff --git a/build.rs b/build.rs index b8682d0b..b97edbe4 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,5 @@ use std::env; -use vergen::Emitter; -use vergen_gitcl::GitclBuilder; +use std::process::Command; fn main() { // Re-run if the packaging version override changes @@ -9,16 +8,11 @@ fn main() { println!("cargo:rerun-if-changed=.git/HEAD"); println!("cargo:rerun-if-changed=.git/index"); - let mut gitcl_builder = GitclBuilder::default(); - // Parameters: use_tag=true, dirty=true, pattern=None - gitcl_builder.describe(true, true, None); - let git = gitcl_builder.build().ok(); - - let mut emitter = Emitter::default(); - if let Some(g) = git.as_ref() { - let _ = emitter.add_instructions(g); + if let Some(git_version) = git_describe() { + println!("cargo:rustc-env=AZURE_INIT_BUILD_VERSION={git_version}"); + } else if let Some(git_sha) = git_sha() { + println!("cargo:rustc-env=AZURE_INIT_BUILD_SHA={git_sha}"); } - let _ = emitter.emit(); // Allow packaging to supply a custom version if let Ok(custom_version) = env::var("AZURE_INIT_VERSION") { @@ -26,3 +20,35 @@ fn main() { println!("cargo:rustc-env=AZURE_INIT_BUILD_VERSION={custom_version}"); } } + +fn git_describe() -> Option { + let output = Command::new("git") + .args(["describe", "--dirty", "--tags"]) + .output() + .ok()?; + if !output.status.success() { + return None; + } + let describe = String::from_utf8_lossy(&output.stdout).trim().to_string(); + if describe.is_empty() { + None + } else { + Some(describe) + } +} + +fn git_sha() -> Option { + let output = Command::new("git") + .args(["rev-parse", "HEAD"]) + .output() + .ok()?; + if !output.status.success() { + return None; + } + let sha = String::from_utf8_lossy(&output.stdout).trim().to_string(); + if sha.is_empty() { + None + } else { + Some(sha) + } +} diff --git a/libazureinit/Cargo.toml b/libazureinit/Cargo.toml index a036993c..55fa0a99 100644 --- a/libazureinit/Cargo.toml +++ b/libazureinit/Cargo.toml @@ -2,7 +2,7 @@ name = "libazureinit" version = "0.1.1" edition = "2021" -rust-version = "1.74" +rust-version = "1.88" build = "build.rs" repository = "https://github.com/Azure/azure-init/" homepage = "https://github.com/Azure/azure-init/" @@ -16,7 +16,7 @@ thiserror = "2.0.3" tokio = { version = "1", features = ["full"] } serde-xml-rs = "0.8.0" serde_json = "1.0.96" -nix = {version = "0.30.1", features = ["fs", "user"]} +nix = {version = "0.31.1", features = ["fs", "user"]} block-utils = "0.11.1" tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } @@ -24,9 +24,7 @@ opentelemetry = "0.31.0" opentelemetry_sdk = "0.31.0" tracing-opentelemetry = "0.32" tokio-util = "0.7" -# Pin sysinfo to <=0.36 for MSRV issues with Rust < 1.85.0. -# This should be unpinned around 2026-02-17 if we continue with our ~1 year MSRV policy -sysinfo = "=0.36" +sysinfo = "0.38" anyhow = "1" fstab = "0.4.0" toml = "0.9" @@ -44,7 +42,7 @@ tracing-test = { version = "0.2", features = ["no-env-filter"] } tempfile = "3" tokio = { version = "1", features = ["full"] } tokio-util = "0.7.11" -whoami = "1" +whoami = "2" anyhow = "1.0.81" gag = "1.0.0" serial_test = "3.0.0" diff --git a/libazureinit/src/config.rs b/libazureinit/src/config.rs index 942653c7..a6f0951d 100644 --- a/libazureinit/src/config.rs +++ b/libazureinit/src/config.rs @@ -433,12 +433,11 @@ impl Config { figment .extract::() - .map(|config| { + .inspect(|_config| { tracing::info!( target: "libazureinit::config::success", "Configuration successfully loaded." ); - config }) .map_err(|e| { tracing::error!("Failed to extract configuration: {:?}", e); diff --git a/libazureinit/src/provision/ssh.rs b/libazureinit/src/provision/ssh.rs index 48a12dc8..96f7665b 100644 --- a/libazureinit/src/provision/ssh.rs +++ b/libazureinit/src/provision/ssh.rs @@ -335,10 +335,11 @@ mod tests { let home_dir = tempfile::TempDir::new().expect("Failed to create temp directory"); - let mut user = - nix::unistd::User::from_name(whoami::username().as_str()) - .expect("Failed to get user") - .expect("User does not exist"); + let mut user = nix::unistd::User::from_name( + whoami::username().expect("Failed to get username").as_str(), + ) + .expect("Failed to get user") + .expect("User does not exist"); user.dir = home_dir.path().into(); if create_ssh_dir { diff --git a/src/main.rs b/src/main.rs index 3a925b48..2b3812f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,14 +31,15 @@ fn version_string() -> String { return v.to_string(); } - if let Some(desc) = option_env!("VERGEN_GIT_DESCRIBE") { - format!("{PKG_VERSION}-{desc}") - } else if let Some(sha) = option_env!("VERGEN_GIT_SHA") { + if let Some(build) = option_env!("AZURE_INIT_BUILD_VERSION") { + return format!("{PKG_VERSION}-{build}"); + } + if let Some(sha) = option_env!("AZURE_INIT_BUILD_SHA") { let short = &sha[..std::cmp::min(7, sha.len())]; - format!("{PKG_VERSION}-{short}") - } else { - PKG_VERSION.to_string() + return format!("{PKG_VERSION}-{short}"); } + + PKG_VERSION.to_string() } /// Minimal provisioning agent for Azure