Expand description
Read and write pkgsrc binary packages.
pkgsrc binary packages come in two formats:
-
Unsigned packages: Compressed tar archives (
.tgz,.tbz, etc.) containing package metadata (+CONTENTS,+COMMENT,+DESC, etc.) and the package files. -
Signed packages:
ar(1)archives containing:+PKG_HASH: Hash metadata for verification+PKG_GPG_SIGNATURE: GPG signature of the hash file- The original compressed tarball
This module provides a two-layer API:
§Low-level (tar-style streaming)
§High-level (convenience)
BinaryPackage: Cached metadata with fast reads and convenience methodsSignedArchive: Output type for signed packages
§Examples
§Fast metadata reading
use pkgsrc::archive::BinaryPackage;
let pkg = BinaryPackage::open("package-1.0.tgz")?;
println!("Package: {}", pkg.pkgname().unwrap_or("unknown"));
println!("Comment: {}", pkg.metadata().comment());
// Convert to summary for repository management
let summary = pkg.to_summary()?;§Installing a package (iterating entries)
use pkgsrc::archive::BinaryPackage;
let pkg = BinaryPackage::open("package-1.0.tgz")?;
// Check dependencies first (fast, uses cached metadata)
for dep in pkg.plist().depends() {
println!("Depends: {}", dep);
}
// Extract files (re-reads archive)
pkg.extract_to("/usr/pkg")?;§Building a new package
use pkgsrc::archive::Builder;
// Auto-detect compression from filename
let mut builder = Builder::create("package-1.0.tgz")?;
builder.append_metadata_file("+COMMENT", b"A test package")?;
builder.append_file("bin/hello", b"#!/bin/sh\necho hello", 0o755)?;
builder.finish()?;§Signing an existing package
use pkgsrc::archive::BinaryPackage;
let pkg = BinaryPackage::open("package-1.0.tgz")?;
let signature = b"GPG SIGNATURE DATA";
pkg.sign(signature)?.write_to("package-1.0-signed.tgz")?;Structs§
- Archive
- Low-level streaming access to package archives.
- Binary
Package - A pkgsrc binary package with cached metadata.
- Builder
- Build a new compressed package archive.
- Checksum
Failure - A single failure reported by
BinaryPackage::verify_checksums. - Extract
Options - Options for extracting package files.
- Extracted
File - Result of extracting a single file.
- Members
- Iterator over a package’s leading metadata members.
- Metadata
Member - A single metadata member yielded by
Members. - Metadata
Reader - Streaming reader for a binary package’s leading metadata members.
- PkgHash
- The
+PKG_HASHfile contents for signed packages. - Signed
Archive - A signed binary package ready to be written.
- Summary
Options - Options for converting a
BinaryPackageto aSummary.
Enums§
- Archive
Error - Error type for archive operations.
- Archive
Type - Type of binary package archive.
- Checksum
Failure Kind - Reason a file failed checksum verification.
- Compression
- Compression format for package archives.
- PkgHash
Algorithm - Hash algorithm used for package signing.
Constants§
- DEFAULT_
BLOCK_ SIZE - Default block size for package hashing (64KB).
- PKGSRC_
SIGNATURE_ VERSION - Current pkgsrc signature version.
Type Aliases§
- Result
- Result type for archive operations.