feat: update package version to 0.7.0 and enhance manual source variable expansion

This commit is contained in:
2026-03-01 14:34:22 -06:00
parent 7841b06b5a
commit 3080eea58a
6 changed files with 78 additions and 24 deletions
Generated
+1 -1
View File
@@ -382,7 +382,7 @@ checksum = "807800ff3288b621186fe0a8f3392c4652068257302709c24efd918c3dffcdc2"
[[package]]
name = "depot"
version = "0.6.0"
version = "0.7.0"
dependencies = [
"anyhow",
"ar",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "depot"
version = "0.6.0"
version = "0.7.0"
edition = "2024"
[lints.rust]
+1 -1
View File
@@ -1,6 +1,6 @@
project(
'depot',
version: '0.5.0',
version: '0.7.0',
meson_version: '>=0.60.0',
)
+30 -17
View File
@@ -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)?;
+1 -1
View File
@@ -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
+44 -3
View File
@@ -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"
);
}
}