feat: update package version to 0.7.0 and enhance manual source variable expansion
This commit is contained in:
Generated
+1
-1
@@ -382,7 +382,7 @@ checksum = "807800ff3288b621186fe0a8f3392c4652068257302709c24efd918c3dffcdc2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "depot"
|
name = "depot"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"ar",
|
"ar",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "depot"
|
name = "depot"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[lints.rust]
|
[lints.rust]
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
project(
|
project(
|
||||||
'depot',
|
'depot',
|
||||||
version: '0.5.0',
|
version: '0.7.0',
|
||||||
meson_version: '>=0.60.0',
|
meson_version: '>=0.60.0',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+30
-17
@@ -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(
|
fn execute_install_plan_with_child_commands(
|
||||||
plan: &planner::ExecutionPlan,
|
plan: &planner::ExecutionPlan,
|
||||||
rootfs: &Path,
|
rootfs: &Path,
|
||||||
no_flags: bool,
|
|
||||||
cross_prefix: Option<&str>,
|
|
||||||
clean: bool,
|
|
||||||
dry_run: bool,
|
|
||||||
config: &config::Config,
|
config: &config::Config,
|
||||||
|
options: InstallPlanExecutionOptions<'_>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct BinaryPhaseItem {
|
struct BinaryPhaseItem {
|
||||||
@@ -1024,11 +1029,13 @@ fn execute_install_plan_with_child_commands(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|step| step.package.clone())
|
.map(|step| step.package.clone())
|
||||||
.collect();
|
.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");
|
anyhow::bail!("Aborted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if dry_run {
|
if options.dry_run {
|
||||||
ui::info("Dry run enabled, no install/build actions executed.");
|
ui::info("Dry run enabled, no install/build actions executed.");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -1205,13 +1212,13 @@ fn execute_install_plan_with_child_commands(
|
|||||||
cmd.arg("-r").arg(rootfs);
|
cmd.arg("-r").arg(rootfs);
|
||||||
cmd.arg("--no-deps");
|
cmd.arg("--no-deps");
|
||||||
cmd.arg("--yes");
|
cmd.arg("--yes");
|
||||||
if no_flags {
|
if options.no_flags {
|
||||||
cmd.arg("--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);
|
cmd.arg("--cross-prefix").arg(p);
|
||||||
}
|
}
|
||||||
if clean {
|
if options.clean {
|
||||||
cmd.arg("--clean");
|
cmd.arg("--clean");
|
||||||
}
|
}
|
||||||
cmd.arg("install").arg(path);
|
cmd.arg("install").arg(path);
|
||||||
@@ -1295,11 +1302,14 @@ pub fn run(cli: Cli) -> Result<()> {
|
|||||||
execute_install_plan_with_child_commands(
|
execute_install_plan_with_child_commands(
|
||||||
&plan,
|
&plan,
|
||||||
&cli.rootfs,
|
&cli.rootfs,
|
||||||
cli.no_flags,
|
|
||||||
cli.cross_prefix.as_deref(),
|
|
||||||
cli.clean,
|
|
||||||
cli.dry_run,
|
|
||||||
&config,
|
&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 {
|
if cli.clean {
|
||||||
clean_build_workspace(&config)?;
|
clean_build_workspace(&config)?;
|
||||||
@@ -1703,11 +1713,14 @@ pub fn run(cli: Cli) -> Result<()> {
|
|||||||
execute_install_plan_with_child_commands(
|
execute_install_plan_with_child_commands(
|
||||||
&dep_plan,
|
&dep_plan,
|
||||||
&cli.rootfs,
|
&cli.rootfs,
|
||||||
cli.no_flags,
|
|
||||||
cli.cross_prefix.as_deref(),
|
|
||||||
cli.clean,
|
|
||||||
cli.dry_run,
|
|
||||||
&config,
|
&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)?;
|
deps::require_build_deps(&pkg_spec, &db_path)?;
|
||||||
|
|||||||
+1
-1
@@ -155,7 +155,7 @@ impl PackageSpec {
|
|||||||
Ok(())
|
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 {
|
pub fn expand_vars(&self, input: &str) -> String {
|
||||||
let specdir = self.spec_dir.to_string_lossy();
|
let specdir = self.spec_dir.to_string_lossy();
|
||||||
input
|
input
|
||||||
|
|||||||
+44
-3
@@ -14,6 +14,13 @@ use std::path::{Path, PathBuf};
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
use walkdir::WalkDir;
|
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.
|
/// Copy manual sources to the build directory before fetching remote sources.
|
||||||
///
|
///
|
||||||
/// Manual sources support:
|
/// 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() {
|
if !local_entries.is_empty() {
|
||||||
for raw_file in local_entries {
|
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);
|
let src_path = spec.spec_dir.join(&file);
|
||||||
if !src_path.exists() {
|
if !src_path.exists() {
|
||||||
bail!(
|
bail!(
|
||||||
@@ -86,7 +93,7 @@ pub fn copy_manual_sources(spec: &PackageSpec, cache_dir: &Path, build_dir: &Pat
|
|||||||
|
|
||||||
if !url_entries.is_empty() {
|
if !url_entries.is_empty() {
|
||||||
for raw_url in url_entries {
|
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)
|
let parsed = Url::parse(&expanded_url)
|
||||||
.with_context(|| format!("Invalid URL: {}", expanded_url))?;
|
.with_context(|| format!("Invalid URL: {}", expanded_url))?;
|
||||||
|
|
||||||
@@ -151,7 +158,7 @@ fn copy_manual_source_file(
|
|||||||
default_dest: &str,
|
default_dest: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let dest_name = if let Some(dest) = manual.dest.as_ref() {
|
let dest_name = if let Some(dest) = manual.dest.as_ref() {
|
||||||
spec.expand_vars(dest)
|
expand_manual_source_value(spec, dest)
|
||||||
} else {
|
} else {
|
||||||
default_dest.to_string()
|
default_dest.to_string()
|
||||||
};
|
};
|
||||||
@@ -701,4 +708,38 @@ mod tests {
|
|||||||
"auth"
|
"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"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user