API: yum

Repository

class pubtools.pulplib.YumRepository[source]

A Repository for RPMs, errata and related content.

Method generated by attrs for class YumRepository.

population_sources

List of repository IDs used to populate this repository

ubi_population

Flag indicating whether repo should be populated from population_sources for the purposes of UBI

ubi_config_version

Version of UBI config that should be used for population of this repository.

importer

An object of YumImporter that is associated with the repository.

New in version 2.39.0.

get_binary_repository()[source]

Find and return the binary repository relating to this repository.

Yum repositories usually come in triplets of (binary RPMs, debuginfo RPMs, source RPMs). For example:

rhel-7-server-rpms__7Server__x86_64

binary

rhel-7-server-debug-rpms__7Server__x86_64

debug

rhel-7-server-source-rpms__7Server__x86_64

source

This method along with get_debug_repository() and get_source_repository() allow locating other repositories from within this group.

Returns:

Future[YumRepository]

Binary repository relating to this repository.

Future[None]

If there is no related repository.

get_debug_repository()[source]

Find and return the debug repository relating to this repository.

Returns:

Future[YumRepository]

Debug repository relating to this repository.

Future[None]

If there is no related repository.

get_source_repository()[source]

Find and return the source repository relating to this repository.

Returns:

Future[YumRepository]

Source repository relating to this repository.

Future[None]

If there is no related repository.

upload_rpm(file_obj, **kwargs)[source]

Upload an RPM to this repository.

Warning

For RPMs belonging to a module, it’s strongly advised to upload the module metadata first (using upload_modules()) and only proceed with uploading RPMs once module upload has completed.

This reduces the risk of accidentally publishing a repository with modular RPMs without the corresponding metadata (which has a much worse impact than publishing metadata without the corresponding RPMs).

Parameters:
  • file_obj (str, file object) –

    If it’s a string, then it’s the path of an RPM to upload.

    Otherwise, it should be a file-like object pointing at the bytes to upload. The client takes ownership of this file object; it should not be modified elsewhere, and will be closed when upload completes.

  • kwargs

    Additional field values to set on the uploaded unit.

    Any RpmUnit fields documented as mutable may be included here (for example, cdn_path). An error will occur if attempting to set other fields.

Returns:

Future[list of Task]

A future which is resolved after content has been imported to this repo.

Raises:

DetachedException – If this instance is not attached to a Pulp client.

New in version 2.16.0.

New in version 2.20.0: Added ability to set mutable fields on upload.

upload_metadata(file_obj, metadata_type)[source]

Upload a metadata file to this repository.

A metadata file is any additional file which will be published alongside, and referenced from, the repodata .xml and .sqlite files when this repo is published.

Parameters:
  • file_obj (str, file object) –

    If it’s a string, then it’s the path of a file to upload.

    Otherwise, it should be a file-like object pointing at the bytes to upload. The client takes ownership of this file object; it should not be modified elsewhere, and will be closed when upload completes.

  • metadata_type (str) –

    Identifies the type of metadata being uploaded.

    This is an arbitrary string which will be reproduced in the yum repo metadata on publish. The appropriate value depends on the type of data being uploaded. For example, "productid" should be used when uploading an RHSM-style product certificate.

    A repository may only contain a single metadata file of each type. If a file of this type is already present in the repo, it will be overwritten by the upload.

Returns:

Future[list of Task]

A future which is resolved after content has been imported to this repo.

Raises:

DetachedException – If this instance is not attached to a Pulp client.

New in version 2.17.0.

upload_modules(file_obj)[source]

Upload a modulemd stream to this repository.

All supported documents in the given stream will be imported to this repository. On current versions of Pulp 2.x, this means only:

Attempting to use other document types may result in an error.

Parameters:

file_obj (str, file object) –

If it’s a string, then it’s the path of a modulemd YAML file to upload.

Otherwise, it should be a file-like object pointing at the text to upload. The client takes ownership of this file object; it should not be modified elsewhere, and will be closed when upload completes.

Returns:

Future[list of Task]

A future which is resolved after content has been imported to this repo.

Raises:

DetachedException – If this instance is not attached to a Pulp client.

New in version 2.17.0.

upload_comps_xml(file_obj)[source]

Upload a comps.xml file to this repository.

Warning

