PacmanRepository¶
Manage repository sections in the target’s pacman configuration as root. Use repositories and signing keys that you trust.
- class rmote.tools.pacman_repository.PacmanRepository[source]¶
Bases:
ToolManage 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.Every operation needs the
/etc/pacman.confconfiguration of Arch Linux. A target without it refuses with NotImplementedError instead of writing a file that nothing reads.Update pacman.conf inside a disposable Arch Linux container. The example repository is only written to disk; it is not contacted:
>>> from rmote.tools import FileSystem >>> remote = getfixture("arch_tool") >>> options = dict(servers=["https://repo.example/$arch"], sig_level="Required DatabaseOptional") >>> remote(PacmanRepository.present, "example", **options).changed True >>> remote(PacmanRepository.present, "example", **options).changed False >>> "[example]" in remote(FileSystem.read_str, "/etc/pacman.conf") True >>> remote(PacmanRepository.absent, "example").changed True >>> remote(PacmanRepository.absent, "example").changed False
- 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.
- 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.