PacmanRepository

class rmote.tools.pacman_repository.PacmanRepository[source]

Bases: Tool

Manage Arch Linux repository sections and GPG keys.

Repository sections are read from and written to /etc/pacman.conf. GPG key files are stored in /etc/pacman.d/. All operations are idempotent and require root.

static absent(name)[source]

Remove the repository section name from /etc/pacman.conf.

Parameters:

name (Text) – Repository section name to remove.

Return type:

Result

Returns:

Result indicating whether pacman.conf was modified.

static key(name, data)[source]

Write a GPG key to /etc/pacman.d/{name}.

Idempotent — the file is left untouched if it already contains identical bytes.

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

  • data (bytes) – Raw key bytes.

Return type:

Result

Returns:

Result indicating whether the key was written.

static present(name, *, servers, sig_level='Optional TrustAll')[source]

Ensure a repository section is present in /etc/pacman.conf.

If the section already exists with the same content it is left unchanged. If it exists with different content it is updated in-place. Otherwise it is appended at the end of the file.

Parameters:
  • name (Text) – Repository section name (e.g. "blackarch").

  • servers (list[Text]) – One or more server URLs for the repository.

  • sig_level (Text) – pacman SigLevel value. Defaults to "Optional TrustAll".

Return type:

Result

Returns:

Result indicating whether pacman.conf was modified.