tmt.steps.prepare.artifact.providers package

Submodules

tmt.steps.prepare.artifact.providers.brew module

Brew Artifact Provider

class tmt.steps.prepare.artifact.providers.brew.BrewArtifactProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: KojiArtifactProvider

Provider for downloading artifacts from Brew builds.

Brew builds are just a special case of Koji builds

Note

Only RPMs are supported currently.

provider = BrewArtifactProvider("brew.build:123456", logger)
artifacts = provider.fetch_contents(guest, Path("/tmp"))
property build_provider: BrewBuild | None
class tmt.steps.prepare.artifact.providers.brew.BrewBuild(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: BrewArtifactProvider, KojiBuild

class tmt.steps.prepare.artifact.providers.brew.BrewNvr(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: BrewArtifactProvider, KojiNvr

class tmt.steps.prepare.artifact.providers.brew.BrewTask(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: BrewArtifactProvider, KojiTask

tmt.steps.prepare.artifact.providers.copr_build module

Copr Build Artifact Provider

tmt.steps.prepare.artifact.providers.copr_build.Client: Any
class tmt.steps.prepare.artifact.providers.copr_build.CoprBuildArtifactProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ArtifactProvider

Provider for downloading artifacts from Copr builds.

Identifier format: build-id:chroot-name

Example usage:

prepare:
  - summary: copr build artifacts
    how: artifact
    provide:
      - copr.build:1784470:fedora-32-x86_64
property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

property build_info: Munch | None

Fetch and return the build metadata.

Returns:

the build metadata, or None if not found.

property build_packages: Sequence[Munch]
contribute_to_shared_repo(guest: Guest, source_path: Path, shared_repo_dir: Path, exclude_patterns: list[Pattern[str]] | None = None) None

Contribute artifacts to the shared repository.

This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.

Parameters:
  • guest – the guest to run the commands on.

  • source_path – path where the artifacts are located (source for contribution).

  • shared_repo_dir – path to the shared repository directory where artifacts should be contributed.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.

property is_pulp: bool

Check if the build is stored in Pulp.

make_rpm_artifact(rpm_meta: dict[str, str]) ArtifactInfo
property result_url: str

Fetch and return the result URL for the build chroot.

tmt.steps.prepare.artifact.providers.copr_build.import_copr(logger: Logger) None

Import copr module with error handling.

tmt.steps.prepare.artifact.providers.copr_repository module

Copr Repository Artifact Provider

class tmt.steps.prepare.artifact.providers.copr_repository.CoprRepositoryProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ArtifactProvider

Provider for enabling Copr repositories and making their packages available.

Identifier format: @group/project or user/project

Example usage:

prepare:
  - summary: enable copr repository
    how: artifact
    provide:
      - copr.repository:@teemtee/stable
property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

copr_repo: str
fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]

Enable the Copr repository on the guest.

Returns:

Empty list as no files are downloaded.

Raises:

tmt.utils.PrepareError – If the guest does not have a valid package manager or if the package manager does not support enabling Copr repositories.

tmt.steps.prepare.artifact.providers.file module

class tmt.steps.prepare.artifact.providers.file.PackageAsFileArtifactProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ArtifactProvider

Provider for preparing artifacts from local or remote package files.

This provider can handle: - Glob patterns matching multiple package files. - Local package files specified by absolute or relative paths. - Remote package files accessible via URLs. - Directories containing package files (all packages in the directory are included).

Example usage:

prepare:
  - summary: package files
    how: artifact
    stage: prepare
    provide:
      - file:/tmp/*.rpm                    # Local glob
      - file:/build/specific.rpm           # Single file
      - file:https://example.com/pkg.rpm   # Remote URL
      - file:/path/to/packages/            # Directory
SUPPORTED_PREFIX: ClassVar[str] = 'file'
property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

contribute_to_shared_repo(guest: Guest, source_path: Path, shared_repo_dir: Path, exclude_patterns: list[Pattern[str]] | None = None) None

Contribute artifacts to the shared repository.

This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.

Parameters:
  • guest – the guest to run the commands on.

  • source_path – path where the artifacts are located (source for contribution).

  • shared_repo_dir – path to the shared repository directory where artifacts should be contributed.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.

make_rpm_artifact(path: str) ArtifactInfo

tmt.steps.prepare.artifact.providers.koji module

Koji Artifact Provider

tmt.steps.prepare.artifact.providers.koji.ClientSession: Any
class tmt.steps.prepare.artifact.providers.koji.KojiArtifactProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ArtifactProvider

Provider for downloading artifacts from Koji builds.

Note

Only RPMs are supported currently.

provider = KojiArtifactProvider("koji.build:123456", logger)
artifacts = provider.download_artifacts(guest, Path("/tmp"), [])
property build_id: int | None

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

property build_info: dict[str, Any] | None

Fetch and return the build metadata for the resolved build ID.

Returns:

the build metadata, or None if not found.

property build_provider: KojiBuild | None
contribute_to_shared_repo(guest: Guest, source_path: Path, shared_repo_dir: Path, exclude_patterns: list[Pattern[str]] | None = None) None

Contribute artifacts to the shared repository.

This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.

Parameters:
  • guest – the guest to run the commands on.

  • source_path – path where the artifacts are located (source for contribution).

  • shared_repo_dir – path to the shared repository directory where artifacts should be contributed.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.

make_rpm_artifact(rpm_meta: dict[str, Any]) ArtifactInfo

Create a normal build RPM artifact from metadata returned by listBuildRPMs.

class tmt.steps.prepare.artifact.providers.koji.KojiBuild(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: KojiArtifactProvider

property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

property build_id: int

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

class tmt.steps.prepare.artifact.providers.koji.KojiNvr(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: KojiArtifactProvider

property artifacts: Sequence[ArtifactInfo]

RPM artifacts for the given NVR.

property build_id: int

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

property build_info: dict[str, Any] | None

Fetch and return the build metadata for the nvr.

Returns:

the build metadata, or None if not found.

class tmt.steps.prepare.artifact.providers.koji.KojiTask(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: KojiArtifactProvider

property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

property build_id: int | None

Resolve and return the build ID.

There are multiple possible ways of finding a build ID from the artifact provider inputs, individual artifact providers must chose the most fitting one.

Returns:

the build ID, or None if there is no build attached to this provider.

Raises:

GeneralError – when the build should exist, but cannot be found in Koji.

make_rpm_artifact(task_id: int, filename: str) ArtifactInfo

Create a scratch RPM artifact from a task output filename.

tmt.steps.prepare.artifact.providers.koji.import_koji(logger: Logger) None

Import koji module with error handling.

tmt.steps.prepare.artifact.providers.repository module

Artifact provider for discovering RPMs from repository files.

class tmt.steps.prepare.artifact.providers.repository.RepositoryFileProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ArtifactProvider

Provider for making RPM artifacts from a repository discoverable without downloading them.

The provider identifier should start with ‘repository-file:’ followed by a URL to a .repo file, e.g., “repository-file:https://download.docker.com/linux/centos/docker-ce.repo”.

The provider downloads the .repo file to the guest’s /etc/yum.repos.d/ directory, and lists RPMs available in the defined repositories without downloading them, acting as a discovery-only provider. Artifacts are all available RPM packages listed in the repository.

Parameters:
  • raw_provider_id – The full provider identifier, starting with ‘repository-file:’.

  • logger – Logger instance for outputting messages.

Raises:

GeneralError – If the .repo file URL is invalid.

property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]

Fetch all artifacts to the specified destination.

Parameters:
  • guest – the guest on which the artifact should be downloaded.

  • download_path – path into which the artifact should be downloaded.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be downloaded.

Returns:

a list of paths to the downloaded artifacts.

Raises:

GeneralError – Unexpected errors outside the download process.

Note:

Errors during individual artifact downloads are caught, logged as warnings, and ignored.

get_repositories() list[Repository]

Return a list of Repository that this provider manages.

repository: Repository
tmt.steps.prepare.artifact.providers.repository.create_repository(artifact_dir: Path, guest: Guest, logger: Logger, priority: int, repo_name: str | None = None) Repository

Create a local RPM repository from a directory on the guest.

Creates repository metadata and prepares a Repository object. Does not install the repository on the guest system. Use install_repository() to make it visible to the package manager.

Parameters:
  • artifact_dir – Path to the directory on the guest containing RPM files.

  • guest – Guest instance where the repository metadata will be created.

  • logger – Logger instance for outputting debug and error messages.

  • repo_name – Name for the repository. If not provided, generates a unique name using the format tmt-repo-default-{n}.

  • priority – Repository priority. Lower values have higher priority.

Returns:

Repository object representing the newly created repository.

Raises:

PrepareError – If the package manager does not support creating repositories or if metadata creation fails.

tmt.steps.prepare.artifact.providers.repository_url module

Artifact provider for creating DNF repositories from baseurl.

class tmt.steps.prepare.artifact.providers.repository_url.RepositoryUrlProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ArtifactProvider

Provider for making RPM artifacts from a repository discoverable without downloading them.

The provider identifier should start with ‘repository-url:’ followed by a baseurl to a DNF repository, e.g., “repository-url:https://example.com/repo/”.

The provider generates a .repo file with the given baseurl, which will be installed to the guest’s /etc/yum.repos.d/ directory, and lists RPMs available in the repository without downloading them, acting as a discovery-only provider. Artifacts are all available RPM packages listed in the repository.

Parameters:
  • raw_provider_id – The full provider identifier, starting with ‘repository-url:’.

  • logger – Logger instance for outputting messages.

Raises:

ValueError – If the provider identifier format is invalid or the baseurl is missing.

property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]

Fetch all artifacts to the specified destination.

Parameters:
  • guest – the guest on which the artifact should be downloaded.

  • download_path – path into which the artifact should be downloaded.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be downloaded.

Returns:

a list of paths to the downloaded artifacts.

Raises:

GeneralError – Unexpected errors outside the download process.

Note:

Errors during individual artifact downloads are caught, logged as warnings, and ignored.

get_repositories() list[Repository]

Return a list of Repository that this provider manages.

repository: Repository

Module contents

Abstract base class for artifact providers.

class tmt.steps.prepare.artifact.providers.ArtifactInfo(version: Version, location: str, provider: ArtifactProvider)

Bases: object

Information about a single artifact, e.g. a package.

property filename: str

This is the filename of the artifact.

property id: str

A unique identifier of the artifact.

TODO: Transient for now, modify based on the decision made here: https://github.com/teemtee/tmt/issues/4546

location: str
property name: str
provider: ArtifactProvider
version: Version
class tmt.steps.prepare.artifact.providers.ArtifactProvider(raw_provider_id: str, repository_priority: int, logger: Logger)

Bases: ABC

Base class for artifact providers.

Each provider must implement:

  • parsing and validating the artifact ID,

  • listing available artifacts,

  • downloading a single given artifact.

property artifact_metadata: list[dict[str, Any]]

Get metadata for the artifacts provided by this provider.

Returns:

List of artifact metadata dictionaries.

property artifacts: Sequence[ArtifactInfo]

Collect all artifacts available from this provider.

The method is left for derived classes to implement with respect to the actual artifact provider they implement. The list of artifacts will be cached, and is treated as read-only.

Returns:

a list of provided artifacts.

contribute_to_shared_repo(guest: Guest, source_path: Path, shared_repo_dir: Path, exclude_patterns: list[Pattern[str]] | None = None) None

Contribute artifacts to the shared repository.

This is the main interface for providers to contribute their artifacts to the shared repository. Providers should override this method to implement their specific contribution logic.

Parameters:
  • guest – the guest to run the commands on.

  • source_path – path where the artifacts are located (source for contribution).

  • shared_repo_dir – path to the shared repository directory where artifacts should be contributed.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be contributed.

fetch_contents(guest: Guest, download_path: Path, exclude_patterns: list[Pattern[str]] | None = None) list[Path]

Fetch all artifacts to the specified destination.

Parameters:
  • guest – the guest on which the artifact should be downloaded.

  • download_path – path into which the artifact should be downloaded.

  • exclude_patterns – if set, artifacts whose names match any of the given regular expressions would not be downloaded.

Returns:

a list of paths to the downloaded artifacts.

Raises:

GeneralError – Unexpected errors outside the download process.

Note:

Errors during individual artifact downloads are caught, logged as warnings, and ignored.

get_repositories() list[Repository]

Return a list of Repository that this provider manages.

id: str

Identifier of this artifact provider. It is valid and unique in the domain of this provider. koji.build:12345. URL for a repository, and so on.

repository_priority: int

Repository priority for providers that create repositories. Lower values have higher priority in package managers.

tmt.steps.prepare.artifact.providers.ArtifactProviderId

A type of an artifact provider identifier.

exception tmt.steps.prepare.artifact.providers.DownloadError(message: str, causes: list[Exception] | None = None, *args: Any, **kwargs: Any)

Bases: GeneralError

Raised when download fails.

General error.

Parameters:
  • message – error message.

  • causes – optional list of exceptions that caused this one. Since raise ... from ... allows only for a single cause, and some of our workflows may raise exceptions triggered by more than one exception, we need a mechanism for storing them. Our reporting will honor this field, and report causes the same way as __cause__.

class tmt.steps.prepare.artifact.providers.Repository(content: str, name: str, repo_ids: list[str] = <factory>)

Bases: object

Thin wrapper/holder for .repo file content

content: str

Content of the repository

property filename: str

The name of the .repo file (e.g., ‘my-repo.repo’).

classmethod from_content(content: str, name: str, logger: Logger) Repository

Create a Repository instance directly from provided content string.

Parameters:
  • content – The string content of the repository.

  • name – The name for the repository (required when using content).

  • logger – Logger to use for the operation.

Returns:

A Repository instance.

Raises:

GeneralError – If the name is empty.

classmethod from_file_path(file_path: Path, logger: Logger, name: str | None = None) Repository

Create a Repository instance by reading content from a local file path.

Parameters:
  • file_path – The local path to the repository file.

  • logger – Logger to use for the operation.

  • name – Optional name for the repository. If not provided, derived from the file path.

Returns:

A Repository instance.

Raises:

GeneralError – If reading the file fails.

classmethod from_url(url: str, logger: Logger, name: str | None = None) Repository

Create a Repository instance by fetching content from a URL.

Parameters:
  • url – The URL to fetch the repository content from.

  • logger – Logger to use for the operation.

  • name – Optional name for the repository. If not provided, derived from the URL.

Returns:

A Repository instance.

Raises:

GeneralError – If fetching or parsing fails.

name: str

Uniquely identifiable name

repo_ids: list[str]

repository_ids present in the .repo file

class tmt.steps.prepare.artifact.providers.RpmVersion(name: str, version: str, release: str, arch: str, epoch: int = 0)

Bases: Version

Represents an RPM package version.

classmethod from_filename(filename: str) Self

Version constructed from RPM filename.

Example usage:

version_info = RpmVersion.from_filename("curl-8.11.1-7.fc42.x86_64.rpm")
classmethod from_rpm_meta(rpm_meta: dict[str, Any]) Self

Version constructed from RPM metadata dictionary.

Example usage:

version_info = RpmVersion.from_rpm_meta({
    "name": "curl",
    "version": "8.11.1",
    "release": "7.fc42",
    "arch": "x86_64"
})
exception tmt.steps.prepare.artifact.providers.UnsupportedOperationError

Bases: RuntimeError

Raised when an operation is intentionally unsupported by a provider.

class tmt.steps.prepare.artifact.providers.Version(name: str, version: str, release: str, arch: str, epoch: int = 0)

Bases: object

Version information for artifacts.

arch: str
epoch: int = 0
name: str
property nevra: str
property nvra: str
release: str
version: str