File automx2.spec of Package automx2
#
# spec file for package automx2
#
# Copyright (c) 2020 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 skip_python2 1
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
%define apache httpd
%else
%define apache apache2
%endif
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: automx2
Version: 2019.0
Release: 0
License: GPL-3.0+
Summary: Mail client autoconfiguration service
Url: https://automx.org/
Group: Productivity/Networking/Email/Utilities
Source: https://files.pythonhosted.org/packages/source/a/automx2/automx2-%{version}.tar.gz
Source2: https://gitlab.com/automx/automx2/raw/master/contrib/automx2-sample.conf
Source3: https://gitlab.com/automx/automx2/raw/master/contrib/sqlite-generate.sh
Source4: automx2-apache.conf
Source5: automx2-nginx.conf
Source6: automx2.service
BuildRequires: %{apache}
BuildRequires: nginx
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module Flask}
BuildRequires: %{python_module Flask-Migrate}
BuildRequires: %{python_module Flask-SQLAlchemy}
BuildRequires: systemd-rpm-macros
Requires(pre): shadow
Requires: python3-Flask
Requires: python3-Flask-Migrate
Requires: python3-Flask-SQLAlchemy
Requires: sqlite3
%{?systemd_requires}
BuildArch: noarch
%description
%{name} makes configuring a mail account easy. It unites methods for automated
mailbox configuration from Apple, Microsoft and Mozilla in one tool.
%{name} is successor to automx. It has been designed to be easier to setup,
easier to configure and easier to use.
%package %{apache}
Summary: %{apache} configuration for %{name}
Requires: %{apache}
Requires: %{name}
Supplements: packageand(%{name}:%{apache})
%description %{apache}
This package provides the example %{apache} configuration to proxy to %{name}.
%package nginx
Summary: Nginx configuration for %{name}
Requires: nginx
Requires: %{name}
Supplements: packageand(%{name}:nginx})
%description nginx
This package provides the example Nginx configuration to proxy to %{name}.
%prep
%setup -q -n %{name}-%{version}
%build
%python_build
%install
%python_install
# move to FHS acceptable location
mkdir -p %{buildroot}%{_datadir}/%{name}
mv %{buildroot}%{_prefix}/scripts/* %{buildroot}%{_datadir}/%{name}/
sed -i 's:/usr/bin/env bash:/bin/bash:' %{buildroot}%{_datadir}/%{name}/*.sh
# install example config
install -D -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{name}.conf
# install statedir
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}
# apache
install -D -m0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/%{apache}/conf.d/%{name}.conf
# nginx
install -D -m0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/nginx/vhosts.d/%{name}.conf
# helper
install -D -m0755 %{SOURCE3} %{buildroot}%{_docdir}/sqlite-generate.sh
sed -i 's:/usr/bin/env bash:/bin/bash:' %{buildroot}%{_docdir}/sqlite-generate.sh
# systemd
install -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_sbindir}
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
%pre
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin -c "user for %{name}" %{name}
%service_add_pre %{name}.service
exit 0
%post
%service_add_post %{name}.service
%preun
%service_del_preun %{name}.service
%postun
%service_del_postun %{name}.service
%files
%doc README.md
%doc %{_docdir}/sqlite-generate.sh
%{python_sitelib}/*
%config(noreplace) %{_sysconfdir}/%{name}.conf
%{_datadir}/%{name}
%attr(0755,automx2,automx2) %dir %{_sharedstatedir}/%{name}
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%files %{apache}
%config(noreplace) %{_sysconfdir}/%{apache}/conf.d/%{name}.conf
%files nginx
%config(noreplace) %{_sysconfdir}/nginx/vhosts.d/%{name}.conf
%changelog