debian_packaging/
lib.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5/*! Debian packaging primitives.
6
7This crate defines pure Rust implementations of Debian packaging primitives. Debian packaging
8(frequently interacted with by tools like `apt` and `apt-get`) provides the basis for
9packaging on Debian-flavored Linux distributions like Debian and Ubuntu.
10
11# Goals
12
13## Compliance and Compatibility
14
15We want this crate to be as-compliant and as-compatible as possible with in-the-wild Debian
16packaging deployments so it can be used as a basis to implementing tools which consume and
17produce entities that are compatible with the official Debian packaging implementations.
18
19This crate could be considered an attempt to reimplement aspects of
20[apt](https://salsa.debian.org/apt-team/apt) in pure Rust. (The `apt` repository defines
21command line tools like `apt-get` as well as libraries like `libapt-pkg` and `libapt-inst`.
22This crate is more focused on providing the library-level interfaces. However, a goal is
23to have as much code be usable as a library so the surface area of any tools is minimal.)
24
25## Determinism and Reproducibility
26
27To help combat the rise in software supply chain attacks and to make debugging and testing
28easier, a goal of this crate is to be as deterministic and reproducible as possible.
29
30Given the same source code / version of this crate, operations like creating a `.deb` file
31or building a repository from indexed `.deb` files should be as byte-for-byte identical as
32reasonably achievable.
33
34## Performance
35
36We strive for highly optimal implementations of packaging primitives wherever possible.
37
38We want to facilitate intensive operations (like reading all packages in a Debian
39repository) or publishing to a repository to scale out to as many CPU cores as possible.
40
41Read operations like parsing control files or version strings should be able to use
420-copy to avoid excessive memory allocations and copying.
43
44# A Tour of Functionality
45
46A `.deb` file defines a Debian package. Readers and writers of `.deb` files exist in the
47[deb] module. To read the contents of a `.deb` defining a binary package, use
48[deb::reader::BinaryPackageReader]. To create new `.deb` files, use [deb::builder::DebBuilder].
49
50A common primitive within Debian packaging is *control files*. These consist of *paragraphs*
51of key-value metadata. Low-level control file primitives are defined in the [control] module.
52[control::ControlParagraph] defines a paragraph, which consists of [control::ControlField].
53[control::ControlFile] provides an interface for a *control file*, which consists of multiple
54paragraphs. [control::ControlParagraphReader] implements a streaming reader of control files
55and [control::ControlParagraphAsyncReader] implements an asynchronous streaming reader.
56
57There are different flavors of *control files* within Debian packaging.
58[binary_package_control::BinaryPackageControlFile] defines a *control file* for a binary package.
59This type provides helper functions for resolving common fields on binary control files.
60[debian_source_control::DebianSourceControlFile] defines a *control file* for a source package,
61as expressed in a `.dsc` file.
62
63There is a meta language for expressing dependencies between Debian packages. The
64[dependency] module defines types for parsing and writing this language. e.g.
65[dependency::DependencyList] represents a parsed list of dependencies like
66`libc6 (>= 2.4), libx11-6`. [dependency::PackageDependencyFields] represents a collection
67of control fields that define relationships between packages.
68
69The [package_version] module implements Debian package version string parsing,
70serialization, and comparison. [package_version::PackageVersion] is the main type used for this.
71
72The [dependency_resolution] module implements functionality related to resolving dependencies.
73e.g. [dependency_resolution::DependencyResolver] can be used to index known binary packages
74and find direct and transitive dependencies. This could be used as the basis for a package
75manager or other tool wishing to walk the dependency tree for a given package.
76
77The [repository] module provides functionality related to Debian repositories, which are
78publications of Debian packages and metadata. The [repository::RepositoryRootReader] trait
79provides an interface for reading the root directory of a repository and
80[repository::ReleaseReader] provides an interface for reading content from a parsed
81`[In]Release` file. The [repository::RepositoryWriter] trait abstracts I/O for writing
82to a repository. Repository interaction involves many support primitives.
83[repository::release::ReleaseFile] represents an `[In]Release` file. Support for verifying
84PGP signatures is provided. [repository::contents::ContentsFile] represents a `Contents`
85file.
86
87Concrete implementations of repository interaction exist. [repository::http::HttpRepositoryClient]
88enables reading from an HTTP-hosted repository (e.g. `http://archive.canonical.com/ubuntu`).
89[repository::filesystem::FilesystemRepositoryWriter] enables writing repositories to a local
90filesystem.
91
92The [repository::builder] module contains functionality for creating and publishing
93Debian repositories. [repository::builder::RepositoryBuilder] is the main type for
94publishing Debian repositories.
95
96The [repository::copier] module contains functionality for copying Debian repositories.
97[repository::copier::RepositoryCopier] is the main type for copying Debian repositories.
98
99The [signing_key] module provides functionality related to PGP signing.
100[signing_key::DistroSigningKey] defines PGP public keys for well-known signing keys used by
101popular Linux distributions. [signing_key::signing_secret_key_params_builder()] and
102[signing_key::create_self_signed_key()] enable easily creating signing keys for Debian
103repositories.
104
105Various other modules provide miscellaneous functionality. [io] defines I/O helpers, including
106stream adapters for validating content digests on read and computing content digests on write.
107
108# Crate Features
109
110The optional and enabled-by-default `http` feature enables HTTP client support for interacting
111with Debian repositories via HTTP.
112*/
113
114pub mod binary_package_control;
115pub mod binary_package_list;
116pub mod changelog;
117pub mod control;
118pub mod deb;
119pub mod debian_source_control;
120pub mod debian_source_package_list;
121pub mod dependency;
122pub mod dependency_resolution;
123pub mod error;
124pub mod io;
125pub mod package_version;
126pub mod repository;
127pub mod signing_key;
128pub mod source_package_control;