Beware of the following quirks with respect to the upload of comps.xml:

  • Pulp does not directly store the uploaded XML. Instead, this library parses the XML and uses the content to store various units. The comps XML rendered as a yum repository is published is therefore not guaranteed to be bytewise-identical to the uploaded content.

  • The uploaded XML must contain all comps data for the repo, as any existing comps data will be removed from the repo.

  • The XML parser is not secure against maliciously constructed data.

  • The process of parsing the XML and storing units consists of multiple steps which cannot be executed atomically. That means if this operation is interrupted, the repository may be left with incomplete data. It’s recommended to avoid publishing a repository in this state.

Parameters:

file_obj (str, file object) –

If it’s a string, then it’s the path of a comps XML file to upload.

Otherwise, it should be a file-like object pointing at the bytes of a valid comps.xml file.

The client takes ownership of this file object; it should not be modified elsewhere, and will be closed when upload completes.

Returns:

Future[list of Task]

A future which is resolved after content has been imported to this repo.

Raises:

DetachedException – If this instance is not attached to a Pulp client.

New in version 2.17.0.

upload_erratum(erratum)[source]

Upload an erratum/advisory object to this repository.

Warning

There are many quirks with respect to advisory upload. Please be aware of the following before using this API:

  • Only one advisory with a given id may exist in the system.

  • When uploading an advisory with an id equal to one already in the system, the upload will generally be ignored (i.e. complete successfully but have no effect), unless either the version or updated fields have a value larger than the existing advisory.

    This implies that, if you want to ensure an existing advisory is updated, you must first search for the existing object and mutate one of these fields before uploading a modified object. The library will not take care of this for you.

  • When overwriting an existing advisory, all fields will be overwritten. The sole exception is the pkglist field which will be merged with existing data when applicable.

  • If an advisory with the same id is present in multiple published yum repositories with inconsistent fields, yum/dnf client errors or warnings may occur. It’s therefore recommended that, whenever an existing advisory is modified, every repository containing that advisory should be republished. The library will not take care of this for you.

  • The repository_memberships field on the provided object has no effect (it cannot be used to upload an advisory to multiple repos at once).

Parameters:

erratum (ErratumUnit) –

An erratum object.

Unlike most other uploaded content, errata are not backed by any file; any arbitrarily constructed ErratumUnit may be uploaded.

Returns:

Future[list of Task]

A future which is resolved after content has been imported to this repo.

Raises:

DetachedException – If this instance is not attached to a Pulp client.

New in version 2.17.0.

class pubtools.pulplib.YumSyncOptions[source]

Options controlling a yum repository sync().

Method generated by attrs for class YumSyncOptions.

query_auth_token

An authorization token that will be added to every request made to the feed URL’s server

max_downloads

Number of threads used when synchronizing the repository.

remove_missing

If true, as the repository is synchronized, old rpms will be removed.

retain_old_count

Count indicating how many old rpm versions to retain.

skip

List of content types to be skipped during the repository synchronization

checksum_type

checksum type to use for metadata generation.

Defaults to source checksum type of sha256

num_retries

Number of times to retry before declaring an error during repository synchronization

Default is 2.

download_policy

Set the download policy for a repository.

Supported options are immediate,on_demand,background

force_full

Boolean flag. If true, full re-sync is triggered.

require_signature

Requires that imported packages like RPM/DRPM/SRPM should be signed

allowed_keys

List of allowed signature key IDs that imported packages can be signed with

class pubtools.pulplib.YumImporter[source]

Method generated by attrs for class YumImporter.

type_id

Specific importer_type_id for Yum repositories.

Units: RPM

class pubtools.pulplib.RpmUnit[source]

A Unit representing an RPM.

New in version 1.5.0.

Method generated by attrs for class RpmUnit.

name

The name of this RPM.

Example: the name of bash-5.0.7-1.fc30.x86_64.rpm is “bash”.

version

The version of this RPM.

Example: the version of bash-5.0.7-1.fc30.x86_64.rpm is “5.0.7”.

release

The release of this RPM.

Example: the release of bash-5.0.7-1.fc30.x86_64.rpm is “1.fc30”.

arch

The architecture of this RPM.

Example: the arch of bash-5.0.7-1.fc30.x86_64.rpm is “x86_64”.

epoch

The epoch of this RPM (most commonly “0”).

Example: the epoch of 3:bash-5.0.7-1.fc30.x86_64.rpm is “3”.

signing_key

The short ID of the GPG key used to sign this RPM.

See also

signing_keys()

filename

Filename of this RPM.

Example: mod_security_crs-3.3.0-2.el8.noarch.rpm

sourcerpm

