Apt¶
Manage Debian or Ubuntu packages with apt-get as root. Refresh the
package index with update before installing a package.
See Quickstart for installation and repeated-run checks.
- class rmote.tools.apt.Apt[source]¶
Bases:
ToolManage Debian/Ubuntu packages via apt-get. Requires root on the remote host.
Every operation that changes packages runs
apt-get. A target without it refuses with NotImplementedError. The installed set is read from/var/lib/dpkg/status, and an absent file reads as no packages.Install and remove a package in a disposable Debian container.
remoteis the fixture’s synchronous RPC callable (like aConnection):>>> remote = getfixture("debian_tool") >>> remote(Apt.update) True >>> remote(Apt.package, "nano").changed True >>> remote(Apt.package, "nano").changed False >>> remote(Apt.package, "nano", state=State.ABSENT).changed True >>> remote(Apt.package, "nano", state=State.ABSENT).changed False
- async classmethod converge(*packages)[source]¶
Apply each Package.state; string arguments default to PRESENT.
- async classmethod package(package, state=None)[source]¶
Install, remove, or upgrade a single package.
- Parameters:
package (
Text|Package) – Package name,name=versionstring, or aPackageinstance.state (
State|getint|None) – Desired state -State.PRESENT(install if absent),State.ABSENT(purge if installed), orState.LATEST(install or upgrade to candidate version). 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
apt-getinvocation fails.
- async static update(ttl=-1)[source]¶
Run
apt-get update, with optional TTL-based skipping.- Parameters:
ttl (
getint|getdouble) – Minimum age in seconds of the last successful update before re-running.-1(default) always runs the update.- Return type:
- Returns:
Trueifapt-get updatewas executed,Falseif the cache is fresher than ttl seconds.- Raises:
RuntimeError – If
apt-get updateexits with a non-zero status.