A Rust interface to the pkgsrc infrastructure, binary package archives, and the pkg_install pkgdb.
This is being developed alongside:
- bob, a pkgsrc package builder.
- mktool, a collection of tools that provide fast alternate implementations for various pkgsrc/mk scripts.
- pm, an exploration of what a binary package manager might look like (not currently being developed).
You should expect things to change over time as each interface adapts to better support these utilities, though I will still make sure to use semver versioning accordingly to avoid gratuitously breaking downstream utilities.
This is a simple implementation of pkg_info(8) that supports the default
output format, i.e. list all currently installed packages and their single-line
comment.
use pkgsrc::pkgdb::PkgDB;
use pkgsrc::MetadataEntry;
use std::path::Path;
fn main() -> std::io::Result<()> {
let pkgdb = PkgDB::open(Path::new("/var/db/pkg"))?;
for pkg in pkgdb {
let pkg = pkg?;
let comment = pkg.read_metadata(MetadataEntry::Comment)?;
println!("{:<19} {}", pkg.pkgname(), comment.trim());
}
Ok(())
}See examples/pkg_info.rs
for a more complete implementation.
archive: Read and write binary packages, supporting both unsigned (compressed tarballs) and signed (ar(1)archives with GPG signatures) formats. Includes low-level streaming API and high-levelPackagetype for fast metadata access.digest: Cryptographic hashing using BLAKE2s, MD5, RMD160, SHA1, SHA256, and SHA512, with special handling for pkgsrc patch files.distinfo: Parse and processdistinfofiles containing checksums for distfiles and patches.kv: Key-value parsing utilities.pkgdb: Handle local pkg databases, supporting the regular file-backed repository.plist: Parse and generate packing lists (PLISTfiles) with support for all@commands.summary: Parse and generatepkg_summary(5)metadata with full validation and span-aware error reporting.Pattern,Depend,Dewey: Package matching withpkg_match()semantics, verified correct against a large corpus of real-world matches.
The current requirements are:
edition = "2024"rust-version = "1.85.1"
This project is licensed under the ISC license.