Source rpm filename if package is not source package.

Example: gnu-efi-3.0c-1.1.src.rpm.

md5sum

MD5 checksum of this RPM, as a hex string.

sha1sum

SHA1 checksum of this RPM, as a hex string.

sha256sum

SHA256 checksum of this RPM, as a hex string.

cdn_path

A path, relative to the CDN root, from which this RPM can be downloaded once published.

This path will not point to any specific repository. However, the RPM must have been published via at least one repository before this path can be accessed.

This field is mutable and may be set by upload_rpm() or update_content().

New in version 2.20.0.

cdn_published

Approximate datetime in UTC at which this RPM first became available at cdn_path, or None if this information is unavailable.

This field is mutable and may be set by upload_rpm() or update_content().

New in version 2.20.0.

repository_memberships

IDs of repositories containing the unit, or None if this information is unavailable.

New in version 2.6.0.

unit_id

The unique ID of this unit, if known.

New in version 2.20.0.

requires

List of dependencies that this RPM requires or None if this information is unavailable.

provides

List of capabilities that this RPM provides or None if this information is unavailable.

files

List of files that this RPM provides or None if this information is unavailable.

class pubtools.pulplib.RpmDependency[source]

An RPM dependency entry within requires() and provides().

Method generated by attrs for class RpmDependency.

name

A name of dependency - it can be name of rpm package, shared library, scriplet or another name of dependency.

version

Version of this RPM dependency.

release

Release of this RPM dependency.

epoch

Epoch of this RPM dependency.

flags

Flags representing relation to version of this RPM dependency.

Can be None if dependency does not specify any version. Otherwise, will be one of GT (greater than), EQ (equal), LT (less than), GE (greater than or equal) or LE (less than or equal).

Units: errata

class pubtools.pulplib.ErratumUnit[source]

A Unit representing an erratum/advisory.

New in version 2.17.0.

Method generated by attrs for class ErratumUnit.

id

The ID of this advisory.

Example: "RHSA-2021:0672"

version

The version of this advisory.

Though stored as a string, this field typically takes the form of an integer starting at “1” and incremented whenever the advisory is modified.

status

Status, typically ‘final’.

updated

Timestamp of the last update to this advisory.

Typically of the form ‘2019-12-31 06:54:41 UTC’, but this is not enforced.

issued

Timestamp of the initial release of this advisory.

Uses the same format as updated().

description

Full human-readable description of the advisory, usually multiple lines.

pushcount

Number of times advisory has been revised and published (starting at ‘1’).

reboot_suggested

True if rebooting host machine is recommended after installing this advisory.

from_

Contact email address for the owner of the advisory.

Note that the canonical name for this attribute is from. As this clashes with a Python keyword, in most contexts the attribute is available as an alias, from_.

rights

Copyright message.

title

Title of the advisory (e.g. ‘bash bugfix and enhancement’).

severity

Severity of the advisory, e.g. “low”, “moderate”, “important” or “critical”.

release

Release number. Typically an integer-string, initially “0”.

type

“bugfix”, “security” or “enhancement”.

solution

Text explaining how to apply the advisory.

summary

Typically a single sentence briefly describing the advisory.

content_types

A list of content types associated with the advisory.

For example, “rpm” may be found in this list if the advisory has any associated RPMs.

references

A list of references associated with the advisory.

pkglist

A list of package collections associated with the advisory.

container_list

A list of container images associated with the advisory.

repository_memberships

IDs of repositories containing the unit, or None if this information is unavailable.

unit_id

The unique ID of this unit, if known.

New in version 2.20.0.

class pubtools.pulplib.ErratumPackage[source]

A package (RPM) entry within a pkglist().

Method generated by attrs for class ErratumPackage.

arch

RPM architecture.

filename

RPM filename (basename).

epoch

RPM epoch.

name

RPM name (e.g. “bash-4.0.1-1.el7.x86_64.rpm” name is “bash”)

version

RPM version (e.g. “bash-4.0.1-1.el7.x86_64.rpm” version is “4.0.1”)

release

RPM release (e.g. “bash-4.0.1-1.el7.x86_64.rpm” version is “1.el7”)

src

Filename of the source RPM from which this RPM was built; equal to filename() for the source RPM itself.

reboot_suggested

True if rebooting host machine is recommended after installing this package.

md5sum

MD5 checksum of this RPM in hex string form, if available.

sha1sum

SHA1 checksum of this RPM in hex string form, if available.

