-
Notifications
You must be signed in to change notification settings - Fork 0
Installation‐and‐Setup
This page guides you through installing and setting up libfasttree in your Rust project. We'll cover prerequisites, adding the crate, and basic configuration. The process is straightforward, assuming you have Rust installed.
Before installing libfasttree, ensure you have:
- Rust and Cargo: Version 1.60 or higher. Install from rustup.rs.
-
SQLite: libfasttree uses SQLx with SQLite for its database. Ensure
libsqlite3is installed on your system:- Ubuntu/Debian:
sudo apt install libsqlite3-dev - Fedora:
sudo dnf install sqlite-devel - macOS:
brew install sqlite
- Ubuntu/Debian:
- Root Privileges: Some operations (e.g., mounting filesystems, changing ownership) require running as root or with sudo.
-
Optional Dependencies:
- For FS-Verity: A Linux kernel with FS-Verity support (4.19+).
- For TPM: A system with TPM 2.0 hardware and
tpm2-toolsinstalled. - For Btrfs/XFS: Filesystems supporting reflinks.
-
Build Tools:
pkg-configand a C compiler for dependencies like nix and gpgme.
Note: libfasttree has many dependencies (e.g., tokio, sqlx, nix). Check the Cargo.toml for the full list.
libfasttree is published on crates.io. Add it to your Cargo.toml:
[dependencies]
libfasttree = "0.0.1"Then, run cargo build to download and compile.
If you're cloning from GitHub for development:
git clone https://github.com/michal92299/libfasttree.git
cd libfasttree
cargo build-
Create Directories: libfasttree uses paths like
/var/lib/fasttree/objectsfor CAS. Create them with proper permissions:sudo mkdir -p /var/lib/fasttree/objects /sysroot /var/lib/extensions sudo chown $USER:$USER /var/lib/fasttree /sysroot /var/lib/extensions
-
Database Initialization: The library creates
db.sqliteautomatically, but ensure the path is writable. -
TPM Configuration (Optional): If using TPM, configure the Tcti (e.g.,
Tcti::Tpmtisfor software simulator orTcti::Devicefor hardware). -
Zstd Dictionaries (Optional): For compression, prepare dictionaries for common file types (e.g., ELF binaries). Add them to
Config::zstd_dicts.
Import and initialize FastTree:
use libfasttree::{Config, DistroType, BootloaderType, FilesystemType, PartitioningType, FastTree};
use std::path::PathBuf;
use tss_esapi::tcti::Tcti;
use tokio;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config {
repo_url: "http://deb.debian.org/debian".to_string(),
distro_type: DistroType::Apt,
cas_dir: PathBuf::from("/var/lib/fasttree/objects"),
db_path: PathBuf::from("/var/lib/fasttree/db.sqlite"),
deployments_dir: PathBuf::from("/sysroot"),
current_link: PathBuf::from("/ostree/current"),
boot_dir: PathBuf::from("/boot"),
bootloader: BootloaderType::SystemdBoot,
filesystem: FilesystemType::Btrfs,
health_check_script: None,
overlay_dirs: vec![PathBuf::from("/etc")],
var_volume: None,
gpg_keyring: PathBuf::from("/etc/apt/trusted.gpg"),
use_fsverity: false,
use_ima: false,
partitioning: PartitioningType::Subvolumes,
sysext_dir: PathBuf::from("/var/lib/extensions"),
zstd_dicts: std::collections::HashMap::new(),
tpm_tcti: Tcti::Tpmtis,
};
let mut ft = FastTree::new(config).await?;
// Now use ft for operations
Ok(())
}Run a simple test: cargo run. If it initializes without errors, you're set. For root-required ops, use sudo cargo run.
- Permission Denied: Run with sudo or adjust ownership.
-
Missing Dependencies: Install system packages for crates like nix (e.g.,
libudev-dev). - TPM Errors: Ensure TPM is enabled in BIOS and tools are installed.
Next: Proceed to Configuration Guide for detailed config options.
Last updated: February 11, 2026