File python-spf-engine.spec of Package python-spf-engine

#
# spec file for package python-spf-engine
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
%define baseversion 2.9
%define subversion .3
%define policyname python-policyd-spf
Name:           python-spf-engine
Version:        %{baseversion}%{subversion}
Release:        0
Summary:        SPF processing for Postfix (and Sendmail)
License:        Apache-2.0 AND GPL-2.0-only
Group:          Development/Languages/Python
URL:            https://launchpad.net/spf-engine
Source0:        https://launchpad.net/spf-engine/%{baseversion}/%{version}/+download/spf-engine-%{version}.tar.gz
Source1:        https://launchpad.net/spf-engine/%{baseversion}/%{version}/+download/spf-engine-%{version}.tar.gz.asc
BuildArch:      noarch
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module pyspf}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires(post):    update-alternatives
Requires(postun):  update-alternatives
Requires:       python-authres
Requires:       python-pyspf >= 2.0.9
Recommends:     python-pymilter
# trick the python_subpackages, so it does not change it to python3 string
%define oname python
Obsoletes:      %{policyname} < 2
Conflicts:      %{policyname}
Provides:       %{policyname} = %{version}
Provides:       %{oname}-spf-engine = %{version}

%python_subpackages

%description
This project provides the SPF (Sender Policy Framework) back-end for both pypolicyd-spf
(for which it was originally developed) and an future SPF milter using pymilter. The goal
is to provide a common back-end for common features for support SPF integration with
Postfix and Sendmail using both the Postfix policy service and the Sendmail milter
protocol (also available with Postfix).

%prep
%setup -q -n spf-engine-%{version}
# For rpmlint warning: remove shebang from python library:
sed -i '/^#!/d' spf_engine/*.py

%build
%python_build

%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/policyd-spf
%python_clone -a %{buildroot}%{_bindir}/pyspf-milter
mv %{buildroot}%{_prefix}/etc/%{policyname} %{buildroot}%{_sysconfdir}/
install -m 644 policyd-spf.conf.commented %{buildroot}%{_sysconfdir}/%{policyname}/
rm -rf %{buildroot}%{_prefix}/etc
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcpyspf-milter
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%post
%python_install_alternative policyd-spf
%python_install_alternative pyspf-milter
%service_add_post pyspf-milter.service

%postun
%python_uninstall_alternative policyd-spf
%python_uninstall_alternative pyspf-milter
%service_del_postun pyspf-milter.service

%pre
%service_add_pre pyspf-milter.service

%preun
%service_del_preun pyspf-milter.service

%files %{python_files}
%doc CHANGES README README.per_user_whitelisting
%doc %{_mandir}/*/*
%license COPYING
%python_alternative %{_bindir}/policyd-spf
%python_alternative %{_bindir}/pyspf-milter
%{python_sitelib}/*
%dir %{_sysconfdir}/%{policyname}
%config(noreplace) %{_sysconfdir}/%{policyname}/policyd-spf.conf
%config %{_sysconfdir}/%{policyname}/policyd-spf.conf.commented
%{_prefix}/lib/systemd/system/pyspf-milter.service
%{_sbindir}/rcpyspf-milter

%changelog
openSUSE Build Service is sponsored by