-
Notifications
You must be signed in to change notification settings - Fork 0
Basic‐Usage
This page introduces the core operations of libfasttree: installing packages, building trees, committing changes, and deploying them. We'll walk through examples step-by-step, assuming you've set up the library as described in the Installation and Setup and Configuration Guide pages. All examples use async Rust code with Tokio.
- Resolve Dependencies: Use a solver to find required packages.
- Download and Verify: Fetch packages and check signatures (e.g., via Sigstore).
- Extract and Store in CAS: Extract files, compute hashes, compress/deduplicate, and store in content-addressed storage.
- Build Tree: Assemble an immutable filesystem tree from CAS objects.
- Commit Tree: Record the tree in the database with references.
- Deploy: Link the tree as current, set up overlays, update bootloader.
libfasttree handles most of this automatically via high-level methods like install and deploy.
The install method orchestrates the full process for a package and its dependencies.
use libfasttree::{Config, FastTree /* other imports from config */};
use std::path::PathBuf;
use tss_esapi::tcti::Tcti;
use tokio;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config {
// Fill in as per Configuration Guide
repo_url: "http://deb.debian.org/debian".to_string(),
distro_type: DistroType::Apt,
// ... other fields ...
};
let mut ft = FastTree::new(config).await?;
// Install "nginx" to the "stable" reference
ft.install("nginx", "stable").await?;
println!("Installation complete!");
Ok(())
}- resolve_dependencies: Fetches metadata and solves deps using a mock libsolv.
- download_package: Downloads and verifies with Sigstore/Cosign.
- extract_to_temp: Extracts to a temp dir, collects metadata (mode, uid, etc.).
- store_in_cas: Computes hashes, chunks files for dedup, compresses with Zstd (using dictionaries if set), applies FS-Verity/IMA, stores in DB and filesystem.
- build_tree: Assembles the tree, optionally snapshots (Btrfs), signs with TPM if enabled.
- commit_tree: Saves tree hash, packages, and ref in DB.
- generate_delta: Creates bsdiff delta from previous tree (if exists).
-
deploy: Calls
deploy("stable")internally.
Run with sudo cargo run if root ops are needed.
If you have a committed tree (e.g., from a previous install), deploy it separately:
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = /* ... */;
let mut ft = FastTree::new(config).await?;
// Deploy the "stable" ref
ft.deploy("stable").await?;
println!("Deployment complete!");
Ok(())
}- Queries DB for tree hash.
- Symlinks to
/ostree/current(or configured path). - Sets up OverlayFS for writable layers (e.g., /etc ephemeral changes).
- Merges configs with 3-way merge for /etc.
- Updates bootloader (Grub or systemd-boot) with new root flags.
- Loads sysext extensions.
- Runs health check if configured.
If deployment fails (e.g., health check), use rollback:
ft.rollback().await?;This switches to the previous tree hash and redeploys.
- Refs: Use meaningful names like "stable", "testing" for branches.
-
Testing: Start with
use_fsverity: falseand non-root to avoid kernel dependencies. -
Monitoring: Check DB (
db.sqlite) with SQLite tools for trees/refs. - Performance: On NVMe, async I/O shines for large installs.
For more on security during installs, see Security Features.
Next: Security Features
Last updated: February 11, 2026