Skip to main content

determine_dependency_source

Function determine_dependency_source 

Source
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 DependencySource and a flag indicating core membership.

Details:

  • Prefers inspecting pacman -Qi metadata when the package is installed; otherwise defaults to heuristics.
  • For installed packages: uses pacman -Qi to read the “Repository” field.
  • For uninstalled packages: uses pacman -Si to 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=C and LANG=C for 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);