File postgrey.spec of Package postgrey

Summary: 	Postfix Greylisting Policy Server
Name:		postgrey
Version: 	1.31
Release:	1
License: 	GPL
Group: 		System/Servers
Source: 	http://isg.ee.ethz.ch/tools/postgrey/pub/%{name}-%{version}.tar.gz
Source1:	%{name}.init
Source2:	%{name}.sysconfig
Source3:	%{name}.README.SuSE
Patch0:		postgrey-user.patch
URL:		http://isg.ee.ethz.ch/tools/postgrey/
Buildarch:	noarch
BuildRoot: 	%{_tmppath}/%{name}-%{version}-%{release}-buildroot/
Requires:	perl-Net-Server, perl-BerkeleyDB, perl-IO-Multiplex
BuildRequires:	perl, coreutils

%define confdir 	/etc/postfix
%define queue_directory %{_var}/spool/postfix

%description
Postgrey is a Postfix policy server implementing greylisting.
When a request for delivery of a mail is received by Postfix 
via SMTP, the triplet CLIENT_IP / SENDER / RECIPIENT is built. 
If it is the first time that this triplet is seen, or if the 
triplet was first seen less than 5 minutes, then the mail gets 
rejected with a temporary error. Hopefully spammers or viruses 
will not try again later, as it is however required per RFC.

%prep
%setup -q -n %{name}-%{version}

%patch0 -p1

pod2man -s 8 -c "" postgrey > postgrey.8
pod2man -s 8 -c "" contrib/postgreyreport > contrib/postgreyreport.8

%install
rm -rf %{buildroot}

mkdir -p %{buildroot}%{_initrddir}
install %{SOURCE1} %{buildroot}%{_initrddir}/%{name}

mkdir -p %{buildroot}%{_sysconfdir}/postfix
cp postgrey_whitelist_clients %{buildroot}%{_sysconfdir}/postfix
cp postgrey_whitelist_recipients %{buildroot}%{_sysconfdir}/postfix
touch %{buildroot}%{_sysconfdir}/postfix/postgrey_whitelist_clients.local

mkdir -p %{buildroot}%{_sbindir}
install postgrey %{buildroot}%{_sbindir}/postgrey
install contrib/postgreyreport %{buildroot}%{_sbindir}/postgreyreport

# Need to SuSEize
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
cp -p %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}

# create rc script link
ln -sf %{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}

# Use this dir for db path since it's the default in postgreyreport
mkdir -p %{buildroot}%{queue_directory}/%{name}

mkdir -p %{buildroot}%{_mandir}/man8
cp postgrey.8 contrib/postgreyreport.8 %{buildroot}%{_mandir}/man8

cp %{SOURCE3} README.SuSE

%clean
rm -rf %{buildroot}

%pre
#%_pre_useradd %{name} %{_localstatedir}/%{name} /bin/false

%post
#%_post_service %{name}

%preun
#%_preun_service %{name}

%postun
#%_postun_userdel %{name}

%files
%defattr(644,root,root,755)
%doc README Changes README.SuSE
%attr(755, root, root) %{_initrddir}/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%config(noreplace) %{confdir}/postgrey_whitelist_clients
%config(noreplace) %{confdir}/postgrey_whitelist_recipients
%config(noreplace) %{confdir}/postgrey_whitelist_clients.local
%attr(755, root, root) %{_sbindir}/postgrey
%attr(755, root, root) %{_sbindir}/postgreyreport
%{_sbindir}/rc%{name}
%{_mandir}/man8/postgrey.8*
%{_mandir}/man8/postgreyreport.8*
%dir %attr(0750, postfix, postfix) %{queue_directory}/%{name}

%changelog
* Thu Feb 28 2008 Jan Zimmerschied jan@z4fun.de
- updated postgrey to version 1.31
- created rcpostgrey link
* Tue Oct 15 2006 Wade Berrier <wberrier@berrier.org> 1.27
- Adapt to suse 10.0
 -add suse initrd (adapted from suse's ddclient package)
 -adjust sysconfig vars
 -patch0 (postgrey-user) is to map to suse type users

* Tue Mar 08 2005 Oden Eriksson <oeriksson@mandrakesoft.com> 1.18-2mdk
- revert to the package by Luca Berra (sorry)

* Tue Mar 08 2005 Oden Eriksson <oeriksson@mandrakesoft.com> 1.18-1mdk
- mistake

* Mon Jan 03 2005 Luca Berra <bluca@vodka.it> 1.17-1mdk
- Initial release based on redhat package from Levente Farkas