Jump to: navigation, search

Difference between revisions of "Rpm-packaging/ReviewGuidelines"

(Initial guideline for package specification template)
 
(Removed syntax overview due update of documentation for renderspec)
Line 8: Line 8:
 
[https://github.com/openstack/renderspec renderspec] - main tool used for transformation from SPEC template into SPEC file.<br />
 
[https://github.com/openstack/renderspec renderspec] - main tool used for transformation from SPEC template into SPEC file.<br />
  
=A little bit about syntax=
+
 
As was mentioned above, Jinja2 format was chosen and used for templates. <br />
 
''Example of syntax from template:''<br />
 
Requires:      &#123;&#123; 'pbr' &#124; py2pkg &#125;&#125; &gt;= 1.6
 
'''pbr''' - python project name.<br />
 
'''py2pkg''' - filter name used in the renderspec for transformation to system package name.<br /><br />
 
License:      &#123;&#123; 'Apache-2.0' &#124; license &#125;&#125;
 
'''Apache-2.0''' - common licence name.<br />
 
'''license'''  - filter name used in the renderspec for transformation in required format(as an example - [https://spdx.org/spdx-license-list SPDX] for [https://www.suse.com/ SUSE]).<br />
 
 
 
=Common rules=
 
=Common rules=
 
==Head==
 
==Head==
* '''Names''':
 
Project ''names'' used in template and processed by filter - are '''source project''' names.<br />
 
''Example:''<br />
 
Name:          &#123;&#123; 'oslo.utils' &#124; py2pkg &#125;&#125;
 
'''oslo.utils''' - means that native name of python projects is - ''oslo.utils''.<br />
 
* '''Sources''':
 
Source code source and project url should be specified!<br />
 
''Example:''<br />
 
%global sname pysomething<br />Version:    1.2.3<br />Url:        https:&#47;&#47;launchpad.net&#47;%{sname}<br />Source0:    https:&#47;&#47;pypi.python.org&#47;packages&#47;source&#47;p&#47;%{sname}/%{sname}-%{version}.tar.gz
 
 
* '''Versions''':
 
* '''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!<br />
+
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<br />
 
''Example:''<br />
 
''Example:''<br />
  BuildRequires: &#123;&#123; 'netaddr' &#124; py2pkg &#125;&#125; >= 0.7.12
+
  BuildRequires: &#123;&#123; py2pkg('netaddr', ('>=', '0.7.12')) &#125;&#125;
  Requires: &#123;&#123; 'netaddr' &#124; py2pkg &#125;&#125; >= 0.7.12
+
  Requires: &#123;&#123; py2pkg('netaddr', ('>=', '0.7.12')) &#125;&#125;
 +
 
 +
In case of unset - un-managed versions - rendering should be executed with ''--requirements global-requirements.txt'' cli arguments to fill up resulting spec file with proper versions.  
  
 
==Documentation==
 
==Documentation==

Revision as of 06:32, 16 March 2016

Purpose

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).

Tool-set

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.


Common rules

Head

  • 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
Example:

BuildRequires: {{ py2pkg('netaddr', ('>=', '0.7.12')) }}
Requires:  {{ py2pkg('netaddr', ('>=', '0.7.12')) }}

In case of unset - un-managed versions - rendering should be executed with --requirements global-requirements.txt cli arguments to fill up resulting spec file with proper versions.

Documentation

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!
Exmaple:

%if %{with docs}
%package doc
....
%endif

%if %{with docs}
%files doc
...
%endif

Tests

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!
Exmaple:

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

%if %{with test}
%check
...
%endif

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