File helios-server.spec of Package helios-server
#
# spec file for package helios-server
#
# 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/
#
%define wsgi_dir /srv/www/vhosts/%{name}
Name: helios-server
Version: 3.1.4+git20220206.e76171f
Release: 0
Summary: End-to-end verifiable voting system
License: Apache-2.0
Group: Productivity/Networking/Web/Utilities
URL: https://heliosvoting.org/
Source0: %{name}-%{version}.tar.xz
Source1: uwsgi.ini
Source2: %{name}-uwsgi.service
Source3: opensuse.py
Source4: opensuse.png
Patch0: %{name}-opensuse_auth.patch
Patch1: helios-server-disable-anymail.patch
Requires: python3-Django
Requires: python3-django-webtest
Requires: python3-gunicorn
Requires: python3-psycopg2
Requires: python3-celery
Requires: python3-django-picklefield
Requires: python3-python-dateutil
Requires: python3-unicodecsv
Requires: python3-bleach
Requires: python3-validate_email
Requires: python3-pycryptodome
Requires: python3-python3-openid
Requires: python3-boto
Requires: python3-oauth2client
Requires: python3-rollbar
BuildRequires: python3-Django
BuildRequires: python3-django-webtest
BuildRequires: python3-gunicorn
BuildRequires: python3-psycopg2
BuildRequires: python3-celery
BuildRequires: python3-django-picklefield
BuildRequires: python3-python-dateutil
BuildRequires: python3-unicodecsv
BuildRequires: python3-bleach
BuildRequires: python3-validate_email
BuildRequires: python3-pycryptodome
BuildRequires: python3-python3-openid
BuildRequires: python3-boto
BuildRequires: python3-oauth2client
BuildRequires: python3-rollbar
# optional requirements which are not needed in the openSUSE infra, and also not available as package:
# python3-dj_database_url - only used in shipped settings.py if ENV[database_url] is given
# python3-django-anymail - disabled in settings.py, only used/needed for sending mails via Amazon SES, Mailgun etc.
# python3-django-ses - only used/needed if using the AWS mail backend
BuildRequires: fdupes
BuildRequires: systemd-rpm-macros
Requires(pre): shadow
BuildArch: noarch
%{?systemd_requires}
%description
Voting system written in python/Django.
%package uwsgi
Summary: UWSGI support for %{name}
Group: Development/Languages/Python
Requires: %{name} = %{version}
Requires: uwsgi-python3
%description uwsgi
This package provides support for running %{name} under uwsgi
%prep
%setup -q
%patch0 -p1
%patch1 -p1
install -m 0644 %{SOURCE3} helios_auth/auth_systems/opensuse.py
install -m 0644 %{SOURCE4} helios_auth/media/login-icons/opensuse.png
%build
:
%install
mkdir -p %{buildroot}%{python3_sitelib}/%{name}
cp -r * %{buildroot}%{python3_sitelib}/%{name}
install -d -m 0755 %{buildroot}/%{_sbindir}
install -d -m 0755 %{buildroot}/%{wsgi_dir}
install -d -m 0755 %{buildroot}/%{wsgi_dir}/tmp/sockets
# systemd service
install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}-uwsgi.service
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-uwsgi
install -D -m 0644 %{SOURCE1} %{buildroot}/%{wsgi_dir}/uwsgi.ini
for f in settings wsgi; do
ln -s %{python3_sitelib}/%{name}/${f}.py %{buildroot}/%{wsgi_dir}/
done
# replace hardcoded things
sed -i -e 's|@SITEDIR@|%{python3_sitelib}/%{name}|' %{buildroot}/%{wsgi_dir}/uwsgi.ini
sed -i -e 's|@WSGI_DIR@|%{wsgi_dir}|' %{buildroot}/%{_unitdir}/%{name}-uwsgi.service %{buildroot}/%{wsgi_dir}/uwsgi.ini
%fdupes %{buildroot}%{python3_sitelib}
%check
# sed in sqlite instead of pgsql
sed -i -e 's:django.db.backends.postgresql_psycopg2:django.db.backends.sqlite3:g' settings.py
# https://github.com/benadida/helios-server/issues/338 - "select ... for update" not supported in sqlite3
sed -i -e '/select .* for update/ s:for update::g' helios/utils.py
python3 manage.py test
%pre
getent group helios >/dev/null || %{_sbindir}/groupadd -r helios || :
getent passwd helios >/dev/null || \
%{_sbindir}/useradd -g helios -s /bin/false -r -c "HeliosVoting" -d %{wsgi_dir} helios || :
%pre uwsgi
%service_add_pre %{name}-uwsgi.service
%preun uwsgi
%service_del_preun %{name}-uwsgi.service
%post uwsgi
%service_add_post %{name}-uwsgi.service
%postun uwsgi
%service_del_postun %{name}-uwsgi.service
%files
%doc INSTALL.md LICENSE README.md
%dir %{python3_sitelib}/%{name}
%config(noreplace) %{python3_sitelib}/%{name}/settings.py
%config(noreplace) %{python3_sitelib}/%{name}/wsgi.py
%{python3_sitelib}/%{name}/*
%dir /srv/www/vhosts
%defattr(-,root,helios)
%dir %{wsgi_dir}
%{wsgi_dir}/settings.py
%files uwsgi
%config(noreplace) %{wsgi_dir}/uwsgi.ini
%{_sbindir}/rc%{name}-uwsgi
%{_unitdir}/%{name}-uwsgi.service
%defattr(-,helios,helios)
%{wsgi_dir}/tmp/
%{wsgi_dir}/wsgi.py
%changelog