tmt.package_managers package

Submodules

tmt.package_managers.apk module

class tmt.package_managers.apk.Apk(*, guest: Guest, logger: Logger)

Bases: PackageManager

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath, tmt.package_managers.PackagePath, tmt.package_managers.PackageUrl], bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_command = <tmt.utils.Command object>
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
path_to_package(path: FileSystemPath) Package

Find a package providing given filesystem path.

This is not easily possible in Alpine. There is apk-file utility available but it seems unrealiable. Support only a fixed set of mappings until a better solution is available.

prepare_command() tuple[tmt.utils.Command, tmt.utils.Command]

Prepare installation command for apk

probe_command: Command = <tmt.utils.Command object>

A command to run to check whether the package manager is available on a guest.

reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput

tmt.package_managers.apt module

class tmt.package_managers.apt.Apt(*, guest: Guest, logger: Logger)

Bases: PackageManager

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath, tmt.package_managers.PackagePath, tmt.package_managers.PackageUrl], bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_command = <tmt.utils.Command object>
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
path_to_package(path: FileSystemPath) Package

Find a package providing given filesystem path.

This is not trivial as some are used to from yum or dnf, it requires installation of apt-file utility and building an index of packages and filesystem paths.

prepare_command() tuple[tmt.utils.Command, tmt.utils.Command]

Prepare installation command for apt

probe_command: Command = <tmt.utils.Command object>

A command to run to check whether the package manager is available on a guest.

reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput

tmt.package_managers.dnf module

class tmt.package_managers.dnf.Dnf(*, guest: Guest, logger: Logger)

Bases: PackageManager

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath, tmt.package_managers.PackagePath, tmt.package_managers.PackageUrl], bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
prepare_command() tuple[tmt.utils.Command, tmt.utils.Command]

Prepare installation command and subcommand options

probe_command: Command = <tmt.utils.Command object>

A command to run to check whether the package manager is available on a guest.

reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
skip_missing_option = '--skip-broken'
class tmt.package_managers.dnf.Dnf5(*, guest: Guest, logger: Logger)

Bases: Dnf

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

cli_invocation: 'tmt.cli.CliInvocation' | None = None
probe_command: Command = <tmt.utils.Command object>

A command to run to check whether the package manager is available on a guest.

skip_missing_option = '--skip-unavailable'
class tmt.package_managers.dnf.Yum(*, guest: Guest, logger: Logger)

Bases: Dnf

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
probe_command: Command = <tmt.utils.Command object>

A command to run to check whether the package manager is available on a guest.

reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput

tmt.package_managers.rpm_ostree module

class tmt.package_managers.rpm_ostree.RpmOstree(*, guest: Guest, logger: Logger)

Bases: PackageManager

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath, tmt.package_managers.PackagePath, tmt.package_managers.PackageUrl], bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
prepare_command() tuple[tmt.utils.Command, tmt.utils.Command]

Prepare installation command for rpm-ostree

probe_command: Command = <tmt.utils.Command object>

A command to run to check whether the package manager is available on a guest.

reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput

Module contents

class tmt.package_managers.FileSystemPath(*args, **kwargs)

Bases: Path

A filesystem path provided by a package

Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.

tmt.package_managers.Installable

All installable objects.

alias of Union[Package, FileSystemPath, PackagePath, PackageUrl]

class tmt.package_managers.Options(excluded_packages: list[tmt.package_managers.Package] = <factory>, skip_missing: bool = False, check_first: bool = True, install_root: Optional[tmt.utils.Path] = None, release_version: Optional[str] = None)

Bases: object

check_first: bool = True

If set, check whether the package is already installed, and do not attempt to install it if it is already present.

excluded_packages: list[tmt.package_managers.Package]

A list of packages to exclude from installation.

install_root: Path | None = None

If set, install packages under this path instead of the usual system root.

release_version: str | None = None

If set, instruct package manager to behave as if the distribution release was release_version.

skip_missing: bool = False

If set, a failure to install a given package would not cause an error.

class tmt.package_managers.Package

Bases: str

A package name

class tmt.package_managers.PackageManager(*, guest: Guest, logger: Logger)

Bases: Common

A base class for package manager plugins

Initialize name and relation with the parent object

Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.

check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Union[tmt.package_managers.Package, tmt.package_managers.FileSystemPath, tmt.package_managers.PackagePath, tmt.package_managers.PackageUrl], bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
command: Command
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
options: Command
prepare_command() tuple[tmt.utils.Command, tmt.utils.Command]

Prepare installation command and subcommand options

probe_command: Command

A command to run to check whether the package manager is available on a guest.

reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
class tmt.package_managers.PackagePath(*args, **kwargs)

Bases: Path

A path to a package file

Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.

class tmt.package_managers.PackageUrl

Bases: str

A URL of a package file

tmt.package_managers.escape_installables(*installables: Package | FileSystemPath | PackagePath | PackageUrl) Iterator[str]
tmt.package_managers.find_package_manager(name: GuestPackageManager) PackageManagerClass

Find a package manager by its name.

Raises:

GeneralError – when the plugin does not exist.

tmt.package_managers.provides_package_manager(package_manager: str) Callable[[type[tmt.package_managers.PackageManager]], type[tmt.package_managers.PackageManager]]

A decorator for registering package managers.

Decorate a package manager plugin class to register a package manager.