AptRepository

class rmote.tools.apt_repository.AptRepository[source]

Bases: Tool

Manage APT repository sources and GPG keys on Debian/Ubuntu.

Repository sources are written as DEB822 .sources files under /etc/apt/sources.list.d/. GPG keyrings are stored in /etc/apt/keyrings/. All operations are idempotent and require root.

static absent(name)[source]

Remove the DEB822 .sources file for name, if it exists.

Parameters:

name (Text) – Repository label (the {name}.sources filename stem).

Return type:

Result

Returns:

Result indicating whether the file was removed.

static key(name, data)[source]

Install a GPG signing key to /etc/apt/keyrings/{name}.

The operation is idempotent — if the file already contains identical bytes it is left untouched.

Parameters:
  • name (Text) – Filename to write the key under (e.g. "docker.gpg").

  • data (bytes) – Raw key bytes (binary DER or ASCII-armoured GPG key).

Return type:

Result

Returns:

Result indicating whether the key was written.

static present(name, *, types=('deb',), uris, suites, components, signed_by='')[source]

Ensure a DEB822 .sources file is configured for name.

Writes /etc/apt/sources.list.d/{name}.sources. The operation is idempotent — if the file already contains the expected content it is left untouched.

Parameters:
  • name (Text) – Repository label used as the filename stem.

  • types (Iterable[Text]) – Package types — typically ("deb",) for binary packages or ("deb-src",) for source packages.

  • uris (Iterable[Text]) – Repository base URIs (e.g. ("https://download.docker.com/linux/ubuntu",)).

  • suites (Iterable[Text]) – Distribution suites (e.g. ("noble",)).

  • components (Iterable[Text]) – Repository components (e.g. ("stable",)).

  • signed_by (Text) – Absolute path to the GPG keyring that signs this repository.

Return type:

Result

Returns:

Result indicating whether the file was created or updated.