Module distinfo

Module distinfo 

Source
Expand description

pkgsrc distinfo file parsing and processing.

Most packages have a distinfo file that describes all of the source distribution files (known in pkgsrc nomenclature as distfiles) used by the package, as well as any pkgsrc patches that are applied to the unpacked source code.

Each distinfo file primarily contains checksums for each file, to ensure integrity of both downloaded distfiles as well as the applied patches. For additional integrity, distfiles usually contain two hashes from different digest algorithms. They also usually include the size of the file. Patch files usually just have a single hash.

The first line is usually a $NetBSD$ RCS Id, and the second line is usually blank. Thus an example distinfo file and how to parse it looks something like this:

use pkgsrc::distinfo::Distinfo;
use std::ffi::OsString;

let input = r#"
    $NetBSD: distinfo,v 1.80 2024/05/27 23:27:10 riastradh Exp $

    BLAKE2s (pkgin-23.8.1.tar.gz) = eb0f008ba9801a3c0a35de3e2b2503edd554c3cb17235b347bb8274a18794eb7
    SHA512 (pkgin-23.8.1.tar.gz) = 2561d9e4b28a9a77c3c798612ec489dd67dd9a93c61344937095b0683fa89d8432a9ab8e600d0e2995d954888ac2e75a407bab08aa1e8198e375c99d2999f233
    Size (pkgin-23.8.1.tar.gz) = 267029 bytes
    SHA1 (patch-configure.ac) = 53f56351fb602d9fdce2c1ed266d65919a369086
    "#;
let distinfo = Distinfo::from_bytes(&input.as_bytes());
assert_eq!(distinfo.rcsid(), Some(&OsString::from("$NetBSD: distinfo,v 1.80 2024/05/27 23:27:10 riastradh Exp $")));

As distinfo files can contain usernames and filenames that are not UTF-8 clean (for example ISO-8859), from_bytes() is the method used to parse input, and the rcsid and filename portions are parsed as OsString. The remaining sections must be UTF-8 clean and are regular Strings.

Structs§

Checksum
Checksum contains the Digest type and the String hash the digest algorithm calculated for an associated Entry.
Distinfo
Distinfo contains the contents of a distinfo file.
Entry
Entry contains the information stored about each unique file listed in the distinfo file.

Enums§

DistinfoError
Possible errors returned by various Distinfo operations.
EntryType
Type of this Entry, either Distfile (the default) or Patchfile.