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:
ToolManage 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.
- async static package(package, state=None)[source]¶
Install, remove, or upgrade a single package.
- Parameters:
package (
Text|Package) – Package name or aPackageinstance. 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), orState.LATEST(install or upgrade). An explicit state overrides Package.state. If omitted, use Package.state for objects or PRESENT for strings.
- Return type:
- Returns:
Resultwith the package name, installed version, and whether the system was changed.- Raises:
RuntimeError – If the underlying
pacmaninvocation 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:
- Returns:
Trueifpacman -Sywas executed,Falseif the database is fresher than ttl seconds.- Raises:
RuntimeError – If
pacman -Syexits with a non-zero status.
Types¶
- class rmote.tools.pacman.State(*values)[source]¶
Bases:
IntEnum- ABSENT = 1¶
- LATEST = 2¶
- PRESENT = 0¶