Skip to main content

Module sandbox

Module sandbox 

Source
Expand description

Sandbox module for build-preflight dependency and static PKGBUILD analysis.

Given a package’s PKGBUILD or .SRCINFO, this module compares its declared dependencies against the host’s installed packages and reports, per category (depends, makedepends, checkdepends, optdepends):

  • whether each dependency is installed (or provided) on the host,
  • the installed version, and
  • whether the declared version constraint is satisfied.

It answers “what would I need to install to build this AUR package?” before any build starts — ported from Pacsea’s sandbox preflight. The optional security analysis reads PKGBUILD text only: it never executes, sources, expands, or builds that content, and it reports stable rule IDs and explicit limitations instead of an aggregate risk score.

§Features

This module requires the sandbox feature flag (which enables deps for parsing and querying):

[dependencies]
arch-toolkit = { version = "0.2", features = ["sandbox"] }

§Examples

§Analyze a PKGBUILD Against the Host

use arch_toolkit::deps::{get_installed_packages, get_provided_packages};
use arch_toolkit::sandbox::analyze_pkgbuild;

let pkgbuild = std::fs::read_to_string("PKGBUILD")?;
let installed = get_installed_packages().unwrap_or_default();
let provided = get_provided_packages(&installed);

let info = analyze_pkgbuild("my-package", &pkgbuild, &installed, &provided);
if info.is_ready_to_build() {
    println!("All build dependencies present");
} else {
    println!("Missing: {:?}", info.missing_packages());
}

§Analyze an AUR Package via .SRCINFO (with the aur feature)

use arch_toolkit::deps::{fetch_srcinfo, get_installed_packages, get_provided_packages};
use arch_toolkit::sandbox::analyze_srcinfo;

let client = reqwest::Client::new();
let srcinfo = fetch_srcinfo(&client, "yay").await?;
let installed = get_installed_packages().unwrap_or_default();
let provided = get_provided_packages(&installed);
let info = analyze_srcinfo("yay", &srcinfo, &installed, &provided);
println!("{} missing dependencies", info.missing_packages().len());

Re-exports§

pub use crate::types::sandbox::DependencyDelta;
pub use crate::types::sandbox::SandboxAnalysisLimitation;
pub use crate::types::sandbox::SandboxFinding;
pub use crate::types::sandbox::SandboxInfo;
pub use crate::types::sandbox::SandboxRuleId;
pub use crate::types::sandbox::SandboxStaticAnalysis;

Functions§

analyze_dependencies
What: Analyze dependency specs against the host environment.
analyze_pkgbuild
What: Analyze a package’s dependencies from PKGBUILD content.
analyze_pkgbuild_security
What: Analyze unexecuted PKGBUILD text for deterministic threat-model signals.
analyze_srcinfo
What: Analyze a package’s dependencies from .SRCINFO content.
extract_package_name
What: Extract the bare package name from a dependency specification.