pub struct RepositoryBuilder<'cf> { /* private fields */ }
Expand description

Build Debian repositories from scratch.

Instances of this type are used to iteratively construct a Debian repository.

A Debian repository consists of named components holding binary packages, sources, installer packages, and metadata gluing it all together.

Usage

Instances are constructed, preferably via Self::new_recommended().

Additional metadata about the repository is then registered using the following functions (as needed):

See https://wiki.debian.org/DebianRepository/Format for a description of what these various fields are used for.

After basic metadata is in place, .deb packages are registered against the builder via Self::add_binary_deb().

Once everything is registered against the builder, it is time to publish (read: write) the repository content.

Publishing works by first writing pool content. The pool is an area of the repository where blobs (like .deb packages) are stored. To publish the pool, call Self::publish_pool_artifacts(). This takes a DataResolver for obtaining missing pool content. Its content retrieval functions will be called for each pool path that needs to be copied to the writer. Since crate::repository::RepositoryRootReader must implement DataResolver, you can pass an instance as the DataResolver to effectively copy artifacts from another Debian repository. Note: for this to work, the source repository must have the same PoolLayout as this repository. This may not always be the case! To more robustly copy files from another repository, instantiate a crate::io::PathMappingDataResolver and call crate::io::PathMappingDataResolver::add_path_map() with the result from Self::add_binary_deb() (and similar function) to install a path mapping.

Implementations

Create a new instance with recommended settings.

Files that should almost always be set (like Architectures and Components) are empty. It is recommended to use Self::new_recommended() instead.

Create a new instance with recommended settings and fields.

The arguments to this function are those that should be defined on most Debian repositories.

Calling this function is equivalent to calling Self::new_recommended_empty() then calling various .add_*() methods on the returned instance.

Register an architecture with the builder.

This defines which platform architectures there will be packages for.

Example architecture values are all, amd64, arm64, and i386.

Register a named component with the builder.

Components describe a named subset of the repository. Example names include main, contrib, restricted, stable.

Register a checksum type to emit.

ChecksumType::Sha256 should always be used. Adding ChecksumType::Md5 is recommended for compatibility with old clients.

Set the Suite value.

This is often a value like stable, bionic, groovy. Some identifier that helps identify this repository.

Set the Codename value.

This is often a human friendly name to help identify the repository. Example values include groovy, bullseye, bionic.

Set the time this repository was created/updated.

If not set, the current time will be used automatically.

Set the value for the Valid-Until field.

Clients should not trust this repository after this date.

Set a human friendly description text for this repository.

Set a field indicating the origin of the repository.

Set freeform text describing the repository.

Set the version of the release.

Typically . delimited integers.

Set the value of Acquire-By-Hash.

This should be enabled for new repositories.

Set the PoolLayout to use.

The layout can only be updated before content is added. Once a package has been indexed, this function will error.

Add a binary package .deb to this repository in the given component.

The package to add is specified as a trait to enable callers to represent Debian packages differently. For example, the trait members may be implemented by just-in-time parsing of an actual .deb file or by retrieving the data from a cache.

The specified component name must be registered with this instance or an error will occur.

Returns the pool path / Filename field that this binary package .deb will occupy in the repository.

Obtain all components having binary packages.

The iterator contains 2-tuples of (component, architecture).

Obtain an iterator of ControlParagraph for binary packages in a given component + architecture.

This method forms the basic building block for constructing Packages files. Packages files can be built by serializing the ControlParagraph to a string/writer.

Obtain an iterator of pool artifacts for binary packages that will need to exist.

Obtain an [AsyncRead] that reads contents of a Packages file for binary packages.

This is a wrapper around Self::iter_component_binary_packages() that normalizes the ControlParagraph to data and converts it to an [AsyncRead].

Like Self::component_binary_packages_reader() except data is compressed.

Obtain IndexFileReader for each logical Packages file.

Obtain all IndexFileReader to be published.

Each item corresponds to a logical item in an [In]Release.

Obtain records describing pool artifacts needed to support binary packages.

Publish artifacts to the pool.

The pool is the area of a Debian repository holding files like the .deb packages.

Content must be published to the pool before indices data is written, otherwise there is a race condition where the indices could refer to files not yet in the pool.

Derive a ReleaseFile representing the content of the Release file.

This takes an iterable describing indices files. This iterable is typically derived from Self::index_file_readers().

Publish index files.

Repository index files describe the contents of the repository. Index files are referred to by the InRelease and Release files.

Indices should only be published after pool artifacts are published. Otherwise there is a race condition where an index file could refer to a file in the pool that does not exist.

Publish the repository to the given RepositoryWriter.

This is the main function for writing out the desired state in this builder.

Publishing effectively works in 3 phases:

  1. Publish missing pool artifacts.
  2. Publish indices files (e.g. Packages lists).
  3. Publish the InRelease and Release file.

writer is a RepositoryWriter used to perform I/O for writing output files. resolver is a DataResolver for resolving pool paths. It will be consulted to obtain paths of .deb and other pool files. distribution_path is the relative path under writer to write indices files under. It typically begins with dists/. e.g. dists/bullseye. This value becomes the directory with the generated InRelease file. threads is the number of parallel threads to use for I/O. progress_cb provides an optional function to receive progress updates. signing_key provides a signing key for PGP signing and an optional function to obtain the password to unlock that key.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more