Package gbp :: Package rpm

[hide private]
[frames] | no frames]

# Package rpm

provides some rpm source package related helpers

Submodules | [hide private]

- gbp.rpm.git
- gbp.rpm.lib_rpm: Wrapper module for librpm
- gbp.rpm.linkedlist: Simple implementation of a doubly linked list
- gbp.rpm.policy: Default packaging policy for RPM

Classes | [hide private]

| NoSpecError Spec file parsing error
| MacroExpandError Macro expansion in spec file failed
| RpmUpstreamSource Upstream source class for RPM packages
| SrcRpmFile Keeps all needed data read from a source rpm
| SpecFile Class for parsing/modifying spec files

Functions | [hide private]

parse_srpm(srpmfile) parse srpm by creating a SrcRpmFile object |

guess_spec_fn(file_list, preferred_name=None) Guess spec file from a list of filenames |

guess_spec(topdir, recursive=True, preferred_name=None) Guess a spec file |

guess_spec_repo(repo, treeish, topdir=`'````'`, recursive=True, preferred_name=None) Try to find/parse the spec file from a given git treeish. |

spec_from_repo(repo, treeish, spec_path) Get and parse a spec file from a give Git treeish |

`int`

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

string_to_int(val_str) Convert string of possible unit identifier to int. |

`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')]

split_version_str(version) Parse full version string and split it into individual "version components", i.e. |

`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'})

compose_version_str(evr) Compose a full version string from individual "version components", i.e. |

Variables | [hide private]

| __package__ = ``'``gbp.rpm``'``

Function Details | [hide private]

### string_to_int(val_str)

Convert string of possible unit identifier to int.

Parameters:
  - `val_str` (`str`) - value to be converted
Returns: `int`

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

  value as integer

### split_version_str(version)

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

Parameters:
  - `version` (`str`) - full version of a package
Returns: `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')]

  individual version components

### compose_version_str(evr)

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

Parameters:
  - `evr` (`dict` of `str`) - dict of version components
Returns: `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'})

  full version