## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 7;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global pypi_name postfix_mta_sts_resolver

Name:           postfix-mta-sts-resolver
Version:        1.4.0
Release:        %autorelease
Summary:        Daemon providing MTA-STS map to Postfix

License:        MIT
URL:            https://github.com/Snawoot/%{name}

# pypi version is stripped down without manpages, doc and examples
Source0:        https://github.com/Snawoot/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
Source1:        mta-sts-daemon.yml
Source2:        postfix-mta-sts-resolver.service
Source3:        https://github.com/Snawoot/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc
Source4:        https://github.com/Snawoot.gpg

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  rubygem-asciidoctor
BuildRequires:  make
BuildRequires:  systemd-rpm-macros
BuildRequires:  pyproject-rpm-macros
BuildRequires:  sed
BuildRequires:  gnupg2

Requires(pre):  shadow-utils

%description
postfix-mta-sts-resolver provides a lookup daemon and command line
query utility for MTA-STS policies (RFC 8461).  The daemon provides TLS
client policy to Postfix via socketmap.



%prep
%{gpgverify} --keyring='%{SOURCE4}' --signature='%{SOURCE3}' --data='%{SOURCE0}'
%autosetup -n %{name}-%{version}


%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel
make doc


%install
%pyproject_install
%pyproject_save_files postfix_mta_sts_resolver

install -p -D -m 0640 %{SOURCE1} %{buildroot}%{_sysconfdir}/mta-sts-daemon.yml
install -p -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service

mkdir -p %{buildroot}%{_sharedstatedir}/mta-sts

mkdir -p %{buildroot}%{_mandir}/man1
install -p -D -m 0644 man/*.1 %{buildroot}%{_mandir}/man1/
mkdir -p %{buildroot}%{_mandir}/man5
install -p -D -m 0644 man/*.5 %{buildroot}%{_mandir}/man5/


%check
# Upstream's test suite doesn't play nicely with Fedora's offline build system
%pyproject_check_import -e 'postfix_mta_sts_resolver.postgres_cache' -e 'postfix_mta_sts_resolver.redis_cache' -e 'postfix_mta_sts_resolver.sqlite_cache'


%pyproject_extras_subpkg -n %{name} sqlite dev redis postgres uvloop


%files  -f %{pyproject_files} 
%license LICENSE
%doc README.md config_examples
%{_mandir}/man*/*
%{_bindir}/mta-sts-query
%{_bindir}/mta-sts-daemon
%config(noreplace) %attr(0640,root,mta-sts) %{_sysconfdir}/mta-sts-daemon.yml
%{_unitdir}/%{name}.service
%dir %attr(0755,mta-sts,mta-sts) %{_sharedstatedir}/mta-sts


%pre
getent group mta-sts >/dev/null || groupadd -r mta-sts
getent passwd mta-sts >/dev/null || \
    useradd -r -g mta-sts -d %{_sharedstatedir}/mta-sts -s /sbin/nologin \
    -c "Postfix MTA-STS Map Daemon" mta-sts


%post
%systemd_post %{name}.service


%preun
%systemd_preun %{name}.service


%postun
%systemd_postun_with_restart %{name}.service


%changelog
## START: Generated by rpmautospec
* Fri Nov 01 2024 Miro Hrončok <miro@hroncok.cz> - 1.4.0-7
- Drop an unused build dependency on tox and tox-current-env

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Fri Jun 07 2024 Python Maint <python-maint@redhat.com> - 1.4.0-5
- Rebuilt for Python 3.13

* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sat Sep 09 2023 Daniel Milnes <daniel@daniel-milnes.uk> - 1.4.0-2
- GPG Verify Downloaded Code

* Sat Sep 09 2023 Daniel Milnes <daniel@daniel-milnes.uk> - 1.4.0-1
- Update to 1.4.0 and pyproject-rpm-macros

* Sat Sep 09 2023 Daniel Milnes <daniel@daniel-milnes.uk> - 1.1.4-6
- Switch to %%autorelease and %%autochangelog

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Wed Oct 26 2022 Marc Dequènes (Duck) <duck@redhat.com> - 1.1.4-3
- Updated postfix-mta-sts-resolver_tests_without_redis.patch

* Wed Oct 26 2022 Marc Dequènes (Duck) <duck@redhat.com> - 1.1.4-2
- Recommends now available uvloop

* Wed Oct 26 2022 Marc Dequènes (Duck) <duck@redhat.com> - 1.1.4-1
- NUR

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Tue Jun 14 2022 Python Maint <python-maint@redhat.com> - 1.0.0-8
- Rebuilt for Python 3.11

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 1.0.0-5
- Rebuilt for Python 3.10

* Mon Mar 08 2021 Marc Dequènes (Duck) <duck@redhat.com> - 1.0.0-4
- Add BuildRequires on make for the doc

* Tue Mar 02 2021 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 1.0.0-3
- Rebuilt for updated systemd-rpm-macros

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Thu Oct 08 2020 Marc Dequènes (Duck) <duck@redhat.com> - 1.0.0-1
- Initial release
## END: Generated by rpmautospec