Jump to: navigation, search

Difference between revisions of "Rpm-packaging/ContentStyle"

(Example)
(Example: Use pypi.io)
 
(2 intermediate revisions by one other user not shown)
Line 8: Line 8:
 
==Indentation==
 
==Indentation==
 
* Horizontal indentation - the values goes right after the BuildRequires: and 2 spaces.
 
* Horizontal indentation - the values goes right after the BuildRequires: and 2 spaces.
* Vertical indentation - all logical blocks like %pre, %build, %install, %files, etc should be separated with 2 newlines.
+
* Vertical indentation - all logical blocks like %pre, %build, %install, %files, etc should be separated with 1 newline.
  
 
==Example==
 
==Example==
 
<pre><nowiki>
 
<pre><nowiki>
 
%global sname py_name
 
%global sname py_name
Name:         {{ py2name('py_name') }}
+
Name:           {{ py2name('py_name') }}
Version:       X.Y.Z
+
Version:       X.Y.Z
Release:       0
+
Release:       0
Summary:       A for .... functionality for OpenStack projects
+
Summary:       A for .... functionality for OpenStack projects
License:       {{ 'Apache-2.0' | license }}
+
License:       {{ 'Apache-2.0' | license }}
Group:         Development/Languages/Python
+
Group:         Development/Languages/Python
Url:           http://www.homepage.org/
+
Url:           http://www.homepage.org/
Source:       https://pypi.python.org/packages/source/o/%{sname}/%{sname}-%{version}.tar.gz
+
Source:         https://pypi.io/packages/source/o/%{sname}/%{sname}-%{version}.tar.gz
BuildRequires: openstack-macros
+
BuildRequires: openstack-macros
BuildRequires: {{ py2pkg('devel') }}
+
BuildRequires: {{ py2pkg('devel') }}
BuildRequires: {{ py2pkg('build_req0') }}
+
BuildRequires: {{ py2pkg('build_req0') }}
BuildRequires: {{ py2pkg('build_req1') }}
+
BuildRequires: {{ py2pkg('build_req1') }}
Requires:     {{ py2pkg('runtume_req0') }}
+
Requires:       {{ py2pkg('runtume_req0') }}
Requires:     {{ py2pkg('runtume_req1') }}
+
Requires:       {{ py2pkg('runtume_req1') }}
BuildArch:     noarch
+
BuildArch:     noarch
 
 
  
 
%description
 
%description
Line 35: Line 34:
 
* Source: http://git.openstack.org/cgit/openstack/py_name
 
* Source: http://git.openstack.org/cgit/openstack/py_name
 
* Bugs: http://bugs.launchpad.net/py_name
 
* Bugs: http://bugs.launchpad.net/py_name
 
  
 
%package doc
 
%package doc
Summary:       Documentation for the py_name
+
Summary:       Documentation for the py_name
Group:         Documentation
+
Group:         Documentation
BuildRequires: {{ py2pkg('doc builld req0') }}
+
BuildRequires: {{ py2pkg('doc builld req0') }}
BuildRequires: {{ py2pkg('doc builld req0') }}
+
BuildRequires: {{ py2pkg('doc builld req0') }}
 
+
Requires:      %{name} = ${version}
  
 
%description doc
 
%description doc
Documentation for the testr wrapper.
+
Documentation for py_name .........
 
 
  
 
%prep
 
%prep
 
%setup -q -n %{sname}-%{version}
 
%setup -q -n %{sname}-%{version}
 
  
 
%build
 
%build
Line 58: Line 54:
 
# remove the sphinx-build leftovers
 
# remove the sphinx-build leftovers
 
rm -rf doc/build/html/.{doctrees,buildinfo}
 
rm -rf doc/build/html/.{doctrees,buildinfo}
 
  
 
%install
 
%install
 
%{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot}
 
%{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot}
 
  
 
%check
 
%check
Line 68: Line 62:
 
export PYTHONPATH="%{python2_sitearch}:%{python2_sitelib}:%{buildroot}%{python2_sitelib}"
 
export PYTHONPATH="%{python2_sitearch}:%{python2_sitelib}:%{buildroot}%{python2_sitelib}"
 
%{__python2} setup.py testr
 
%{__python2} setup.py testr
 
  
 
%files
 
%files
Line 77: Line 70:
 
%{python2_sitelib}/py_name
 
%{python2_sitelib}/py_name
 
%{python2_sitelib}/py_name*egg-info
 
%{python2_sitelib}/py_name*egg-info
 
  
 
%files doc
 
%files doc
Line 83: Line 75:
 
%doc doc/build/html
 
%doc doc/build/html
  
 +
%changelog
  
%changelog
 
 
</nowiki></pre>
 
</nowiki></pre>

Latest revision as of 16:53, 13 July 2016

Code style definition

Code should be written in common manner and in the way easy to read.

Head

  • All %global variables must be declared at the very beginning
  • Name: value, which is used within py2name context function, must equals pypi name!
  • Version: value is almost equals to git tag. For non trivial versions containing dev, alpha, beta, rc in version should be used tilda=~ as delimiter from numerical version part .

Indentation

  • Horizontal indentation - the values goes right after the BuildRequires: and 2 spaces.
  • Vertical indentation - all logical blocks like %pre, %build, %install, %files, etc should be separated with 1 newline.

Example

%global sname py_name
Name:           {{ py2name('py_name') }}
Version:        X.Y.Z
Release:        0
Summary:        A for .... functionality for OpenStack projects
License:        {{ 'Apache-2.0' | license }}
Group:          Development/Languages/Python
Url:            http://www.homepage.org/
Source:         https://pypi.io/packages/source/o/%{sname}/%{sname}-%{version}.tar.gz
BuildRequires:  openstack-macros
BuildRequires:  {{ py2pkg('devel') }}
BuildRequires:  {{ py2pkg('build_req0') }}
BuildRequires:  {{ py2pkg('build_req1') }}
Requires:       {{ py2pkg('runtume_req0') }}
Requires:       {{ py2pkg('runtume_req1') }}
BuildArch:      noarch

%description
A py_name ......... for OpenStack projects
* Documentation: http://docs.openstack.org/developer/py_name
* Source: http://git.openstack.org/cgit/openstack/py_name
* Bugs: http://bugs.launchpad.net/py_name

%package doc
Summary:        Documentation for the py_name
Group:          Documentation
BuildRequires:  {{ py2pkg('doc builld req0') }}
BuildRequires:  {{ py2pkg('doc builld req0') }}
Requires:       %{name} = ${version}

%description doc
Documentation for py_name .........

%prep
%setup -q -n %{sname}-%{version}

%build
%{__python2} setup.py build
# generate html docs
%{__python2} setup.py build_sphinx
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot}

%check
export PATH="$PATH:%{buildroot}/%{_bindir}"
export PYTHONPATH="%{python2_sitearch}:%{python2_sitelib}:%{buildroot}%{python2_sitelib}"
%{__python2} setup.py testr

%files
%defattr(-,root,root,-)
%license LICENSE
%doc README.rst ChangeLog
%{_bindir}/py_name_cli
%{python2_sitelib}/py_name
%{python2_sitelib}/py_name*egg-info

%files doc
%license LICENSE
%doc doc/build/html

%changelog