stuffer.apt module

Package installation with apt commands.

Packages are installed with apt.Install. Third-party package repositories can be added with apt.AddRepository or apt.SourceList. Repository keys are added with either apt.KeyAdd or apt.KeyRecv.

There is no command corresponding to apt-get update, since it is considered bad practice to run and update in isolation. Instead, update is executed automatically only when necessary, i.e. for the first apt.Install command, and in case new package repositories or repository keys have been added. The state key apt.UPDATE_NEEDED_KEY is used to communicate to later commands whether an update is necessary or not.

Attributes

UPDATE_NEEDED_KEY : str
Name of store variable used to signal the need to run apt-get update.
class stuffer.apt.AddRepository(name: Union[str, stuffer.content.DeferStr])[source]

Bases: stuffer.core.Action

Add an apt repository with apt-add-repository.

name
Name of repository.
prerequisites()[source]
run()[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.
class stuffer.apt.Install(package: Union[str, stuffer.content.DeferStr, List[str]], update: Optional[bool] = None)[source]

Bases: stuffer.core.Action

Install a package with apt-get install.

apt-get update will ne executed first, unless the value for apt.UPDATE_NEEDED_KEY indicates that update is unnecessary.

package
Name of package. Standard apt-get install version constraints can be used, e.g. wget=1.17.1.
update
Whether to run apt-get update first. If absent, it is automatically decided.
run() → None[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.
class stuffer.apt.KeyAdd(url: Union[str, stuffer.content.DeferStr])[source]

Bases: stuffer.core.Action

Add a trusted key to apt using apt-key add method.

url
URL of key file to download.
prerequisites()[source]
run()[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.
class stuffer.apt.KeyRecv(keyserver: Union[str, stuffer.content.DeferStr], key: Union[str, stuffer.content.DeferStr])[source]

Bases: stuffer.core.Action

Add a trusted key to apt using apt-key –recv-keys method.

keyserver
Host name of key server, passed as –keyserver argument.
key
Key hex code.
run()[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.
class stuffer.apt.Purge(package: Union[str, stuffer.content.DeferStr])[source]

Bases: stuffer.core.Action

Completely remove a package.

Runs the apt-get purge command.

package
Name of package.
command()[source]

Shell command to run. Override this or run().

Should either return a list of strings to pass to subprocess.check_output, or a string, in which case shell=True will be passed with subprocess.check_output..

class stuffer.apt.SourceList(name: Union[str, stuffer.content.DeferStr], contents: Union[str, stuffer.content.DeferStr, Callable[[], str]])[source]

Bases: stuffer.core.Action

Add a package repository by creating a file under /etc/apt/sources.list.d.

name
Name of repository file, without extension
contents
Contents of file, e.g. deb https://apt.dockerproject.org/repo ubuntu-xenial main, or function that returns the contents when called.
prerequisites()[source]
run()[source]

Run the Action command(s).

The default implementation runs the command returned by command().

str
The output of the command
subprocess.CalledProcessError
On execution failure.