Thanks to visit codestin.com
Credit goes to lib.rs

52 releases (10 breaking)

Uses new Rust 2024

0.11.0 Apr 24, 2026
0.9.0 Mar 17, 2026
0.5.6 Dec 31, 2025
0.4.2 Aug 27, 2025
0.1.15 Sep 23, 2019

#443 in Database interfaces


Used in 4 crates

ISC license

9MB
8K SLoC

pkgsrc-rs

Downloads Crates.io Documentation License

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.

Example

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 anyhow::Result;
use pkgsrc::metadata::FileRead;
use pkgsrc::pkgdb::PkgDB;

fn main() -> Result<()> {
    let pkgdb = PkgDB::open("/var/db/pkg")?;

    for pkg in pkgdb {
        let pkg = pkg?;
        println!("{:<19} {}", pkg.pkgname(), pkg.comment()?);
    }

    Ok(())
}

See examples/pkg_info.rs for a more complete implementation.

Features

  • 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-level Package type 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 process distinfo files 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 (PLIST files) with support for all @ commands.
  • summary: Parse and generate pkg_summary(5) metadata with full validation and span-aware error reporting.
  • Pattern, Depend, Dewey: Package matching with pkg_match() semantics, verified correct against a large corpus of real-world matches.

MSRV

The current requirements are:

  • edition = "2024"
  • rust-version = "1.85.1"

License

This project is licensed under the ISC license.

Dependencies

~6–11MB
~229K SLoC