File python-puppetboard.spec of Package python-puppetboard
#
# spec file for package python-puppetboard
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# https://github.com/voxpupuli/puppetboard/issues/361
%define skip_python3 1
%define pyname puppetboard
%define wsgi_dir /srv/www/vhosts/%{pyname}
%define apache_confd %{_sysconfdir}/apache2/conf.d
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-puppetboard
Version: 0.3.0
Release: 0
Summary: Web frontend for PuppetDB
License: Apache-2.0
Group: Development/Languages/Python
Url: https://github.com/voxpupuli/puppetboard
Source: https://pypi.python.org/packages/source/p/%{pyname}/%{pyname}-%{version}.tar.gz
Source1: wsgi.py
Source2: apache2-wsgi.conf
Source3: uwsgi.ini
Source4: %{pyname}-uwsgi.service
Patch0: fix_setup_build.patch
BuildRequires: %{python_module Flask-WTF}
BuildRequires: %{python_module Flask}
BuildRequires: %{python_module MarkupSafe}
BuildRequires: %{python_module WTForms}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module itsdangerous}
BuildRequires: %{python_module Jinja2}
BuildRequires: %{python_module pypuppetdb}
BuildRequires: %{python_module requests}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module Werkzeug}
BuildRequires: %{python_module pytest-runner}
BuildRequires: apache2
BuildRequires: fdupes
BuildRequires: pkgconfig
BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(systemd)
Requires: python-Flask
Requires: python-Flask-WTF
Requires: python-MarkupSafe
Requires: python-WTForms
Requires: python-itsdangerous
Requires: python-jinja2
Requires: python-pypuppetdb
Requires: python-requests
Requires(pre): shadow
Provides: %{pyname}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%{?systemd_requires}
%python_subpackages
%description
Puppetboard is a web interface to PuppetDB aiming to replace the reporting functionality of Puppet Dashboard.
Puppetboard relies on the pypuppetdb library to fetch data from PuppetDB and is built with the help of the Flask microframework.
%package apache
Summary: Apache + mod_wsgi support for puppetboard
Group: Development/Languages/Python
Requires: %{name} = %{version}
Requires: apache2-mod_wsgi
%description apache
This package provides support for running puppetboard under Apache + mod_wsgi
%package uwsgi
Summary: UWSGI support for puppetboard
Group: Development/Languages/Python
Requires: %{name} = %{version}
Requires: uwsgi-python
%description uwsgi
This package provides support for running puppetboard under uwsgi
%prep
%autosetup -n %{pyname}-%{version}
%build
%python_build
%install
%python_install
%fdupes %{buildroot}%{_prefix}
install -d -m 0755 %{buildroot}/%{_sbindir}
install -d -m 0755 %{buildroot}/%{apache_confd}
install -d -m 0755 %{buildroot}/%{wsgi_dir}
install -d -m 0755 %{buildroot}/%{wsgi_dir}/tmp/sockets
install -m 0644 %{pyname}/default_settings.py %{buildroot}/%{wsgi_dir}/settings.py
install -m 0644 %{SOURCE1} %{buildroot}/%{wsgi_dir}
install -m 0644 %{SOURCE2} %{buildroot}/%{apache_confd}/%{pyname}-wsgi.conf
install -m 0644 %{SOURCE3} %{buildroot}/%{wsgi_dir}/uwsgi.ini
install -D -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/%{pyname}-uwsgi.service
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{pyname}-uwsgi
sed -i -e 's|@PYTHON_SITELIB@|%{python_sitelib}|' -e 's|@WSGI_DIR@|%{wsgi_dir}|' \
%{buildroot}/%{apache_confd}/%{pyname}-wsgi.conf
sed -i -e 's|@WSGI_DIR@|%{wsgi_dir}|' %{buildroot}/%{wsgi_dir}/wsgi.py \
%{buildroot}/%{wsgi_dir}/uwsgi.ini %{buildroot}/%{_unitdir}/%{pyname}-uwsgi.service
rm -rf %{buildroot}%{python_sitelib}/test
%pre
getent group %{pyname} >/dev/null || %{_sbindir}/groupadd -r %{pyname} || :
getent passwd %{pyname} >/dev/null || \
%{_sbindir}/useradd -g %{pyname} -s /bin/false -r -c "PuppetBoard" \
-d %{wsgi_dir} %{pyname} || :
%pre uwsgi
%service_add_pre %{pyname}-uwsgi.service
%preun uwsgi
%service_del_preun %{pyname}-uwsgi.service
%post uwsgi
%service_add_post %{pyname}-uwsgi.service
%postun uwsgi
%service_del_postun %{pyname}-uwsgi.service
%files %{python_files}
%defattr(-,root,root,-)
%doc LICENSE README.rst CHANGELOG.rst
%{python_sitelib}/*
%dir /srv/www/vhosts
%defattr(-,root,%{pyname})
%dir %{wsgi_dir}
%config(noreplace) %{wsgi_dir}/settings.py
%config(noreplace) %{wsgi_dir}/wsgi.py
%files %{python_files apache}
%defattr(-,root,root,-)
%config(noreplace) %{apache_confd}/%{pyname}-wsgi.conf
%files %{python_files uwsgi}
%defattr(-,root,root,-)
%config(noreplace) %{wsgi_dir}/uwsgi.ini
%{_sbindir}/rc%{pyname}-uwsgi
%{_unitdir}/%{pyname}-uwsgi.service
%defattr(-,%{pyname},%{pyname})
%{wsgi_dir}/tmp/
%changelog