sha256sum

SHA256 checksum of this RPM in hex string form, if available.

class pubtools.pulplib.ErratumModule[source]

A module entry within a pkglist().

Method generated by attrs for class ErratumModule.

name

Module name.

stream

Module stream.

version

Module version.

context

Module context.

arch

Module architecture.

class pubtools.pulplib.ErratumPackageCollection[source]

A collection of packages found within an pkglist().

A non-modular advisory typically contains only a single collection, while modular advisories typically contain one collection per module.

Method generated by attrs for class ErratumPackageCollection.

name

A name for this collection. The collection name has no specific meaning, but must be unique within an advisory.

packages

List of packages within this collection.

Type:

list[ErratumPackage]

short

An alternative name for this collection. In practice, this field is typically blank.

module

An ErratumModule defining the module this entry is associated with, if any.

class pubtools.pulplib.ErratumReference[source]

A reference within a references() list.

Method generated by attrs for class ErratumReference.

href

A URL.

id

A short ID for the reference, unique within this erratum.

title

A title for the reference; analogous to the ‘title’ attribute in HTML.

type

Type of reference. This defines the expected target of the URL and includes at least:

  • “self”: reference to a page for this advisory

  • “bugzilla”: reference to a bug

  • “other”: any other kind of reference

Units: modules

class pubtools.pulplib.ModulemdUnit[source]

A Unit representing a modulemd document.

New in version 1.5.0.

Method generated by attrs for class ModulemdUnit.

name

The name of this module.

Example: the name of javapackages-tools:201801:20180813043155:dca7b4a4:aarch64 is “javapackages-tools”.

stream

The stream of this module.

Example: the stream of javapackages-tools:201801:20180813043155:dca7b4a4:aarch64 is “201801”.

version

The version of this module.

Example: the version of javapackages-tools:201801:20180813043155:dca7b4a4:aarch64 is 20180813043155.

context

The context of this module.

Example: the context of javapackages-tools:201801:20180813043155:dca7b4a4:aarch64 is “dca7b4a4”.

arch

The architecture of this module.

Example: the arch of javapackages-tools:201801:20180813043155:dca7b4a4:aarch64 is “aarch64.

repository_memberships

IDs of repositories containing the unit, or None if this information is unavailable.

New in version 2.6.0.

unit_id

The unique ID of this unit, if known.

New in version 2.20.0.

artifacts

List of artifacts included in the module.

Typically a list of RPM NEVRAs (no ‘.rpm’ extension) including binary, debug and source RPMs.

Example:

["perl-version-7:0.99.24-441.module+el8.3.0+6718+7f269185.src",
 "perl-version-7:0.99.24-441.module+el8.3.0+6718+7f269185.x86_64"]
profiles

The profiles of this modulemd unit.

dependencies

List of dependencies that this modulemd requires for runtime or None if this information is unavailable.

property artifacts_filenames

RPM filenames for artifacts in this module (as opposed to the RPM NEVRAs returned by artifacts()).

Returns:

List[str]

Artifact RPM filenames.

property nsvca

Returns nsvca string of this module.

Example: “virt:av:8040020210622174547:522a0ee4:arch”

class pubtools.pulplib.ModulemdDefaultsUnit[source]

A Unit representing a modulemd_defaults document.

New in version 2.4.0.

Method generated by attrs for class ModulemdDefaultsUnit.

name

The name of this modulemd defaults unit

repo_id

The repository ID bound to this modulemd defaults unit

stream

The stream of this modulemd defaults unit

profiles

The profiles of this modulemd defaults unit.

repository_memberships

IDs of repositories containing the unit, or None if this information is unavailable.

New in version 2.6.0.

unit_id

The unique ID of this unit, if known.

New in version 2.20.0.

class pubtools.pulplib.ModulemdDependency[source]

A module dependency entry within dependencies().

Method generated by attrs for class ModulemdDependency.

name

The name of this dependency.

stream

The stream of this dependency.

Units: metadata

class pubtools.pulplib.YumRepoMetadataFileUnit[source]

A Unit representing a metadata file in a yum repo.

New in version 2.17.0.

Method generated by attrs for class YumRepoMetadataFileUnit.

data_type

The type of this metadata file, e.g. “productid”.

sha256sum

SHA256 checksum of this metadata file, if known, as a hex string.

repository_memberships

IDs of repositories containing the unit, or None if this information is unavailable.

unit_id

The unique ID of this unit, if known.

New in version 2.20.0.