pub fn determine_dependency_source<S: BuildHasher>(
name: &str,
installed: &HashSet<String, S>,
) -> (DependencySource, bool)Expand description
What: Infer the origin repository for a dependency currently under analysis.
Inputs:
name: Candidate dependency package name.installed: Set of locally installed package names used to detect presence.
Output:
- Returns a tuple with the determined
DependencySourceand a flag indicating core membership.
Details:
- Prefers inspecting
pacman -Qimetadata when the package is installed; otherwise defaults to heuristics. - For installed packages: uses
pacman -Qito read the “Repository” field. - For uninstalled packages: uses
pacman -Sito check if it exists in official repositories. - Handles local packages (repo = “local” or empty) specially.
- Downgrades gracefully to official classifications when the repository field cannot be read.
- Sets
LC_ALL=CandLANG=Cfor consistent locale-independent output. - Returns reasonable defaults when pacman is unavailable (graceful degradation).
§Example
use arch_toolkit::deps::determine_dependency_source;
use std::collections::HashSet;
let installed = HashSet::from(["glibc".to_string()]);
let (source, is_core) = determine_dependency_source("glibc", &installed);
println!("Source: {:?}, Is core: {}", source, is_core);