# `gbp.rpm` package documentation

Part of `gbp`

provides some rpm source package related helpers

Module | changelog | An RPM Changelog
Module | git | No module docstring; 1/1 classes documented
Module | lib_rpm | Wrapper module for librpm
Module | linkedlist | Simple implementation of a doubly linked list
Module | policy | Default packaging policy for RPM

From the `__init__.py` module:

Class | MacroExpandError | Macro expansion in spec file failed
Class | NoSpecError | Spec file parsing error
Class | RpmUpstreamSource | Upstream source class for RPM packages
Class | SpecFile | Class for parsing/modifying spec files
Class | SrcRpmFile | Keeps all needed data read from a source rpm
Function | compose_version_str | Compose a full version string from individual "version components", i.e. epoch, version and release
Function | filter_version | Remove entry from the version dict
Function | guess_spec | Guess a spec file
Function | guess_spec_fn | Guess spec file from a list of filenames
Function | guess_spec_repo | Try to find/parse the spec file from a given git treeish.
Function | parse_srpm | parse srpm by creating a SrcRpmFile object
Function | spec_from_repo | Get and parse a spec file from a give Git treeish
Function | split_version_str | Parse full version string and split it into individual "version components", i.e. upstreamversion, epoch and release
Function | string_to_int | Convert string of possible unit identifier to int.

def parse_srpm(srpmfile):

parse srpm by creating a SrcRpmFile object

def guess_spec_fn(file_list, preferred_name=None):

Guess spec file from a list of filenames

def guess_spec(topdir, recursive=(True), preferred_name=None):

Guess a spec file

def guess_spec_repo(repo, treeish, topdir="""""", recursive=(True), preferred_name=None):

Try to find/parse the spec file from a given git treeish.

def spec_from_repo(repo, treeish, spec_path):

Get and parse a spec file from a give Git treeish

def string_to_int(val_str):

Convert string of possible unit identifier to int.

Parameters | val_str | value to be converted (type: `str`)

Returns

value as integer (type: `int`

    >>> string_to_int("1234")
    1234
    >>> string_to_int("123k")
    125952
    >>> string_to_int("1234K")
    1263616
    >>> string_to_int("1M")
    1048576

)

def split_version_str(version):

Parse full version string and split it into individual "version components", i.e. upstreamversion, epoch and release

Parameters | version | full version of a package (type: `str`)

Returns

individual version components (type: `dict`

    >>> sorted(split_version_str("1").items())
    [('epoch', None), ('release', None), ('upstreamversion', '1')]
    >>> sorted(split_version_str("1.2.3-5.3").items())
    [('epoch', None), ('release', '5.3'), ('upstreamversion', '1.2.3')]
    >>> sorted(split_version_str("3:1.2.3").items())
    [('epoch', '3'), ('release', None), ('upstreamversion', '1.2.3')]
    >>> sorted(split_version_str("3:1-0").items())
    [('epoch', '3'), ('release', '0'), ('upstreamversion', '1')]

)

def compose_version_str(evr):

Compose a full version string from individual "version components", i.e. epoch, version and release

Parameters | evr | dict of version components (type: `dict` of `str`)

Returns

full version (type: `str`

    >>> compose_version_str({'epoch': '', 'upstreamversion': '1.0'})
    '1.0'
    >>> compose_version_str({'epoch': '2', 'upstreamversion': '1.0', 'release': None})
    '2:1.0'
    >>> compose_version_str({'epoch': None, 'upstreamversion': '1', 'release': '0'})
    '1-0'
    >>> compose_version_str({'epoch': '2', 'upstreamversion': '1.0', 'release': '2.3'})
    '2:1.0-2.3'
    >>> compose_version_str({'epoch': '2', 'upstreamversion': '', 'release': '2.3'})

)

def filter_version(evr, *keys):

Remove entry from the version dict

Parameters | evr | dict of version components (type: `dict` of `str`)
| keys | keys to remove (type: `str`s)

Returns

new version dict (type: `dict` of `str`

    >>> sorted(list(filter_version({'epoch': 'foo', 'upstreamversion': 'bar', 'vendor': 'baz'}, 'vendor').keys()))
    ['epoch', 'upstreamversion']
    >>> list(filter_version({'epoch': 'foo', 'upstreamversion': 'bar', 'revision': 'baz'}, 'epoch', 'revision').keys())
    ['upstreamversion']

)