File python-puppetboard.spec of Package python-puppetboard
#
# spec file for package python-puppetboard
#
# Copyright (c) 2016 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/
#
%define pyname puppetboard
%define wsgi_dir /srv/www/vhosts/%{pyname}
%define apache_confd %{_sysconfdir}/apache2/conf.d
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch: noarch
%endif
Name: python-puppetboard
Version: 0.0.5
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
BuildRequires: apache2
BuildRequires: fdupes
BuildRequires: python-Flask
BuildRequires: python-Flask-WTF
BuildRequires: python-MarkupSafe
BuildRequires: python-WTForms
BuildRequires: python-devel
BuildRequires: python-itsdangerous
BuildRequires: python-jinja2
BuildRequires: python-pypuppetdb
BuildRequires: python-requests
BuildRequires: python-setuptools
BuildRequires: python-werkzeug
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
%{?systemd_requires}
%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
%setup -q -n %{pyname}-%{version}
%build
python setup.py build
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
%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
%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
%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 apache
%defattr(-,root,root,-)
%config(noreplace) %{apache_confd}/%{pyname}-wsgi.conf
%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