Reference

repopulator package

AlpinePackage

A package in AlpineRepo

arch property

arch: str

Architecture of the package

fields property

fields: Mapping[str, str]

Information about package stored in the repository index

The available fields are documented at: https://wiki.alpinelinux.org/wiki/Apk_spec#APKINDEX_Format

name property

name: str

Name of the package

repo_filename property

repo_filename: str

Filename of the package when stored inside the repository

src_path property

src_path: Path

Path to the original package file

version_key property

version_key: VersionKey

Version of the package as a properly comparable key

version_str property

version_str: str

Version of the package as a string

__init__

__init__(src_path: Path, index: dict[str, str])

Internal do not use. Use AlpineRepo.add_package to create instances of this class

AlpineRepo

Generates Alpine apk repositories

architectures property

architectures: KeysView[str]

Architectures in this repository

description property

description

Repository description

__init__

__init__(desc: str)

Constructor for AlpineRepo class

Parameters:
  • desc (str) –

    repository description. This is the description shown when performing apk update

add_package

add_package(
    path: str | PathLike[str],
    force_arch: Optional[str] = None,
) -> AlpinePackage

Adds a package to the repository

Parameters:
  • path (str | PathLike[str]) –

    the path to .apk file for the package.

  • force_arch (Optional[str], default: None ) –

    the architecture (e.g. "x86_64", "aarch64", etc.) to use if the package that are marked "noarch". All Alpine packages in a repo must belong to some architecture.

Returns:
  • AlpinePackage

    an AlpinePackage object for the added package

del_package

del_package(package: AlpinePackage)

Removes a package from this repository

It is not an error to pass a package that is not in a repository to this function. It will be ignored in such case.

Parameters:

export

export(
    root: str | PathLike[str],
    signer: PkiSigner,
    signer_name: str,
    now: Optional[datetime] = None,
    keep_expanded: bool = False,
)

Export the repository into a given folder

This actually creates an on-disk repository suitable to serve to apk clients. If the directory to export to already exists the export process tries to handle pre-existing content there gracefully. Content that doesn't conflict with repository content will be left alone. Content that does conflict will be removed or overwritten.

