rpms – RPM metadata

This module provides classes for manipulating rpms.json files. rpms.json files provide details about RPMs included in composes.

Example:

import productmd.compose
compose = productmd.compose.Compose("/path/to/compose")

# Print the entire dict that maps all variants, arches, and RPMs for this
# compose:
print(compose.rpms.rpms)

# Find all the source RPMs in this compose:
srpms = set()

for variant in compose.rpms.rpms:
    for arch in compose.rpms.rpms[variant]:
        for srpm in compose.rpms.rpms[variant][arch]:
            srpms.add(srpm)

print(srpms)
# ... prints the set of SRPMs in all our variants:
# ['ceph-2:12.2.5-25.el7cp.src',
#  'ceph-ansible-0:3.1.0-0.1.rc9.el7cp.src',
#  'ceph-iscsi-cli-0:2.7-1.el7cp.src',
#  ...
# ]

Classes

class productmd.rpms.Rpms
add(variant, arch, nevra, path, sigkey, category, srpm_nevra=None)

Map RPM to to variant and arch.

Parameters:
  • variant (str) – compose variant UID
  • arch (str) – compose architecture
  • nevra (str) – name-epoch:version-release.arch
  • sigkey (str or None) – sigkey hash
  • category (str) – RPM category, one of binary, debug, source
  • srpm_nevra (str) – name-epoch:version-release.arch of RPM’s SRPM
dump(f)

Dump data to a file.

Parameters:f (file or str) – file-like object or path to file
dumps()

Dump data to a string.

Return type:str
load(f)

Load data from a file.

Parameters:f (file or str) – file-like object or path to file
loads(s)

Load data from a string.

Parameters:s (str) – input data
validate()

Validate attributes by running all self._validate_*() methods.

Raises:
  • TypeError – if an attribute has invalid type
  • ValueError – if an attribute contains invalid value