Pacman

Manage Arch Linux packages with pacman as root. Package and repository state refer to the target host.

class rmote.tools.pacman.Pacman[source]

Bases: Tool

Manage Arch Linux packages via pacman. Requires root on the remote host.

Every operation runs pacman. A target without it refuses with NotImplementedError, which names Arch Linux as what provides it.

Install and remove a package in a disposable Arch Linux container:

>>> remote = getfixture("arch_tool")
>>> remote(Pacman.package, "nano").changed
True
>>> remote(Pacman.package, "nano").changed
False
>>> remote(Pacman.package, "nano", state=State.ABSENT).changed
True
>>> remote(Pacman.package, "nano", state=State.ABSENT).changed
False
async classmethod converge(*packages)[source]

Apply each Package.state; string arguments default to PRESENT.

Parameters:

*packages (Text | Package) – Package names or Package instances.

Return type:

list[Result]

Returns:

List of Result objects, one per package, in the same order as the input.

async static package(package, state=None)[source]

Install, remove, or upgrade a single package.

Parameters:
  • package (Text | Package) – Package name or a Package instance. Version pinning (name=version) is parsed but ignored by pacman.

  • state (State | getint | None) – Desired state - State.PRESENT (install if absent), State.ABSENT (remove if installed), or State.LATEST (install or upgrade). An explicit state overrides Package.state. If omitted, use Package.state for objects or PRESENT for strings.

Return type:

Result

Returns:

Result with the package name, installed version, and whether the system was changed.

Raises:

RuntimeError – If the underlying pacman invocation fails.

async static update(ttl=-1)[source]

Synchronise the package database (pacman -Sy), with optional TTL-based skipping.

Parameters:

ttl (getint | getdouble) – Minimum age in seconds of the last sync before re-running. -1 (default) always synchronises.

Return type:

bool

Returns:

True if pacman -Sy was executed, False if the database is fresher than ttl seconds.

Raises:

RuntimeError – If pacman -Sy exits with a non-zero status.

Types

class rmote.tools.pacman.State(*values)[source]

Bases: IntEnum

ABSENT = 1
LATEST = 2
PRESENT = 0
class rmote.tools.pacman.Package(name, state=State.PRESENT, version='')[source]

Bases: object

classmethod from_string(s, state=State.PRESENT)[source]
Return type:

Package

name: str
classmethod parse(s, state=None)[source]

Use the explicit state, then Package.state, then PRESENT.

Return type:

Package

state: int = 0
version: str = ''
class rmote.tools.pacman.Result(name, changed, version='')[source]

Bases: object

changed: bool
classmethod from_package(package, changed)[source]
Return type:

Result

name: str
version: str = ''