feat: merge missing dependencies into a single function and update dependency checks

This commit is contained in:
2026-02-28 19:22:35 -06:00
parent c96a17c553
commit 238f64eef7
2 changed files with 35 additions and 15 deletions
+33 -13
View File
@@ -934,6 +934,15 @@ fn binary_arch_from_filename(filename: &str) -> String {
.to_string() .to_string()
} }
fn merge_missing_dependencies(mut base: Vec<String>, extra: Vec<String>) -> Vec<String> {
for dep in extra {
if !base.contains(&dep) {
base.push(dep);
}
}
base
}
fn print_plan_summary(plan: &planner::ExecutionPlan) { fn print_plan_summary(plan: &planner::ExecutionPlan) {
let summary = plan.summary(); let summary = plan.summary();
ui::info(format!( ui::info(format!(
@@ -1425,14 +1434,10 @@ pub fn run(cli: Cli) -> Result<()> {
deps::print_dep_status(&pkg_spec, &db_path)?; deps::print_dep_status(&pkg_spec, &db_path)?;
// Collect all missing dependencies (build + runtime) // Collect all missing dependencies (build + runtime)
let mut missing = deps::check_build_deps(&pkg_spec, &db_path)?; let missing = merge_missing_dependencies(
let missing_runtime = deps::check_runtime_deps(&pkg_spec, &db_path)?; deps::check_build_deps(&pkg_spec, &db_path)?,
deps::check_runtime_deps(&pkg_spec, &db_path)?,
for dep in missing_runtime { );
if !missing.contains(&dep) {
missing.push(dep);
}
}
if !missing.is_empty() { if !missing.is_empty() {
// Check for dependency cycles via DEPOT_DEPCHAIN env var // Check for dependency cycles via DEPOT_DEPCHAIN env var
let dep_chain = std::env::var("DEPOT_DEPCHAIN").unwrap_or_default(); let dep_chain = std::env::var("DEPOT_DEPCHAIN").unwrap_or_default();
@@ -1667,12 +1672,12 @@ pub fn run(cli: Cli) -> Result<()> {
// Check build dependencies // Check build dependencies
if !cli.no_deps { if !cli.no_deps {
deps::print_dep_status(&pkg_spec, &db_path)?; deps::print_dep_status(&pkg_spec, &db_path)?;
let missing = deps::check_build_deps(&pkg_spec, &db_path)?; let missing = merge_missing_dependencies(
deps::check_build_deps(&pkg_spec, &db_path)?,
deps::check_runtime_deps(&pkg_spec, &db_path)?,
);
if !missing.is_empty() { if !missing.is_empty() {
ui::warn(format!( ui::warn(format!("Missing dependencies: {}", missing.join(", ")));
"Missing build dependencies: {}",
missing.join(", ")
));
let local_sibling_root = spec_path let local_sibling_root = spec_path
.parent() .parent()
.and_then(|p| p.parent()) .and_then(|p| p.parent())
@@ -1706,6 +1711,7 @@ pub fn run(cli: Cli) -> Result<()> {
)?; )?;
} }
deps::require_build_deps(&pkg_spec, &db_path)?; deps::require_build_deps(&pkg_spec, &db_path)?;
deps::require_runtime_deps(&pkg_spec, &db_path)?;
} else if cli.dry_run { } else if cli.dry_run {
ui::info("Dry run enabled, stopping before build."); ui::info("Dry run enabled, stopping before build.");
return Ok(()); return Ok(());
@@ -2492,4 +2498,18 @@ mod tests {
); );
Ok(()) Ok(())
} }
#[test]
fn merge_missing_dependencies_preserves_order_and_uniqueness() {
let merged = merge_missing_dependencies(
vec!["make".into(), "pkgconf".into(), "glibc".into()],
vec![
"glibc".into(),
"openssl".into(),
"pkgconf".into(),
"zlib".into(),
],
);
assert_eq!(merged, vec!["make", "pkgconf", "glibc", "openssl", "zlib"]);
}
} }
+2 -2
View File
@@ -1147,12 +1147,12 @@ mod tests {
std::fs::create_dir_all(&scripts).unwrap(); std::fs::create_dir_all(&scripts).unwrap();
std::fs::write( std::fs::write(
scripts.join("post_install"), scripts.join("pre_install"),
"echo ok > \"$DEPOT_ROOTFS/hook.out\"\n", "echo ok > \"$DEPOT_ROOTFS/hook.out\"\n",
) )
.unwrap(); .unwrap();
let ran = run_hook_if_present(&scripts, Hook::PostInstall, &rootfs_rel, "foo").unwrap(); let ran = run_hook_if_present(&scripts, Hook::PreInstall, &rootfs_rel, "foo").unwrap();
assert!(ran); assert!(ran);
assert_eq!( assert_eq!(
std::fs::read_to_string(rootfs_abs.join("hook.out")).unwrap(), std::fs::read_to_string(rootfs_abs.join("hook.out")).unwrap(),