tmt.package_managers package

Submodules

tmt.package_managers.apk module

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

Bases: PackageManager[ApkEngine]

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.

NAME: str = 'apk'
check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Package | FileSystemPath | PackagePath | PackageUrl, bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo(*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.

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

Bases: PackageManagerEngine

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) ShellScript

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) ShellScript
install_command = <tmt.utils.Command object>
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
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[Command, Command]

Prepare installation command for apk

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

tmt.package_managers.apt module

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

Bases: PackageManager[AptEngine]

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.

NAME: str = 'apt'
check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Package | FileSystemPath | PackagePath | PackageUrl, bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo(*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.

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

Bases: PackageManagerEngine

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) ShellScript

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) ShellScript
install_command = <tmt.utils.Command object>
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
prepare_command() tuple[Command, Command]

Prepare installation command for apt

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

tmt.package_managers.bootc module

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

Bases: PackageManager[BootcEngine]

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.

NAME: str = 'bootc'
build_container() None
check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Package | FileSystemPath | PackagePath | 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
probe_command: Command = <tmt.utils.Command object>

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

probe_priority: int = 130

Package managers with higher value would be preferred when more one package manager is detected on guest. For most of the time, the default is sufficient, but some families of package managers (looking at you, yum, dnf, dnf5, rpm-ostree!) may be installed togethers, and therefore a priority is needed.

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

Bases: PackageManagerEngine

Initialize bootc engine for package management

check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) ShellScript

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
containerfile_directives: list[str]
flush_containerfile_directives() None
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
open_containerfile_directives() None

Initialize containerfile directives

prepare_command() tuple[Command, Command]

Prepare installation command for bootc

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

tmt.package_managers.dnf module

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

Bases: PackageManager[DnfEngine]

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.

NAME: str = 'dnf'
bootc_builder: bool = True

If set, this package manager can be used for building derived images under the hood of the bootc package manager.

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

Return a presence status for each given installable

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.

probe_priority: int = 50

Package managers with higher value would be preferred when more one package manager is detected on guest. For most of the time, the default is sufficient, but some families of package managers (looking at you, yum, dnf, dnf5, rpm-ostree!) may be installed togethers, and therefore a priority is needed.

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.

NAME: str = 'dnf5'
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.

probe_priority: int = 60

Package managers with higher value would be preferred when more one package manager is detected on guest. For most of the time, the default is sufficient, but some families of package managers (looking at you, yum, dnf, dnf5, rpm-ostree!) may be installed togethers, and therefore a priority is needed.

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

Bases: DnfEngine

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
skip_missing_packages_option = '--skip-unavailable'
class tmt.package_managers.dnf.DnfEngine(*, guest: Guest, logger: Logger)

Bases: PackageManagerEngine

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) ShellScript

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
create_repository(directory: Path) ShellScript

Create repository metadata for package files in the given directory.

Parameters:

directory – The path to the directory containing RPM packages.

Returns:

A shell script to create repository metadata.

install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
install_repository(repository: None) ShellScript

Install a repository by placing its configuration in /etc/yum.repos.d/.

Parameters:

repository – The repository to install.

Returns:

A shell script to install the repository.

list_packages(repository: None) ShellScript

List packages available in the specified repository.

Parameters:

repository – The repository to query.

Returns:

A shell script to list packages in the repository.

Raises:

NotImplementedError – If the package manager does not support listing packages.

prepare_command() tuple[Command, Command]

Prepare installation command and subcommand options

refresh_metadata() ShellScript
reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
skip_missing_debuginfo_option = '--skip-broken'
skip_missing_packages_option = '--skip-broken'
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.

NAME: str = 'yum'
bootc_builder: bool = False

If set, this package manager can be used for building derived images under the hood of the bootc package manager.

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.

probe_priority: int = 40

Package managers with higher value would be preferred when more one package manager is detected on guest. For most of the time, the default is sufficient, but some families of package managers (looking at you, yum, dnf, dnf5, rpm-ostree!) may be installed togethers, and therefore a priority is needed.

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

Bases: DnfEngine

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) ShellScript
refresh_metadata() ShellScript
reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript

tmt.package_managers.mock module

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

Bases: _MockPackageManager

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.

NAME: str = 'mock-dnf'
cli_invocation: 'tmt.cli.CliInvocation' | None = None
class tmt.package_managers.mock.MockDnf5(*, guest: Guest, logger: Logger)

Bases: _MockPackageManager

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.

