Jump to: navigation, search


< Rpm-packaging
Revision as of 17:48, 26 February 2016 by IYozhikov (talk | contribs) (Initial guideline for package specification template)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


The main goal to use templates instead of SPEC - flexibility and unification. Templates made in Jinja2 format.
It means that templates made in one way after processing by renderspec tool will fit all supported Linux vendors(SUSE, Fedora, CentOS).


openstack-macros - sub-project which allows to add or substitute required RPM macro used in SPEC template.
pymod2pkg - project used for translation of python source name aka pypi name into Linux package name.
renderspec - main tool used for transformation from SPEC template into SPEC file.

A little bit about syntax

As was mentioned above, Jinja2 format was chosen and used for templates.
Example of syntax from template:

Requires:      {{ 'pbr' | py2pkg }} >= 1.6

pbr - python project name.
py2pkg - filter name used in the renderspec for transformation to system package name.

License:       {{ 'Apache-2.0' | license }}

Apache-2.0 - common licence name.
license - filter name used in the renderspec for transformation in required format(as an example - SPDX for SUSE).

Common rules


  • Names:

Project names used in template and processed by filter - are source project names.

Name:          {{ 'oslo.utils' | py2pkg }}

oslo.utils - means that native name of python projects is - oslo.utils.

  • Sources:

Source code source and project url should be specified!

%global sname pysomething
Version: 1.2.3
Url: https://launchpad.net/%{sname}
Source0: https://pypi.python.org/packages/source/p/%{sname}/%{sname}-%{version}.tar.gz
  • Versions:

Lower bounds should be specified in both cases - for Requires and for BuildRequires entries at least for projects with versions set in requirements.txt and test-requirements.txt files!

BuildRequires: {{ 'netaddr' | py2pkg }} >= 0.7.12
Requires: {{ 'netaddr' | py2pkg }} >= 0.7.12


For *-doc package should be specified additional section which describes all meta-data for doc package.
BuildRequires: - populated only with projects required for documentation build.
Please use %bcond_with docs in case of necessity!

%if %{with docs}
%package doc

%if %{with docs}
%files doc


Useful but not mandatory. All directives for unit tests must be set under %check section.
All required for tests projects should be specified as BuildRequires: in the top of template.
Please use %bcond_with test in case of necessity!

%if %{with test}
BuildRequires: required for test projects

%if %{with test}

Misc but important!

Under %files section for each package in SPEC template:

  • Section %doc should not include: HACKING*, CONTRIBUTING* and AUTHORS
  • Section %license should be specified in case of LICENCE file availability in source code