From 3080eea58a4fca884f19e1880170995c58344890 Mon Sep 17 00:00:00 2001 From: SFG545 Date: Sun, 1 Mar 2026 14:34:22 -0600 Subject: [PATCH] feat: update package version to 0.7.0 and enhance manual source variable expansion --- Cargo.lock | 2 +- Cargo.toml | 2 +- meson.build | 2 +- src/commands.rs | 47 +++++++++++++++++++++++++++++---------------- src/package/spec.rs | 2 +- src/source/mod.rs | 47 ++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 78 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8e3e48..d9cd2ae 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -382,7 +382,7 @@ checksum = "807800ff3288b621186fe0a8f3392c4652068257302709c24efd918c3dffcdc2" [[package]] name = "depot" -version = "0.6.0" +version = "0.7.0" dependencies = [ "anyhow", "ar", diff --git a/Cargo.toml b/Cargo.toml index 0f0f348..2f31c60 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "depot" -version = "0.6.0" +version = "0.7.0" edition = "2024" [lints.rust] diff --git a/meson.build b/meson.build index d677554..53bc0d2 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'depot', - version: '0.5.0', + version: '0.7.0', meson_version: '>=0.60.0', ) diff --git a/src/commands.rs b/src/commands.rs index b27b02a..f955afa 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -992,14 +992,19 @@ fn print_plan_summary(plan: &planner::ExecutionPlan) { } } +struct InstallPlanExecutionOptions<'a> { + no_flags: bool, + cross_prefix: Option<&'a str>, + clean: bool, + dry_run: bool, + confirm_installation: bool, +} + fn execute_install_plan_with_child_commands( plan: &planner::ExecutionPlan, rootfs: &Path, - no_flags: bool, - cross_prefix: Option<&str>, - clean: bool, - dry_run: bool, config: &config::Config, + options: InstallPlanExecutionOptions<'_>, ) -> Result<()> { #[derive(Clone)] struct BinaryPhaseItem { @@ -1024,11 +1029,13 @@ fn execute_install_plan_with_child_commands( .iter() .map(|step| step.package.clone()) .collect(); - if !ui::prompt_package_action("installation", &planned_packages, true)? { + if options.confirm_installation + && !ui::prompt_package_action("installation", &planned_packages, true)? + { anyhow::bail!("Aborted"); } - if dry_run { + if options.dry_run { ui::info("Dry run enabled, no install/build actions executed."); return Ok(()); } @@ -1205,13 +1212,13 @@ fn execute_install_plan_with_child_commands( cmd.arg("-r").arg(rootfs); cmd.arg("--no-deps"); cmd.arg("--yes"); - if no_flags { + if options.no_flags { cmd.arg("--no-flags"); } - if let Some(p) = cross_prefix { + if let Some(p) = options.cross_prefix { cmd.arg("--cross-prefix").arg(p); } - if clean { + if options.clean { cmd.arg("--clean"); } cmd.arg("install").arg(path); @@ -1295,11 +1302,14 @@ pub fn run(cli: Cli) -> Result<()> { execute_install_plan_with_child_commands( &plan, &cli.rootfs, - cli.no_flags, - cli.cross_prefix.as_deref(), - cli.clean, - cli.dry_run, &config, + InstallPlanExecutionOptions { + no_flags: cli.no_flags, + cross_prefix: cli.cross_prefix.as_deref(), + clean: cli.clean, + dry_run: cli.dry_run, + confirm_installation: true, + }, )?; if cli.clean { clean_build_workspace(&config)?; @@ -1703,11 +1713,14 @@ pub fn run(cli: Cli) -> Result<()> { execute_install_plan_with_child_commands( &dep_plan, &cli.rootfs, - cli.no_flags, - cli.cross_prefix.as_deref(), - cli.clean, - cli.dry_run, &config, + InstallPlanExecutionOptions { + no_flags: cli.no_flags, + cross_prefix: cli.cross_prefix.as_deref(), + clean: cli.clean, + dry_run: cli.dry_run, + confirm_installation: false, + }, )?; } deps::require_build_deps(&pkg_spec, &db_path)?; diff --git a/src/package/spec.rs b/src/package/spec.rs index e65d9cf..84b1a32 100755 --- a/src/package/spec.rs +++ b/src/package/spec.rs @@ -155,7 +155,7 @@ impl PackageSpec { Ok(()) } - /// Expand variables like $name and $version in a string + /// Expand variables like `$name` and `$version` in a string. pub fn expand_vars(&self, input: &str) -> String { let specdir = self.spec_dir.to_string_lossy(); input diff --git a/src/source/mod.rs b/src/source/mod.rs index 68735b1..e0c9ea1 100755 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -14,6 +14,13 @@ use std::path::{Path, PathBuf}; use url::Url; use walkdir::WalkDir; +fn expand_manual_source_value(spec: &PackageSpec, raw: &str) -> String { + let carch = spec.build.flags.carch.as_str(); + spec.expand_vars(raw) + .replace("$CARCH", carch) + .replace("${CARCH}", carch) +} + /// Copy manual sources to the build directory before fetching remote sources. /// /// Manual sources support: @@ -62,7 +69,7 @@ pub fn copy_manual_sources(spec: &PackageSpec, cache_dir: &Path, build_dir: &Pat if !local_entries.is_empty() { for raw_file in local_entries { - let file = spec.expand_vars(&raw_file); + let file = expand_manual_source_value(spec, &raw_file); let src_path = spec.spec_dir.join(&file); if !src_path.exists() { bail!( @@ -86,7 +93,7 @@ pub fn copy_manual_sources(spec: &PackageSpec, cache_dir: &Path, build_dir: &Pat if !url_entries.is_empty() { for raw_url in url_entries { - let expanded_url = spec.expand_vars(&raw_url); + let expanded_url = expand_manual_source_value(spec, &raw_url); let parsed = Url::parse(&expanded_url) .with_context(|| format!("Invalid URL: {}", expanded_url))?; @@ -151,7 +158,7 @@ fn copy_manual_source_file( default_dest: &str, ) -> Result<()> { let dest_name = if let Some(dest) = manual.dest.as_ref() { - spec.expand_vars(dest) + expand_manual_source_value(spec, dest) } else { default_dest.to_string() }; @@ -701,4 +708,38 @@ mod tests { "auth" ); } + + #[test] + fn copy_manual_sources_expands_carch_in_files_entries() { + let tmp = tempfile::tempdir().unwrap(); + let spec_dir = tmp.path().join("spec"); + let cache_dir = tmp.path().join("cache"); + let build_dir = tmp.path().join("build"); + std::fs::create_dir_all(&spec_dir).unwrap(); + std::fs::write(spec_dir.join("build.sh"), "#!/bin/sh\necho hi\n").unwrap(); + std::fs::write(spec_dir.join("config.armv7"), "armv7-config").unwrap(); + + let mut spec = mk_spec_with_manuals( + spec_dir.clone(), + vec![ManualSource { + file: None, + files: vec!["build.sh".into(), "config.$CARCH".into()], + url: None, + urls: Vec::new(), + sha256: None, + dest: None, + }], + ); + spec.build.flags.carch = "armv7".into(); + + copy_manual_sources(&spec, &cache_dir, &build_dir).unwrap(); + assert_eq!( + std::fs::read_to_string(build_dir.join("build.sh")).unwrap(), + "#!/bin/sh\necho hi\n" + ); + assert_eq!( + std::fs::read_to_string(build_dir.join("config.armv7")).unwrap(), + "armv7-config" + ); + } }