refactor: remove unused dependency status print functions and related logic

This commit is contained in:
2026-06-10 06:14:19 -05:00
parent 9a544c60b0
commit 65cec6903a
6 changed files with 30 additions and 229 deletions
-12
View File
@@ -1370,16 +1370,6 @@ fn install_package_outputs_to_rootfs(
} }
fn print_plan_summary(plan: &planner::ExecutionPlan) { fn print_plan_summary(plan: &planner::ExecutionPlan) {
let summary = plan.summary();
ui::info(format!(
"Plan summary: packages={} actions={} (binary_install={}, source_build_install={}, skip_installed={}) known_download={}",
summary.total_packages,
summary.binary_installs + summary.source_build_installs,
summary.binary_installs,
summary.source_build_installs,
summary.skipped_installed,
human_bytes(summary.known_download_bytes)
));
if std::env::var_os("DEPOT_VERBOSE_PLAN").is_none() { if std::env::var_os("DEPOT_VERBOSE_PLAN").is_none() {
return; return;
} }
@@ -2256,8 +2246,6 @@ fn run_direct_install_request(
// Check dependencies and prompt for auto-install if needed // Check dependencies and prompt for auto-install if needed
if !options.no_deps { if !options.no_deps {
deps::print_dep_status_for_outputs(&pkg_spec, &db_path, requested_outputs)?;
let missing_required = merge_missing_dependencies( let missing_required = merge_missing_dependencies(
deps::check_build_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?, deps::check_build_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?,
deps::check_runtime_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?, deps::check_runtime_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?,
-1
View File
@@ -101,7 +101,6 @@ pub(super) fn run_build(args: BuildArgs, cli_test_deps: bool) -> Result<()> {
} }
if !no_deps { if !no_deps {
deps::print_dep_status_for_outputs(&pkg_spec, &db_path, requested_outputs)?;
let missing_build = let missing_build =
deps::check_build_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?; deps::check_build_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?;
let missing_runtime = let missing_runtime =
-3
View File
@@ -16,9 +16,6 @@ pub(super) fn run_info(args: InfoArgs) -> Result<()> {
let _info_lock_guard = locking::try_read(&info_lock, &info_lock_path, "info")?; let _info_lock_guard = locking::try_read(&info_lock, &info_lock_path, "info")?;
let pkg_spec = package::PackageSpec::from_file(&path)?; let pkg_spec = package::PackageSpec::from_file(&path)?;
println!("{}", pkg_spec); println!("{}", pkg_spec);
let db_path = config.installed_db_path(&rootfs);
deps::print_dep_status(&pkg_spec, &db_path)?;
} else { } else {
let config = config::Config::for_rootfs(&rootfs); let config = config::Config::for_rootfs(&rootfs);
let info_lock = locking::open_lock(&config)?; let info_lock = locking::open_lock(&config)?;
+28 -40
View File
@@ -4,8 +4,7 @@ use crate::metadata_time;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use rusqlite::{Connection, params}; use rusqlite::{Connection, params};
use sha2::{Digest, Sha256, Sha512}; use sha2::{Digest, Sha256, Sha512};
use std::collections::BTreeSet; use std::collections::{HashMap, BTreeSet};
use std::collections::HashMap;
use std::fs; use std::fs;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@@ -1185,11 +1184,7 @@ pub fn fetch_binary_repo_db(
let repo_db_url = join_repo_url(base_url, repo_db_rel)?; let repo_db_url = join_repo_url(base_url, repo_db_rel)?;
let repo_sig_url = join_repo_url(base_url, &format!("{}.sig", repo_db_rel))?; let repo_sig_url = join_repo_url(base_url, &format!("{}.sig", repo_db_rel))?;
crate::log_info!( crate::log_info!("Fetching binary repo DB for '{}'", repo_name);
"Fetching binary repo DB for '{}' from {}",
repo_name,
repo_db_url
);
let client = reqwest::blocking::Client::builder() let client = reqwest::blocking::Client::builder()
.build() .build()
@@ -1292,14 +1287,12 @@ pub fn fetch_binary_repo_db(
if sig_downloaded { if sig_downloaded {
let mut trusted_keys = crate::signing::list_trusted_public_keys(rootfs)?; let mut trusted_keys = crate::signing::list_trusted_public_keys(rootfs)?;
if trusted_keys.is_empty() { if trusted_keys.is_empty() {
if let Some(installed_key) = try_trust_repo_public_key_for_repo_db( if try_trust_repo_public_key_for_repo_db(
repo_name, base_url, rootfs, &cache_dir, &client, &tmp_zst, &tmp_sig, repo_name, base_url, rootfs, &cache_dir, &client, &tmp_zst, &tmp_sig,
)? { )?
crate::log_info!( .is_some()
"Trusted repo key for '{}' installed at {}", {
repo_name, crate::log_info!("Trusted repo key for '{}' installed", repo_name);
installed_key.display()
);
} else if !repo.allow_unsigned { } else if !repo.allow_unsigned {
anyhow::bail!( anyhow::bail!(
"No trusted minisign public key found for binary repo '{}' and no trusted key was accepted from {}/keys/", "No trusted minisign public key found for binary repo '{}' and no trusted key was accepted from {}/keys/",
@@ -1318,39 +1311,34 @@ pub fn fetch_binary_repo_db(
if trusted_keys.is_empty() { if trusted_keys.is_empty() {
// No key was trusted/installed, and allow_unsigned=true already handled above. // No key was trusted/installed, and allow_unsigned=true already handled above.
} else { } else {
let verified_key = match verify_with_any_trusted_public_key(rootfs, &tmp_zst, &tmp_sig) if let Err(initial_err) = verify_with_any_trusted_public_key(rootfs, &tmp_zst, &tmp_sig)
{ {
Ok(key) => key, if try_trust_repo_public_key_for_repo_db(
Err(initial_err) => { repo_name, base_url, rootfs, &cache_dir, &client, &tmp_zst, &tmp_sig,
if let Some(installed_key) = try_trust_repo_public_key_for_repo_db( )?
repo_name, base_url, rootfs, &cache_dir, &client, &tmp_zst, &tmp_sig, .is_some()
)? { {
crate::log_info!( crate::log_info!("Trusted repo key for '{}' installed", repo_name);
"Trusted repo key for '{}' installed at {}", verify_with_any_trusted_public_key(rootfs, &tmp_zst, &tmp_sig).with_context(
repo_name, || {
installed_key.display()
);
verify_with_any_trusted_public_key(rootfs, &tmp_zst, &tmp_sig)
.with_context(|| {
format!(
"Failed to verify detached signature for binary repo '{}'",
repo_name
)
})?
} else {
return Err(initial_err).with_context(|| {
format!( format!(
"Failed to verify detached signature for binary repo '{}'", "Failed to verify detached signature for binary repo '{}'",
repo_name repo_name
) )
}); },
} )?;
} else {
return Err(initial_err).with_context(|| {
format!(
"Failed to verify detached signature for binary repo '{}'",
repo_name
)
});
} }
}; }
crate::log_info!( crate::log_info!(
"Verified detached signature for binary repo '{}' using {}", "Verified detached signature for binary repo '{}'",
repo_name, repo_name
verified_key.display()
); );
} }
} }
+2 -137
View File
@@ -9,8 +9,7 @@
//! - `package<=1.2.3` - less than or equal to 1.2.3 //! - `package<=1.2.3` - less than or equal to 1.2.3
use crate::db; use crate::db;
use crate::package::{BuildType, PackageSpec}; use crate::package::PackageSpec;
use crate::ui;
use anyhow::Result; use anyhow::Result;
use std::collections::HashSet; use std::collections::HashSet;
use std::path::Path; use std::path::Path;
@@ -157,17 +156,6 @@ fn is_dep_satisfied(
} }
} }
fn build_type_runs_automatic_tests(spec: &PackageSpec) -> bool {
matches!(
spec.build.build_type,
BuildType::Autotools | BuildType::CMake | BuildType::Meson | BuildType::Perl
)
}
fn automatic_tests_disabled_for_outputs(spec: &PackageSpec, outputs: RequestedOutputs) -> bool {
spec.should_skip_automatic_tests() || outputs.includes_lib32()
}
/// Check whether a dependency expression is satisfied by the installed package DB. /// Check whether a dependency expression is satisfied by the installed package DB.
pub fn is_dep_satisfied_in_db(dep: &str, db_path: &Path) -> Result<bool> { pub fn is_dep_satisfied_in_db(dep: &str, db_path: &Path) -> Result<bool> {
if !db_path.exists() { if !db_path.exists() {
@@ -329,106 +317,6 @@ pub(crate) fn check_test_deps_for_outputs(
Ok(missing) Ok(missing)
} }
/// Print dependency status
pub fn print_dep_status(spec: &PackageSpec, db_path: &Path) -> Result<()> {
print_dep_status_for_outputs(spec, db_path, RequestedOutputs::PrimaryOnly)
}
fn print_named_dep_status(label: &str, deps: &[String], missing: &[String], warn_on_missing: bool) {
if deps.is_empty() {
return;
}
ui::info(format!("{label}: {}", deps.join(", ")));
if warn_on_missing && !missing.is_empty() {
ui::warn(format!("{label} missing: {}", missing.join(", ")));
}
}
/// Print dependency status for the selected outputs.
pub(crate) fn print_dep_status_for_outputs(
spec: &PackageSpec,
db_path: &Path,
outputs: RequestedOutputs,
) -> Result<()> {
let primary = spec.dependencies.primary_dependencies();
let lib32 = spec.lib32_dependencies();
if matches!(
outputs,
RequestedOutputs::PrimaryOnly | RequestedOutputs::PrimaryAndLib32
) {
let missing_build =
check_build_deps_for_outputs(spec, db_path, RequestedOutputs::PrimaryOnly)?;
let missing_runtime =
check_runtime_deps_for_outputs(spec, db_path, RequestedOutputs::PrimaryOnly)?;
let missing_test =
check_test_deps_for_outputs(spec, db_path, RequestedOutputs::PrimaryOnly)?;
print_named_dep_status("Build dependencies", &primary.build, &missing_build, true);
print_named_dep_status(
"Runtime dependencies",
&primary.runtime,
&missing_runtime,
true,
);
print_named_dep_status(
"Test dependencies",
&primary.test,
&missing_test,
!automatic_tests_disabled_for_outputs(spec, outputs)
&& build_type_runs_automatic_tests(spec),
);
if !primary.optional.is_empty() {
ui::info(format!(
"Optional dependencies: {}",
primary.optional.join(", ")
));
}
}
if matches!(
outputs,
RequestedOutputs::PrimaryAndLib32 | RequestedOutputs::Lib32Only
) {
let missing_build =
check_build_deps_for_outputs(spec, db_path, RequestedOutputs::Lib32Only)?;
let missing_runtime =
check_runtime_deps_for_outputs(spec, db_path, RequestedOutputs::Lib32Only)?;
let missing_test = check_test_deps_for_outputs(spec, db_path, RequestedOutputs::Lib32Only)?;
if outputs == RequestedOutputs::Lib32Only || lib32 != primary {
print_named_dep_status(
"Lib32 build dependencies",
&lib32.build,
&missing_build,
true,
);
print_named_dep_status(
"Lib32 runtime dependencies",
&lib32.runtime,
&missing_runtime,
true,
);
print_named_dep_status(
"Lib32 test dependencies",
&lib32.test,
&missing_test,
!automatic_tests_disabled_for_outputs(spec, outputs)
&& build_type_runs_automatic_tests(spec),
);
if !lib32.optional.is_empty() {
ui::info(format!(
"Lib32 optional dependencies: {}",
lib32.optional.join(", ")
));
}
}
}
Ok(())
}
/// Verify all build dependencies are installed for the selected outputs. /// Verify all build dependencies are installed for the selected outputs.
pub(crate) fn require_build_deps_for_outputs( pub(crate) fn require_build_deps_for_outputs(
spec: &PackageSpec, spec: &PackageSpec,
@@ -486,6 +374,7 @@ pub(crate) fn require_test_deps_for_outputs(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::package::BuildType;
fn test_spec_with_build( fn test_spec_with_build(
build_type: BuildType, build_type: BuildType,
@@ -798,28 +687,4 @@ mod tests {
assert!(is_dep_satisfied_in_db("libressl", &db_path).unwrap()); assert!(is_dep_satisfied_in_db("libressl", &db_path).unwrap());
assert!(is_dep_satisfied_in_db("libressl>=4.3.0", &db_path).unwrap()); assert!(is_dep_satisfied_in_db("libressl>=4.3.0", &db_path).unwrap());
} }
#[test]
fn test_build_type_runs_automatic_tests_matches_builder_behavior() {
assert!(build_type_runs_automatic_tests(&test_spec_with_build(
BuildType::Autotools,
None,
&[]
)));
assert!(build_type_runs_automatic_tests(&test_spec_with_build(
BuildType::Perl,
None,
&[]
)));
assert!(build_type_runs_automatic_tests(&test_spec_with_build(
BuildType::Meson,
None,
&[]
)));
assert!(build_type_runs_automatic_tests(&test_spec_with_build(
BuildType::CMake,
None,
&[]
)));
}
} }
-36
View File
@@ -44,48 +44,12 @@ pub(crate) struct PlannedStep {
pub requested_by: Vec<String>, pub requested_by: Vec<String>,
} }
impl PlannedStep {
pub(crate) fn download_size(&self) -> Option<u64> {
match &self.origin {
PlanOrigin::Binary { record, .. } => Some(record.size),
_ => None,
}
}
}
#[derive(Debug, Clone, Default)]
pub(crate) struct PlanSummary {
pub total_packages: usize,
pub skipped_installed: usize,
pub binary_installs: usize,
pub source_build_installs: usize,
pub known_download_bytes: u64,
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct ExecutionPlan { pub(crate) struct ExecutionPlan {
pub steps: Vec<PlannedStep>, pub steps: Vec<PlannedStep>,
} }
impl ExecutionPlan { impl ExecutionPlan {
pub(crate) fn summary(&self) -> PlanSummary {
let mut out = PlanSummary {
total_packages: self.steps.len(),
..PlanSummary::default()
};
for step in &self.steps {
match step.action {
PlanAction::SkipInstalled => out.skipped_installed += 1,
PlanAction::InstallBinary => out.binary_installs += 1,
PlanAction::BuildAndInstall => out.source_build_installs += 1,
}
if let Some(n) = step.download_size() {
out.known_download_bytes = out.known_download_bytes.saturating_add(n);
}
}
out
}
pub(crate) fn actionable_steps(&self) -> impl Iterator<Item = &PlannedStep> { pub(crate) fn actionable_steps(&self) -> impl Iterator<Item = &PlannedStep> {
self.steps self.steps
.iter() .iter()