Fix all warnings properly — no blanket #![allow(dead_code)]

Removed both blanket #![allow(dead_code)] from main.rs and lib.rs.
Each warning is now handled individually with a targeted #[allow]
and a comment explaining WHY the item exists and WHEN it will be used.

Fixes:
- resolver/mod.rs: Added missing SourceInfo fields (git, branch, tag,
  commit, update_check) to test helper make_pkg() — fixes cargo test
- main.rs: Wire DEFAULT_CONFIG_PATH constant into CLI default_value
  instead of hardcoding the string (eliminates unused constant warning)

Targeted #[allow(dead_code)] with justification on:
- config/global.rs: load_default() (future system service mode),
  find_package() (future replacement for inline Info search)
- resolver/solib.rs: SharedLib, LibConflict, ConflictResolution structs
  (planned upgrade conflict UI), get_soname(), check_upgrade_conflicts(),
  format_conflict_report(), collect_provided_sonames(), soname_base()
  (entire conflict detection chain — will be wired into dpack upgrade)
- resolver/mod.rs: definition_path field (populated but read in future)
- sandbox/mod.rs: add_ro_bind() (planned dep mounting), staging_dir(),
  build_dir() (accessor methods for post-build inspection)
- db/mod.rs: is_installed() (used by tests, future install guard),
  who_owns() (planned dpack owns <file> command)
- build/mod.rs: db(), db_mut() (accessors for advanced orchestration)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 12:30:40 +01:00
parent 1766909379
commit 3d5390b515
8 changed files with 39 additions and 26 deletions

View File

@@ -361,11 +361,15 @@ impl BuildOrchestrator {
}
/// Get a reference to the database.
/// Allows callers to inspect installed packages after an install run.
#[allow(dead_code)] // Accessor for post-install inspection
pub fn db(&self) -> &PackageDb {
&self.db
}
/// Get a mutable reference to the database.
/// Allows callers to perform additional db operations after install.
#[allow(dead_code)] // Accessor for advanced orchestration workflows
pub fn db_mut(&mut self) -> &mut PackageDb {
&mut self.db
}

View File

