A new user interface for you! Read more...

File postfix-mta-sts-resolver.spec of Package postfix-mta-sts-resolver

#
# spec file for package postfix-mta-sts-resolver
#
# Copyright (c) 2018 Matthias Fehring <buschmann23@opensuse.org>
#
# 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/
#

%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

%define _grpname mta-sts
%define _usrname mta-sts
%define _confdir %{_sysconfdir}
%define _conffile mta-sts-daemon.yml

Name:           postfix-mta-sts-resolver
Version:        0.5.3
Release:        0
Summary:        Postfix MTA-STS Resolver
License:        MIT
Group:          Productivity/Networking/Email/Utilities
Url:            https://github.com/Snawoot/postfix-mta-sts-resolver
Source0:        https://github.com/Snawoot/postfix-mta-sts-resolver/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  python-rpm-macros
BuildRequires:  python3-setuptools >= 38.6.0
BuildRequires:  python3-devel >= 3.5.3
BuildRequires:  python3-aiodns >= 1.1.1
BuildRequires:  python3-aiohttp >= 3.4.4
BuildRequires:  python3-aiosqlite >= 0.10.0
BuildRequires:  python3-aioredis >= 1.2.0
BuildRequires:  python3-PyYAML >= 3.12
BuildRequires:  python3-pynetstring >= 0.1.dev2
BuildRequires:  python3-pycares >= 2.3.0
BuildRequires:  python3-uvloop >= 0.11.0
BuildRequires:  python3-sdnotify >= 0.3.2
BuildRequires:  postfix >= 2.10
# START TESTING SECIONT
BuildRequires:  python3-pytest >= 3.0.0
BuildRequires:  python3-pytest-cov
BuildRequires:  python3-pytest-asyncio
BuildRequires:  python3-pytest-timeout
BuildRequires:  python3-pylint
BuildRequires:  python3-tox
BuildRequires:  python3-coverage
BuildRequires:  python3-async_generator
BuildRequires:  python3-twine
BuildRequires:  python3-wheel
BuildRequires:  python3-cryptography >= 1.6
# END TESTING SECTION
Requires(pre):  shadow
Requires:       postfix >= 2.10
Requires:       python3 >= 3.5.3
Requires:       python3-aiodns >= 1.1.1
Requires:       python3-aiohttp >= 3.4.4
Requires:       python3-PyYAML >= 3.12
Requires:       python3-pynetstring >= 0.1.dev2
Requires:       python3-pycares >= 2.3.0
Requires:       python3-sdnotify >= 0.3.2
Recommends:     python3-uvloop >= 0.11.0
Suggests:       python3-aiosqlite >= 0.10.0
Suggests:       python3-aioredis >= 1.2.0
%{?systemd_requires}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
Daemon which provides TLS client policy for Postfix via socketmap,
according to domain MTA-STS policy.


%prep
%setup -q

%build
%{__python3} setup.py build

%install
%{__python3} setup.py install --prefix=%{_prefix} --root=%{buildroot}

%{__install} -d %{buildroot}%{_confdir}
%{__install} -m 0644 config_examples/mta-sts-daemon.yml.internal %{buildroot}%{_confdir}/%{_conffile}

%{__install} -d %{buildroot}%{_sbindir}
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

%{__install} -d %{buildroot}%{_fillupdir}
%{__cat} > %{buildroot}%{_fillupdir}/sysconfig.%{name} << 'EOF'
# Set the necessary startup options
OPTIONS="-c %{_confdir}/%{_conffile} -v info"
EOF

%{__install} -d -m 0755 %{buildroot}%{_unitdir}
%{__cat} > %{buildroot}%{_unitdir}/%{name}.service << 'EOF'
[Unit]
Description=Daemon providing MTA-STS policy for Postfix
Documentation=https://github.com/Snawoot/%{name}
After=network.target nss-lookup.target syslog.target

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/%{name}
ExecStart=/usr/bin/mta-sts-daemon $OPTIONS
Restart=always
KillMode=process
TimeoutStartSec=10
TimeoutStopSec=30
User=%{_usrname}
Group=%{_grpname}

[Install]
WantedBy=multi-user.target
EOF

%{__install} -p -d %{buildroot}%{_tmpfilesdir}
%{__cat} > %{buildroot}%{_tmpfilesdir}/%{name}.conf <<EOF
# Type Path             Mode UID      GID         Age Argument
d %{_rundir}/%{name} 0700 %{_usrname} %{_grpname} -
EOF

# %%check
# %%__python3 setup.py test

%pre
getent group %{_grpname} >/dev/null || groupadd -r %{_grpname}
getent passwd %{_usrname} >/dev/null || useradd -r -g %{_grpname} -d %{_rundir}/%{name} -s /sbin/nologin -c "User for %{name}" %{_usrname}
%service_add_pre %{name}.service

%preun
%service_del_preun %{name}.service

%post
%service_add_post %{name}.service
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
%{fillup_only postfix-mta-sts-resolver}

%postun
%service_del_postun %{name}.service

%files
%defattr(-,root,root,-)
%license LICENSE
%doc README.md config_examples
%{_bindir}/mta-sts-daemon
%{_bindir}/mta-sts-query
%{_sbindir}/rc%{name}
%config(noreplace) %{_confdir}/%{_conffile}
%{python3_sitelib}/postfix_mta_sts_resolver-%{version}-py*egg-info
%{python3_sitelib}/postfix_mta_sts_resolver
%{_tmpfilesdir}/%{name}.conf
%dir %{_fillupdir}
%{_fillupdir}/sysconfig.%{name}
%ghost %{_rundir}/%{name}
%attr(0644,root,root) %{_unitdir}/%{name}.service

%changelog