Specifically any existing /*.apk files will be removed and replaced with the ones from the repository for the architectures in the repository.

Parameters:
  • root (str | PathLike[str]) –

    the root path to export to. The directory will be created if it does not exist

  • signer (PkiSigner) –

    A PkiSigner instance to use for signing the repository. Note that this is used to only sign the repository itself, not the packages in it. The packages need to be signed ahead of time which usually happens automatically if you use abuild tool

  • signer_name (str) –

    The "name" of the signer to use. It is usually something like "mymail@mydomain.com-1234abcd" (see https://wiki.alpinelinux.org/wiki/Abuild_and_Helpers#Setting_up_the_build_environment for details). Unlike what pkg tool does it is not parsed out of private key filename - you have to pass it here manually.

  • now (Optional[datetime], default: None ) –

    optional timestamp to use when generating files (including various timestamp fields inside files). Specifying this argument allows for reproducible repository creation.

  • keep_expanded (bool, default: False ) –

    keep intermediate uncompressed files on disk. This is useful for testing and troubleshooting only

packages

packages(arch: str) -> Sequence[AlpinePackage]

Packages for a given architecture

AptDistribution

A distribution in AptRepo

Attributes:
  • origin (Optional[str]) –

    Origin of the distribution

  • label (Optional[str]) –

    Label of the distribution

  • suite (Optional[str]) –

    Suite of the distribution

  • codename (Optional[str]) –

    Codename of the distribution

  • version (Optional[str]) –

    Version of the distribution

  • description (Optional[str]) –

    Description of the distribution

components property

components: KeysView[str]

Components in this distribution

path property

path: PurePosixPath

Path of the distribution

__init__

__init__(
    path: PurePosixPath,
    origin: Optional[str],
    label: Optional[str],
    suite: Optional[str],
    codename: Optional[str],
    version: Optional[str],
    description: Optional[str],
) -> None

Internal, do not use. Use AptRepo.add_distribution to create instances of this class

architectures

architectures(component: str) -> KeysView[str]

Architectures for a given component

packages

packages(component: str, arch: str) -> Sequence[AptPackage]

Architectures for a given component and architecture

AptPackage

A package in AptRepo

arch property

arch: str

Architecture of the package

fields property

fields: Mapping[str, Any]

Information about package stored in the repository index

name property

name: str

Name of the package

repo_filename property

repo_filename: str

Filename of the package when stored inside the repository

src_path property

src_path: Path

Path to the original package file

version_key property

version_key: VersionKey

Version of the package as a properly comparable key

version_str property

version_str: str

Version of the package as a string

__init__

__init__(
    src_path: Path, fields: Dict[str, str | list[str]]
)

Internal, do not use. Use AptRepo.add_package to create instances of this class

AptRepo

Generates APT repositories

distributions property

distributions: AbstractSet[AptDistribution]

Distributions in this repository

packages property

packages: Sequence[AptPackage]

Packages in this repository

__init__

__init__()

Constructor for AptRepo class

add_distribution

add_distribution(
    path: PurePosixPath | str,
    *,
    origin: Optional[str] = None,
    label: Optional[str] = None,
    suite: Optional[str] = None,
    codename: Optional[str] = None,
    version: Optional[str] = None,
    description: Optional[str] = None
) -> AptDistribution

Adds a new distribution to the repository

Parameters:
Returns:

add_package

add_package(path: str | PathLike[str]) -> AptPackage

Adds a package to the repository

Adding a package to the repository simply adds it to the pool of available packages. After doing that you need to add the returned package to one or more distributions to make it available to repository clients.

Parameters:
  • path (str | PathLike[str]) –

    the path to .deb file for the package.

Returns: an AptPackage object for the added package

assign_package

assign_package(
    package: AptPackage,
    dist: AptDistribution,
    component: str,
)

Assigns a repository package to a distribution's component

Parameters:
  • package (AptPackage) –

    the package to assign.

  • dist (AptDistribution) –

    the distribution to assign to

  • component (str) –

    the distribution's component to assign the package to

del_distribution

del_distribution(dist: AptDistribution)

Removes a distribution from the repository.

If the distribution is not in this repo the function ignores it and succeeds

Parameters:

del_package

del_package(package: AptPackage)

Removes a package from this repository

The package is removed from the repository and all distributions in it. It is not an error to pass a package that is not in a repository to this function. It will be ignored in such case.

Parameters:

export

export(
    root: str | PathLike[str],
    signer: PgpSigner,
    now: Optional[datetime] = None,
)

Export the repository into a given folder.

This actually creates an on-disk repository suitable to serve to APT clients. If the directory to export to already exists the export process tries to handle pre-existing content there gracefully. Content that doesn't conflict with repository content will be left alone. Content that does conflict will be removed or overwritten.

Specifically:

  • any existing pool/*.deb files will be removed and replaced with the ones from the repository.
  • 'dists' subdirectory will be completely erased and replaced with exported content
Parameters:
  • root (str | PathLike[str]) –

    the root path to export to. The directory will be created if it does not exist

  • signer (PgpSigner) –

    A PgpSigner instance to use for signing the repository.

  • now (Optional[datetime], default: None ) –

    optional timestamp to use when generating files (including various timestamp fields inside files). Specifying this argument allows for reproducible repository creation.

unassign_package

unassign_package(
    package: AptPackage,
    dist: AptDistribution,
    component: Optional[str] = None,
)

Removes a repository package from a distribution's component

If the package or distribution are not in this repository or the package is not assigned to the distribution's component the call is silently ignored.

Parameters:
  • package (AptPackage) –

    the package to remove.

  • dist (AptDistribution) –

    the distribution to remove from

  • component (Optional[str], default: None ) –

    if specified remove the package only from this component. Otherwise, remove it from all

FreeBSDPackage

A package in FreeBSDRepo

arch property

arch: str

Architecture of the package

fields property

fields: Mapping[str, Any]

Information about package stored in the repository index.

name property

name: str

Name of the package

repo_filename property

repo_filename: str

Filename of the package when stored inside the repository

src_path property

src_path: Path

Path to the original package file

version_key property

version_key: VersionKey

Version of the package as a properly comparable key

version_str property

version_str: str

Version of the package as a string

__init__

__init__(
    src_path: Path, manifest: bytes, fields: dict[str, Any]
) -> None

Internal do not use. Use FreeBSDRepo.add_package to create instances of this class

FreeBSDRepo

Generates FreeBSD pkg repositories

packages property

packages: Sequence[FreeBSDPackage]

Packages in the repository

__init__

__init__()

Constructor for FreeBSDRepo class

add_package

add_package(path: str | PathLike[str]) -> FreeBSDPackage

Adds a package to the repository

Parameters:
  • path (str | PathLike[str]) –

    the path to .pkg file for the package.

Returns: a FreeBSDPackage object for the added package

del_package

del_package(package: FreeBSDPackage)

Removes a package from this repository

It is not an error to pass a package that is not in a repository to this function. It will be ignored in such case.

Parameters:

export

export(
    root: str | PathLike[str],
    signer: PkiSigner,
    now: Optional[datetime] = None,
    keep_expanded: bool = False,
)

Export the repository into a given folder

This actually creates an on-disk repository suitable to serve to pkg clients. If the directory to export to already exists the export process tries to handle pre-existing content there gracefully. Content that doesn't conflict with repository content will be left alone. Content that does conflict will be removed or overwritten.

Specifically any existing All/*.pkg files will be removed and replaced with the ones from the repository.

Parameters:
  • root (str | PathLike[str]) –

    the root path to export to. The directory will be created if it does not exist

  • signer (PkiSigner) –

    A PkiSigner instance to use for signing the repository.

  • now (Optional[datetime], default: None ) –

    optional timestamp to use when generating files (including various timestamp fields inside files). Specifying this argument allows for reproducible repository creation.

  • keep_expanded (bool, default: False ) –

    keep intermediate uncompressed files on disk. This is useful for testing and troubleshooting only

PacmanPackage

A package in PacmanRepo

arch property

arch: str

Architecture of the package

fields property

fields: Mapping[str, Any]

Information about package stored in the repository index

See https://repod.archlinux.page/repositories/sync_database.html#desc-v2 for information about available fields

name property

name: str

Name of the package

repo_filename property

repo_filename: str

Filename of the package when stored inside the repository

sig_path property

sig_path: Optional[Path]

Path to the package signature file, if present

src_path property

src_path: Path

Path to the original package file

version_key property

version_key: VersionKey

Version of the package as a properly comparable key

version_str property

version_str: str

Version of the package as a string

__init__

__init__(
    src_path: Path,
    sig_path: Optional[Path],
    desc: dict[str, Any],
    files: list[str],
)

Internal do not use. Use add_package to create instances of this class

PacmanRepo

Generates Pacman repositories

architectures property

architectures: KeysView[str]

Architectures in this repository

name property

name

Repository name

__init__

__init__(name: str)

Constructor for AlpineRepo class

Parameters:
  • name (str) –

    repository name.

add_package

add_package(path: str | PathLike[str]) -> PacmanPackage

Adds a package to the repository

Parameters:
  • path (str | PathLike[str]) –

    the path to .zst file for the package. If a matching .zst.sig file exists alongside it, it will be used as a signature file.

Returns: a PacmanPackage object for the added package

del_package

del_package(package: PacmanPackage)

Removes a package from this repository

It is not an error to pass a package that is not in a repository to this function. It will be ignored in such case.

Parameters:

export

export(
    root: Path,
    signer: PgpSigner,
    now: Optional[datetime] = None,
    keep_expanded: bool = False,
)

Export the repository into a given folder

This actually creates an on-disk repository suitable to serve to pacman clients. If the directory to export to already exists the export process tries to handle pre-existing content there gracefully. Content that doesn't conflict with repository content will be left alone. Content that does conflict will be removed or overwritten.

Specifically any existing /.pkg.tar.zst and /.pkg.tar.zst.sig files will be removed and replaced with the ones from the repository for the architectures in the repository.

Parameters:
  • root (Path) –

    the root path to export to. The directory will be created if it does not exist

  • signer (PgpSigner) –

    A PgpSigner instance to use for signing the repository. It is used to sign the repository itself and any packages that do not have pre-existing signatures.

  • now (Optional[datetime], default: None ) –

    optional timestamp to use when generating files (including various timestamp fields inside files). Specifying this argument allows for reproducible repository creation.

  • keep_expanded (bool, default: False ) –

    keep intermediate uncompressed files on disk. This is useful for testing and troubleshooting only

packages

packages(arch: str) -> Sequence[PacmanPackage]

Packages for a given architecture

PgpSigner

Implementation of PGP signing

Many repository formats rely on PGP signing and use this class for it.

This class simply delegates signing to gpg executable that needs to be present on $PATH. Unfortunately, currently there seems to be no good way to perform PGP signing in "pure Python".

You are required to supply key name and password for signing. Signing is done non-interactively without any user prompts.

__init__

__init__(
    *,
    key_name: str,
    key_pwd: str,
    homedir: Optional[str | PathLike[str]] = None
)

Constructor for PgpSigner class

Parameters:
  • key_name (str) –

    name or identifier of the key to use

  • key_pwd (str) –

    password of the key

  • homedir (Optional[str | PathLike[str]], default: None ) –

    GPG home directory. If not specified the gpg defaults are used (including honoring GNUPGHOME environment variable)

binary_sign_external

binary_sign_external(path: Path, sig_path: Path)

Signs a given file producing binary signature in a separate file

Parameters:
  • path (Path) –

    file to sign

  • sig_path (Path) –

    path to write the signature to

export_public_key

export_public_key(path: Path)

Utility method to export the public key of the signing key into a file Args: path: path of the file to write the public key to

sign_external

sign_external(path: Path, sig_path: Path)

Signs a given file producing text (aka "armored") signature in a separate file

Parameters:
  • path (Path) –

    file to sign

  • sig_path (Path) –

    path to write the signature to

sign_inline

sign_inline(path: Path, out_path: Path)

Adds a signature to a given text file

Parameters:
  • path (Path) –

    file to sign

  • out_path (Path) –

    path to write the signed content to

PkiSigner

Implementation of private key based signing

Many repository formats rely on private key signing and use this class for it.

The supplied key needs to be in PEM format. Its cryptographic type needs to be appropriate for the repository that it will be used for.

__init__

__init__(
    priv_key_path: str | PathLike[str],
    priv_key_passwd: Optional[str],
)

Constructor for PkiSigner class

The private key file is read once during the construction and not used again Args: priv_key_path: path to the private key file. The file must be in PEM format. priv_key_passwd: password for the key if it requires one.

get_alpine_signature

get_alpine_signature(path: Path)

Generate file signature in a format required by Alpine apk repositories

Only rsa keys are currently supported

Parameters:
  • path (Path) –

    path of the file to sign

Returns: Signature as a bytes object

get_free_bsd_signature

get_free_bsd_signature(path: Path)

Generate file signature in a format required by FreeBSD repositories

Private key type must be one of: rsa, ecdsa or eddsa Args: path: path of the file to sign Returns: Signature as a bytes object

RpmPackage

A package in RpmRepo

arch property

arch: str

Architecture of the package

fields property

fields: ImmutableDict

Information about package stored in the repository index

name property

name: str

Name of the package

pkgid property

pkgid: str

Unique identifier of the package in the repository

repo_filename property

repo_filename: str

Filename of the package when stored inside the repository

src_path property

src_path: Path

Path to the original package file

version_key property

version_key: RpmVersion

Version of the package as a properly comparable key

version_str property

version_str: str

Version of the package as a string

__init__

__init__(
    src_path: Path,
    filename: str,
    pkgid: str,
    size: int,
    mtime: int,
    headers: dict[str, Any],
    header_range: tuple[int, int],
)

Internal, do not use Use RpmRepo.addPackage to create instances of this class

RpmRepo

Generates RPM repositories

packages property

packages: Sequence[RpmPackage]

Packages in the repository

__init__

__init__()

Constructor for RpmRepo class

add_package

add_package(path: str | PathLike[str]) -> RpmPackage

Adds a package to the repository

Parameters:
  • path (str | PathLike[str]) –

    the path to .rpm file for the package.

Returns: an RpmPackage object for the added package

del_package

del_package(package: RpmPackage)

Removes a package from this repository

It is not an error to pass a package that is not in a repository to this function. It will be ignored in such case.

Parameters:

export

export(
    root: str | PathLike[str],
    signer: PgpSigner,
    now: Optional[datetime] = None,
    keep_expanded: bool = False,
)

Export the repository into a given folder

This actually creates an on-disk repository suitable to serve to pacman clients. If the directory to export to already exists the export process tries to handle pre-existing content there gracefully. Content that doesn't conflict with repository content will be left alone. Content that does conflict will be removed or overwritten.

Specifically any existing *.rpm files will be removed and replaced with the ones from the repository.

Parameters:
  • root (str | PathLike[str]) –

    the root path to export to. The directory will be created if it does not exist

  • signer (PgpSigner) –

    A PgpSigner instance to use for signing the repository.

  • now (Optional[datetime], default: None ) –

    optional timestamp to use when generating files (including various timestamp fields inside files). Specifying this argument allows for reproducible repository creation.

  • keep_expanded (bool, default: False ) –

    keep intermediate uncompressed files on disk. This is useful for testing and troubleshooting only

RpmVersion

Representation of RPM package version

Instances of this class are properly comparable (==, !=, <, <=, >, >=) and hashable.

The string representation of an RpmVersion object is the properly formatted version string

__init__

__init__(version: str | Sequence[str]) -> None

Constructor for RpmVersion class

Parameters:
  • version (str | Sequence[str]) –

    either the full RPM version in string form or a tuple of (epoch, version, release)

VersionKey

Representation of a package version

Package versions cannot be compared as simple strings. For example "1.10" should be bigger than "1.2". This class allows correct sematic comparisons for versions.

Instances of this class are properly comparable (==, !=, <, <=, >, >=) and hashable.

Logically a version key is a heterogeneous tuple of str and int elements.

__init__

__init__(*args)

Constructor for VersionKey class

Arguments are any number of version parts. Each part can be:

  • a single int for a numeric part
  • an str or bytes object for a string part

parse staticmethod

parse(version: str) -> VersionKey

Parses the version key from a string

Parsing is always well defined for any string and never fails

Parameters:
  • version (str) –

    a version string

Returns: parsed key

options: summary: modules: false