Name:		postfwd
Version:	1.35
Release:	6.ndias%{?dist}
Summary:	Postfix firewall daemon

Group:		System Environment/Daemons
License:	BSD
URL:		http://postfwd.org
Source0:	http://postfwd.org/postfwd.tar.gz
Source1:	postfwd
Source2:	postfwd.service
BuildArch:	noarch

BuildRequires:	/usr/bin/perl, systemd
Requires:	perl-Net-Server, perl-Net-DNS, perl-Time-HiRes, perl-Storable

%description
postfwd is written in perl to combine complex postfix restrictions in a ruleset
similar to those of the most firewalls. The program uses the postfix policy
delegation protocol to control access to the mail system before a message has
been accepted (please visit http://www.postfix.org/SMTPD_POLICY_README.html for
more information). It allows you to choose an action (e.g. reject, dunno) for a
combination of several smtp parameters (like sender and recipient address, size
or the client's TLS fingerprint).

%prep
%setup -q


%build


%install
install -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
install -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service

install -d %{buildroot}%{_datadir}/doc/%{name}-%{version}
install -D -p -m 644 doc/* %{buildroot}%{_datadir}/doc/%{name}-%{version}

install -D -p -m 644 etc/postfwd.cf.sample  %{buildroot}%{_sysconfdir}/postfwd/postfwd.cf
install -d %{buildroot}%{_mandir}/man8
install -D -p -m 644 man/man8/* %{buildroot}%{_mandir}/man8

install -D -p -m 644 plugins/postfwd.plugins.sample %{buildroot}%{_sysconfdir}/postfwd/plugins/postfwd.plugins

install -d %{buildroot}%{_sbindir}
install -D sbin/* %{buildroot}%{_sbindir}

install -d %{buildroot}%{_datadir}/postfwd/tools
install -D tools/*.pl %{buildroot}%{_datadir}/postfwd/tools
install -D -p -m 644 tools/request.sample %{buildroot}%{_datadir}/postfwd/tools
install -d %{buildroot}%{_datadir}/postfwd/tools/hapolicy
install -D -p -m 644 tools/hapolicy/*.png %{buildroot}%{_datadir}/postfwd/tools/hapolicy
install -D -p -m 644 tools/hapolicy/hapolicy.* %{buildroot}%{_datadir}/postfwd/tools/hapolicy
install -D -p -m 755 tools/hapolicy/hapolicy %{buildroot}%{_datadir}/postfwd/tools/hapolicy

# remove CRLF from this file
perl -i -pe 's/\r\n/\n/gs' %{buildroot}%{_datadir}/doc/%{name}-%{version}/%{name}2-chroot.txt

%preun

/usr/bin/systemctl disable %{name}

%files
%doc

%{_unitdir}/%{name}.service

%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/plugins

%dir %{_datadir}/%{name}
%dir %{_datadir}/%{name}/tools
%dir %{_datadir}/%{name}/tools/hapolicy
%dir %{_datadir}/doc/%{name}-%{version}

%config(noreplace) %{_sysconfdir}/%{name}/plugins/%{name}.plugins
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.cf
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_datadir}/%{name}/tools/hapolicy/hapolicy*.png
%{_datadir}/%{name}/tools/hapolicy/hapolicy.*
%{_datadir}/%{name}/tools/request.sample
%{_datadir}/%{name}/tools/hapolicy/hapolicy
%{_datadir}/%{name}/tools/*.pl

%{_sbindir}/%{name}
%{_sbindir}/%{name}2

%{_datadir}/doc/%{name}-%{version}/LICENSE
%{_datadir}/doc/%{name}-%{version}/postfwd*
%{_datadir}/doc/%{name}-%{version}/hapolicy*
%{_datadir}/doc/%{name}-%{version}/arch.html
%{_datadir}/doc/%{name}-%{version}/quick.html
%{_datadir}/doc/%{name}-%{version}/versions.html

%{_mandir}/man8/%{name}.8.gz
%{_mandir}/man8/%{name}2.8.gz


%changelog
* Fri Sep 28 2018 Nuno Dias <Nuno.Dias@gmail.com> - 1.35-6.ndias
- Version 1.35