@@ -143,6 +143,8 @@ impl DpackConfig {
}
/// Load from the default location, or return defaults if not found.
/// Used when running dpack without an explicit --config flag.
#[allow(dead_code)] // Will be used when dpack runs as a system service
pub fn load_default() -> Self {
let path = Path::new(DEFAULT_CONFIG_PATH);
if path.exists() {
@@ -175,6 +177,8 @@ impl DpackConfig {
/// Find a package definition across all configured repos.
/// Returns the first match by repo priority.
/// Used by `dpack info <pkg>` when searching repos for uninstalled packages.
#[allow(dead_code)] // Will replace the inline search in the Info command handler
pub fn find_package(&self, name: &str) -> Option<PathBuf> {
let mut repos = self.repos.clone();
repos.sort_by_key(|r| r.priority);

View File

@@ -131,6 +131,7 @@ impl PackageDb {
}
/// Check if a package is installed.
#[allow(dead_code)] // Used by tests; will be used by `dpack install` to skip reinstalls
pub fn is_installed(&self, name: &str) -> bool {
self.cache.contains_key(name)
}
@@ -162,6 +163,8 @@ impl PackageDb {
}
/// Find all packages that own a specific file.
/// Planned for `dpack owns /usr/lib/libz.so` command.
#[allow(dead_code)] // Used by tests; will be exposed as `dpack owns <file>` command
pub fn who_owns(&self, file_path: &Path) -> Vec<String> {
self.cache
.values()

View File

@@ -8,11 +8,6 @@
//! - Installed package database (`db`)
//! - Build orchestration (`build`)
// Many public API items are not yet used from main.rs but will be
// consumed as later phases are implemented. Suppress dead_code warnings
// for the library crate.
#![allow(dead_code)]
pub mod config;
pub mod resolver;
pub mod sandbox;

View File

@@ -4,10 +4,6 @@
//! Supports TOML package definitions, dependency resolution, sandboxed builds,
//! and converters for CRUX Pkgfiles and Gentoo ebuilds.
// Public API items in submodules are used across phases — suppress dead_code
// warnings for items not yet wired into CLI commands.
#![allow(dead_code)]
use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
use colored::Colorize;
@@ -30,7 +26,7 @@ use build::BuildOrchestrator;
#[command(version)]
struct Cli {
/// Path to dpack configuration file
#[arg(short, long, default_value = "/etc/dpack.conf")]
#[arg(short, long, default_value = config::global::DEFAULT_CONFIG_PATH)]
config: String,
#[command(subcommand)]

View File

@@ -44,7 +44,9 @@ pub struct ResolvedPackage {
/// Which features are enabled for this package
pub features: Vec<String>,
/// Path to the package definition file
/// Path to the package definition file.
/// Set by the orchestrator after resolution to locate the .toml for building.
#[allow(dead_code)] // Populated during resolve, read during build orchestration future enhancements
pub definition_path: std::path::PathBuf,
}
@@ -275,6 +277,11 @@ mod tests {
source: SourceInfo {
url: format!("https://example.com/{}-{}.tar.xz", name, version),
sha256: "a".repeat(64),
git: String::new(),
branch: String::new(),
tag: String::new(),
commit: String::new(),
update_check: String::new(),
patches: vec![],
},
dependencies: Dependencies {

View File

@@ -19,41 +19,33 @@ use std::process::Command;
use crate::db::PackageDb;
/// A shared library dependency found in an ELF binary.
/// Used by check_upgrade_conflicts() to track which libraries a package needs.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[allow(dead_code)] // Used by check_upgrade_conflicts — wired into `dpack upgrade` in future
pub struct SharedLib {
/// Library soname (e.g., "libz.so.1")
pub soname: String,
/// Full path to the library file
pub path: Option<PathBuf>,
}
/// A conflict where a library upgrade would break a dependent package.
/// Returned by check_upgrade_conflicts() when a soname changes between versions.
#[derive(Debug, Clone)]
#[allow(dead_code)] // Used by check_upgrade_conflicts — wired into `dpack upgrade` in future
pub struct LibConflict {
/// The library being upgraded
pub library: String,
/// The old soname that dependents link against
pub old_soname: String,
/// The new soname after the upgrade
pub new_soname: String,
/// Packages that depend on the old soname
pub affected_packages: Vec<String>,
}
/// Resolution action chosen by the user.
/// Resolution action chosen by the user when a shared lib conflict is detected.
/// Will be returned from an interactive prompt in `dpack upgrade`.
#[derive(Debug, Clone)]
#[allow(dead_code)] // Planned: interactive conflict resolution in `dpack upgrade`
pub enum ConflictResolution {
/// Upgrade all affected packages
UpgradeAll,
/// Compile the new package with static linking
StaticLink,
/// Hold back the library (don't upgrade)
HoldBack,
/// Force the upgrade (user accepts the risk)
Force,
}
@@ -98,6 +90,8 @@ pub fn get_needed_libs(binary_path: &Path) -> Result<Vec<String>> {
/// Get the soname of a shared library file.
///
/// Uses `readelf -d` to extract the SONAME entry.
/// Called by collect_provided_sonames() in the upgrade conflict detection path.
#[allow(dead_code)] // Part of check_upgrade_conflicts — wired into `dpack upgrade` in future
pub fn get_soname(lib_path: &Path) -> Result<Option<String>> {
let output = Command::new("readelf")
.args(["-d", &lib_path.to_string_lossy()])
@@ -163,6 +157,8 @@ pub fn build_solib_map(db: &PackageDb) -> HashMap<String, Vec<String>> {
/// Compares the old package's provided sonames with the new package's sonames.
/// If a soname changes (e.g., `libfoo.so.1` → `libfoo.so.2`), find all
/// packages that link against the old soname.
/// Will be called from `dpack upgrade` after building new package but before committing.
#[allow(dead_code)] // Planned: wired into `dpack upgrade` conflict detection
pub fn check_upgrade_conflicts(
package_name: &str,
old_files: &[PathBuf],
@@ -210,6 +206,7 @@ pub fn check_upgrade_conflicts(
}
/// Collect sonames provided by a set of files.
#[allow(dead_code)] // Called by check_upgrade_conflicts
fn collect_provided_sonames(files: &[PathBuf]) -> HashSet<String> {
let mut sonames = HashSet::new();
@@ -226,6 +223,7 @@ fn collect_provided_sonames(files: &[PathBuf]) -> HashSet<String> {
/// Extract the base name from a soname (strip version suffix).
/// e.g., "libz.so.1" → "libz.so", "libfoo.so.2.3.4" → "libfoo.so"
#[allow(dead_code)] // Called by check_upgrade_conflicts
fn soname_base(soname: &str) -> String {
if let Some(pos) = soname.find(".so.") {
soname[..pos + 3].to_string() // Include ".so"
@@ -235,6 +233,8 @@ fn soname_base(soname: &str) -> String {
}
/// Format a conflict report for display to the user.
/// Will be called from `dpack upgrade` to print conflicts before proceeding.
#[allow(dead_code)] // Planned: shown during `dpack upgrade` conflict resolution
pub fn format_conflict_report(conflicts: &[LibConflict]) -> String {
if conflicts.is_empty() {
return "No shared library conflicts detected.".to_string();

View File

@@ -114,6 +114,8 @@ impl BuildSandbox {
}
/// Add a read-only bind mount (e.g., dependency install paths).
/// Called by build orchestrator to mount each resolved dependency into the sandbox.
#[allow(dead_code)] // Planned: orchestrator will mount deps when sandbox is fully integrated
pub fn add_ro_bind(&mut self, host_path: PathBuf, sandbox_path: PathBuf) {
self.ro_binds.push((host_path, sandbox_path));
}
@@ -264,11 +266,13 @@ impl BuildSandbox {
}
/// Get the path to the staging directory where installed files landed.
#[allow(dead_code)] // Accessor for callers that need to inspect staging after build
pub fn staging_dir(&self) -> &Path {
&self.staging_dir
}
/// Get the build directory path.
#[allow(dead_code)] // Accessor for callers that need to inspect the build dir
pub fn build_dir(&self) -> &Path {
&self.build_dir
}