NAME: str = 'mock-dnf5'
cli_invocation: 'tmt.cli.CliInvocation' | None = None
class tmt.package_managers.mock.MockEngine(*, guest: Guest, logger: Logger)

Bases: PackageManagerEngine

We use mock –pm-cmd … to execute the package manager commands inside the mock. Such scripts need to be executed locally and not inside the mock shell.

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) ShellScript

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) ShellScript
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
prepare_command() tuple[Command, Command]

Prepare installation command and subcommand options

refresh_metadata() ShellScript
reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
class tmt.package_managers.mock.MockYum(*, guest: Guest, logger: Logger)

Bases: _MockPackageManager

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.

NAME: str = 'mock-yum'
cli_invocation: 'tmt.cli.CliInvocation' | None = None

tmt.package_managers.rpm_ostree module

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

Bases: PackageManager[RpmOstreeEngine]

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.

NAME: str = 'rpm-ostree'
check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Package | FileSystemPath | PackagePath | PackageUrl, bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
install_debuginfo(*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.

probe_priority: int = 100

Package managers with higher value would be preferred when more one package manager is detected on guest. For most of the time, the default is sufficient, but some families of package managers (looking at you, yum, dnf, dnf5, rpm-ostree!) may be installed togethers, and therefore a priority is needed.

refresh_metadata() CommandOutput
reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
class tmt.package_managers.rpm_ostree.RpmOstreeEngine(*, guest: Guest, logger: Logger)

Bases: PackageManagerEngine

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) ShellScript

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) ShellScript
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
prepare_command() tuple[Command, Command]

Prepare installation command for rpm-ostree

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

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 = tmt.package_managers.Package | tmt.package_managers.FileSystemPath | tmt.package_managers.PackagePath | tmt.package_managers.PackageUrl

All installable objects.

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

Bases: object

allow_untrusted: bool = False

If set, instruct package manager to install from untrusted sources.

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[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, Generic[PackageManagerEngineT]

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.

NAME: str
bootc_builder: bool = False

If set, this package manager can be used for building derived images under the hood of the bootc package manager.

abstractmethod check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) dict[Package | FileSystemPath | PackagePath | PackageUrl, bool]

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
create_repository(directory: Path) CommandOutput

Wrapper of PackageManagerEngine.create_repository().

engine: PackageManagerEngineT
install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
install_repository(repository: None) CommandOutput

Install a repository by placing its configuration in /etc/yum.repos.d/ and refresh the package manager cache.

Parameters:

repository – The repository to install.

Returns:

The output of the command execution.

list_packages(repository: None) list[str]

List packages available in the specified repository.

Parameters:

repository – The repository to query.

Returns:

A list of package names available in the repository.

probe_command: Command

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

probe_priority: int = 0

Package managers with higher value would be preferred when more one package manager is detected on guest. For most of the time, the default is sufficient, but some families of package managers (looking at you, yum, dnf, dnf5, rpm-ostree!) may be installed togethers, and therefore a priority is needed.

refresh_metadata() CommandOutput
reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) CommandOutput
class tmt.package_managers.PackageManagerEngine(*, guest: Guest, logger: Logger)

Bases: Common

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.

abstractmethod check_presence(*installables: Package | FileSystemPath | PackagePath | PackageUrl) ShellScript

Return a presence status for each given installable

cli_invocation: 'tmt.cli.CliInvocation' | None = None
command: Command
create_repository(directory: Path) ShellScript

Create repository metadata for package files in the given directory.

Parameters:

directory – The path to the directory containing packages.

Returns:

A shell script to create repository metadata.

Raises:

PrepareError – If this package manager does not support creating repositories.

abstractmethod install(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
abstractmethod install_debuginfo(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
install_repository(repository: None) ShellScript

Install a repository by placing its configuration in /etc/yum.repos.d/.

Parameters:

repository – The repository to install.

Returns:

A shell script to install the repository.

list_packages(repository: None) ShellScript

List packages available in the specified repository.

Parameters:

repository – The repository to query.

Returns:

A shell script to list packages in the repository.

Raises:

NotImplementedError – If the package manager does not support listing packages.

options: Command
abstractmethod prepare_command() tuple[Command, Command]

Prepare installation command and subcommand options

abstractmethod refresh_metadata() ShellScript
abstractmethod reinstall(*installables: Package | FileSystemPath | PackagePath | PackageUrl, options: Options | None = None) ShellScript
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[PackageManagerEngine]

Find a package manager by its name.

Raises:

GeneralError – when the plugin does not exist.