From 65cec6903ae9bf3c81bf066e857017f466fc0522 Mon Sep 17 00:00:00 2001 From: SFG545 Date: Wed, 10 Jun 2026 06:14:19 -0500 Subject: [PATCH] refactor: remove unused dependency status print functions and related logic --- src/commands.rs | 12 ---- src/commands/build_cmd.rs | 1 - src/commands/misc.rs | 3 - src/db/repo.rs | 68 ++++++++----------- src/deps.rs | 139 +------------------------------------- src/planner.rs | 36 ---------- 6 files changed, 30 insertions(+), 229 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 53fe661..eb48a0f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1370,16 +1370,6 @@ fn install_package_outputs_to_rootfs( } 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() { return; } @@ -2256,8 +2246,6 @@ fn run_direct_install_request( // Check dependencies and prompt for auto-install if needed if !options.no_deps { - deps::print_dep_status_for_outputs(&pkg_spec, &db_path, requested_outputs)?; - let missing_required = merge_missing_dependencies( deps::check_build_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?, deps::check_runtime_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?, diff --git a/src/commands/build_cmd.rs b/src/commands/build_cmd.rs index e2ff772..2db5e65 100644 --- a/src/commands/build_cmd.rs +++ b/src/commands/build_cmd.rs @@ -101,7 +101,6 @@ pub(super) fn run_build(args: BuildArgs, cli_test_deps: bool) -> Result<()> { } if !no_deps { - deps::print_dep_status_for_outputs(&pkg_spec, &db_path, requested_outputs)?; let missing_build = deps::check_build_deps_for_outputs(&pkg_spec, &db_path, requested_outputs)?; let missing_runtime = diff --git a/src/commands/misc.rs b/src/commands/misc.rs index 8e6c4a8..4ca3df6 100644 --- a/src/commands/misc.rs +++ b/src/commands/misc.rs @@ -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 pkg_spec = package::PackageSpec::from_file(&path)?; println!("{}", pkg_spec); - - let db_path = config.installed_db_path(&rootfs); - deps::print_dep_status(&pkg_spec, &db_path)?; } else { let config = config::Config::for_rootfs(&rootfs); let info_lock = locking::open_lock(&config)?; diff --git a/src/db/repo.rs b/src/db/repo.rs index 9dc306a..9cf6dec 100644 --- a/src/db/repo.rs +++ b/src/db/repo.rs @@ -4,8 +4,7 @@ use crate::metadata_time; use anyhow::{Context, Result}; use rusqlite::{Connection, params}; use sha2::{Digest, Sha256, Sha512}; -use std::collections::BTreeSet; -use std::collections::HashMap; +use std::collections::{HashMap, BTreeSet}; use std::fs; use std::io::{Read, Write}; 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_sig_url = join_repo_url(base_url, &format!("{}.sig", repo_db_rel))?; - crate::log_info!( - "Fetching binary repo DB for '{}' from {}", - repo_name, - repo_db_url - ); + crate::log_info!("Fetching binary repo DB for '{}'", repo_name); let client = reqwest::blocking::Client::builder() .build() @@ -1292,14 +1287,12 @@ pub fn fetch_binary_repo_db( if sig_downloaded { let mut trusted_keys = crate::signing::list_trusted_public_keys(rootfs)?; 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, - )? { - crate::log_info!( - "Trusted repo key for '{}' installed at {}", - repo_name, - installed_key.display() - ); + )? + .is_some() + { + crate::log_info!("Trusted repo key for '{}' installed", repo_name); } else if !repo.allow_unsigned { anyhow::bail!( "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() { // No key was trusted/installed, and allow_unsigned=true already handled above. } 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, - Err(initial_err) => { - 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, - )? { - crate::log_info!( - "Trusted repo key for '{}' installed at {}", - 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(|| { + if 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!("Trusted repo key for '{}' installed", repo_name); + 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!( + "Failed to verify detached signature for binary repo '{}'", + repo_name + ) + }); } - }; + } crate::log_info!( - "Verified detached signature for binary repo '{}' using {}", - repo_name, - verified_key.display() + "Verified detached signature for binary repo '{}'", + repo_name ); } } diff --git a/src/deps.rs b/src/deps.rs index 4592ef8..ced54d4 100755 --- a/src/deps.rs +++ b/src/deps.rs @@ -9,8 +9,7 @@ //! - `package<=1.2.3` - less than or equal to 1.2.3 use crate::db; -use crate::package::{BuildType, PackageSpec}; -use crate::ui; +use crate::package::PackageSpec; use anyhow::Result; use std::collections::HashSet; 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. pub fn is_dep_satisfied_in_db(dep: &str, db_path: &Path) -> Result { if !db_path.exists() { @@ -329,106 +317,6 @@ pub(crate) fn check_test_deps_for_outputs( 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. pub(crate) fn require_build_deps_for_outputs( spec: &PackageSpec, @@ -486,6 +374,7 @@ pub(crate) fn require_test_deps_for_outputs( #[cfg(test)] mod tests { use super::*; + use crate::package::BuildType; fn test_spec_with_build( 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>=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, - &[] - ))); - } } diff --git a/src/planner.rs b/src/planner.rs index 7b4c344..ee7e8d9 100644 --- a/src/planner.rs +++ b/src/planner.rs @@ -44,48 +44,12 @@ pub(crate) struct PlannedStep { pub requested_by: Vec, } -impl PlannedStep { - pub(crate) fn download_size(&self) -> Option { - 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)] pub(crate) struct ExecutionPlan { pub steps: Vec, } 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 { self.steps .iter()