Skip to content

jperkin/pkgsrc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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.

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.

About

Rust library for pkgsrc

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages