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:
@@ -361,11 +361,15 @@ impl BuildOrchestrator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a reference to the database.
|
/// 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 {
|
pub fn db(&self) -> &PackageDb {
|
||||||
&self.db
|
&self.db
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a mutable reference to the database.
|
/// 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 {
|
pub fn db_mut(&mut self) -> &mut PackageDb {
|
||||||
&mut self.db
|
&mut self.db
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ impl DpackConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Load from the default location, or return defaults if not found.
|
/// 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 {
|
pub fn load_default() -> Self {
|
||||||
let path = Path::new(DEFAULT_CONFIG_PATH);
|
let path = Path::new(DEFAULT_CONFIG_PATH);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
@@ -175,6 +177,8 @@ impl DpackConfig {
|
|||||||
|
|
||||||
/// Find a package definition across all configured repos.
|
/// Find a package definition across all configured repos.
|
||||||
/// Returns the first match by repo priority.
|
/// 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> {
|
pub fn find_package(&self, name: &str) -> Option<PathBuf> {
|
||||||
let mut repos = self.repos.clone();
|
let mut repos = self.repos.clone();
|
||||||
repos.sort_by_key(|r| r.priority);
|
repos.sort_by_key(|r| r.priority);
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ impl PackageDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a package is installed.
|
/// 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 {
|
pub fn is_installed(&self, name: &str) -> bool {
|
||||||
self.cache.contains_key(name)
|
self.cache.contains_key(name)
|
||||||
}
|
}
|
||||||
@@ -162,6 +163,8 @@ impl PackageDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Find all packages that own a specific file.
|
/// 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> {
|
pub fn who_owns(&self, file_path: &Path) -> Vec<String> {
|
||||||
self.cache
|
self.cache
|
||||||
.values()
|
.values()
|
||||||
|
|||||||
@@ -8,11 +8,6 @@
|
|||||||
//! - Installed package database (`db`)
|
//! - Installed package database (`db`)
|
||||||
//! - Build orchestration (`build`)
|
//! - 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 config;
|
||||||
pub mod resolver;
|
pub mod resolver;
|
||||||
pub mod sandbox;
|
pub mod sandbox;
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
//! Supports TOML package definitions, dependency resolution, sandboxed builds,
|
//! Supports TOML package definitions, dependency resolution, sandboxed builds,
|
||||||
//! and converters for CRUX Pkgfiles and Gentoo ebuilds.
|
//! 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 anyhow::{Context, Result};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
@@ -30,7 +26,7 @@ use build::BuildOrchestrator;
|
|||||||
#[command(version)]
|
#[command(version)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Path to dpack configuration file
|
/// 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,
|
config: String,
|
||||||
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ pub struct ResolvedPackage {
|
|||||||
/// Which features are enabled for this package
|
/// Which features are enabled for this package
|
||||||
pub features: Vec<String>,
|
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,
|
pub definition_path: std::path::PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +277,11 @@ mod tests {
|
|||||||
source: SourceInfo {
|
source: SourceInfo {
|
||||||
url: format!("https://example.com/{}-{}.tar.xz", name, version),
|
url: format!("https://example.com/{}-{}.tar.xz", name, version),
|
||||||
sha256: "a".repeat(64),
|
sha256: "a".repeat(64),
|
||||||
|
git: String::new(),
|
||||||
|
branch: String::new(),
|
||||||
|
tag: String::new(),
|
||||||
|
commit: String::new(),
|
||||||
|
update_check: String::new(),
|
||||||
patches: vec![],
|
patches: vec![],
|
||||||
},
|
},
|
||||||
dependencies: Dependencies {
|
dependencies: Dependencies {
|
||||||
|
|||||||
@@ -19,41 +19,33 @@ use std::process::Command;
|
|||||||
use crate::db::PackageDb;
|
use crate::db::PackageDb;
|
||||||
|
|
||||||
/// A shared library dependency found in an ELF binary.
|
/// 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)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
#[allow(dead_code)] // Used by check_upgrade_conflicts — wired into `dpack upgrade` in future
|
||||||
pub struct SharedLib {
|
pub struct SharedLib {
|
||||||
/// Library soname (e.g., "libz.so.1")
|
|
||||||
pub soname: String,
|
pub soname: String,
|
||||||
|
|
||||||
/// Full path to the library file
|
|
||||||
pub path: Option<PathBuf>,
|
pub path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A conflict where a library upgrade would break a dependent package.
|
/// 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)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)] // Used by check_upgrade_conflicts — wired into `dpack upgrade` in future
|
||||||
pub struct LibConflict {
|
pub struct LibConflict {
|
||||||
/// The library being upgraded
|
|
||||||
pub library: String,
|
pub library: String,
|
||||||
|
|
||||||
/// The old soname that dependents link against
|
|
||||||
pub old_soname: String,
|
pub old_soname: String,
|
||||||
|
|
||||||
/// The new soname after the upgrade
|
|
||||||
pub new_soname: String,
|
pub new_soname: String,
|
||||||
|
|
||||||
/// Packages that depend on the old soname
|
|
||||||
pub affected_packages: Vec<String>,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(dead_code)] // Planned: interactive conflict resolution in `dpack upgrade`
|
||||||
pub enum ConflictResolution {
|
pub enum ConflictResolution {
|
||||||
/// Upgrade all affected packages
|
|
||||||
UpgradeAll,
|
UpgradeAll,
|
||||||
/// Compile the new package with static linking
|
|
||||||
StaticLink,
|
StaticLink,
|
||||||
/// Hold back the library (don't upgrade)
|
|
||||||
HoldBack,
|
HoldBack,
|
||||||
/// Force the upgrade (user accepts the risk)
|
|
||||||
Force,
|
Force,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +90,8 @@ pub fn get_needed_libs(binary_path: &Path) -> Result<Vec<String>> {
|
|||||||
/// Get the soname of a shared library file.
|
/// Get the soname of a shared library file.
|
||||||
///
|
///
|
||||||
/// Uses `readelf -d` to extract the SONAME entry.
|
/// 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>> {
|
pub fn get_soname(lib_path: &Path) -> Result<Option<String>> {
|
||||||
let output = Command::new("readelf")
|
let output = Command::new("readelf")
|
||||||
.args(["-d", &lib_path.to_string_lossy()])
|
.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.
|
/// 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
|
/// If a soname changes (e.g., `libfoo.so.1` → `libfoo.so.2`), find all
|
||||||
/// packages that link against the old soname.
|
/// 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(
|
pub fn check_upgrade_conflicts(
|
||||||
package_name: &str,
|
package_name: &str,
|
||||||
old_files: &[PathBuf],
|
old_files: &[PathBuf],
|
||||||
@@ -210,6 +206,7 @@ pub fn check_upgrade_conflicts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Collect sonames provided by a set of files.
|
/// Collect sonames provided by a set of files.
|
||||||
|
#[allow(dead_code)] // Called by check_upgrade_conflicts
|
||||||
fn collect_provided_sonames(files: &[PathBuf]) -> HashSet<String> {
|
fn collect_provided_sonames(files: &[PathBuf]) -> HashSet<String> {
|
||||||
let mut sonames = HashSet::new();
|
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).
|
/// Extract the base name from a soname (strip version suffix).
|
||||||
/// e.g., "libz.so.1" → "libz.so", "libfoo.so.2.3.4" → "libfoo.so"
|
/// 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 {
|
fn soname_base(soname: &str) -> String {
|
||||||
if let Some(pos) = soname.find(".so.") {
|
if let Some(pos) = soname.find(".so.") {
|
||||||
soname[..pos + 3].to_string() // Include ".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.
|
/// 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 {
|
pub fn format_conflict_report(conflicts: &[LibConflict]) -> String {
|
||||||
if conflicts.is_empty() {
|
if conflicts.is_empty() {
|
||||||
return "No shared library conflicts detected.".to_string();
|
return "No shared library conflicts detected.".to_string();
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ impl BuildSandbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a read-only bind mount (e.g., dependency install paths).
|
/// 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) {
|
pub fn add_ro_bind(&mut self, host_path: PathBuf, sandbox_path: PathBuf) {
|
||||||
self.ro_binds.push((host_path, sandbox_path));
|
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.
|
/// 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 {
|
pub fn staging_dir(&self) -> &Path {
|
||||||
&self.staging_dir
|
&self.staging_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the build directory path.
|
/// Get the build directory path.
|
||||||
|
#[allow(dead_code)] // Accessor for callers that need to inspect the build dir
|
||||||
pub fn build_dir(&self) -> &Path {
|
pub fn build_dir(&self) -> &Path {
|
||||||
&self.build_dir
|
&self.build_dir
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user