Blob Blame History Raw
## $Id$

## This package accepts the following switches:
##   --with spf        ...  enable SPF support

## Fedora Extras specific customization below...
%bcond_without 			fedora
%bcond_with			spf
##

%global username	grmilter
%global vardir		%_var/lib/%name
%global dbdir		%vardir/db
%global rundir		%_var/run/%name
%global __chkconfig	/sbin/chkconfig

%{!?release_func:%global release_func() %1%{?dist}}

Summary:	Milter for greylisting, the next step in the spam control war
Name:		milter-greylist
Version:	3.0
Release:	%release_func 2
License:	BSD w/ advertising
Group:		System Environment/Daemons
URL:		http://hcpnet.free.fr/milter-greylist/
Source0:	ftp://ftp.espci.fr/pub/milter-greylist/%name-%version.tgz
Patch0:		milter-greylist-2.0.2-sysv.patch
BuildRoot:	%_tmppath/%name-%version-%release-root
Requires:		init(%name)
Provides:		user(%username)  = 7
Provides:		group(%username) = 7
BuildRequires:		bison flex m4
BuildRequires:		%_libdir/libbind.so
BuildRequires:		sendmail-devel %{?with_spf:libspf-devel}
BuildRequires:		fedora-usermgmt-devel
%{?FE_USERADD_REQ}

%package sysv
Summary:	Sysv initscripts for %name
Group:		System Environment/Daemons
Provides:	init(%name) = sysv
Requires(preun):	%name = %version-%release
Requires(postun):	%name = %version-%release
Requires(preun):	initscripts
Requires(postun):	initscripts
Requires(post):		%__chkconfig
Requires(preun):	%__chkconfig


%description
Greylisting is a new method of blocking significant amounts of spam at
the mailserver level, but without resorting to heavyweight statistical
analysis or other heuristical (and error-prone) approaches. Consequently,
implementations are fairly lightweight, and may even decrease network
traffic and processor load on your mailserver.

This package provides a greylist filter for sendmail's milter API.


%description sysv
Greylisting is a new method of blocking significant amounts of spam at
the mailserver level, but without resorting to heavyweight statistical
analysis or other heuristical (and error-prone) approaches. Consequently,
implementations are fairly lightweight, and may even decrease network
traffic and processor load on your mailserver.

This package provides the SysV initscripts for the %name package.


%prep
%setup -q
%patch0 -p1 -b .sysv

sed -i -e 's!--rpath!\0X!g' configure
sed -i -e 's!^\#\?user .*!user "%username"!;
           s!^\#socket !socket !;
	   s!^pidfile .*!\#\0!;' greylist.conf

for i in `find -type f`; do
    sed -e 's!/var/milter-greylist/milter-greylist.sock!%rundir/milter-greylist.sock!g;
            s!/var/milter-greylist/greylist.db!%dbdir/greylist.db!g;
	    s!/var/milter-greylist/milter-greylist.pid!%_var/run/milter-greylist.pid!g;
           ' "$i" >"$i.tmp"
    cmp -s "$i" "$i.tmp" || cat "$i.tmp" >"$i"
    rm -f "$i".tmp
done


%define makeflags	TEST=false BINDIR=%_sbindir
%build
%configure \
	--with-user=%username			\
	--enable-dnsrbl				\
	--with-libbind				\
	--disable-drac				\
	--with-drac-db=%vardir/drac/drac.db	\
	%{?with_spf:--with-libspf=/usr}

## is not SMP safe :(
%__make %makeflags


%install
rm -rf $RPM_BUILD_ROOT

%__install -d -m755 $RPM_BUILD_ROOT{%_initrddir,%rundir,%dbdir,%_var/run}
%__make DESTDIR=$RPM_BUILD_ROOT install %makeflags USER="$(id -u)"
%__install -p -m755 rc-redhat.sh $RPM_BUILD_ROOT%_initrddir/%name

# create temporary files
touch $RPM_BUILD_ROOT%rundir/milter-greylist.sock
touch $RPM_BUILD_ROOT%_var/run/milter-greylist.pid

## Remove the unwanted init-methods
%{?_without_sysv:  rm -rf $RPM_BUILD_ROOT%_initrddir}


%pre
%__fe_groupadd 7 -r %username &>/dev/null || :
%__fe_useradd  7 -r -s /sbin/nologin -M -d %vardir \
                 -c 'Greylist-milter user' -g %username %username &>/dev/null || :


%postun
%__fe_userdel  %username &>/dev/null || :
%__fe_groupdel %username &>/dev/null || :



%post sysv
%__chkconfig --add %name

%preun sysv
test "$1" != 0 || %__chkconfig --del %name
test "$1" != 0 || %_initrddir/%name stop >/dev/null || :

%postun sysv
test "$1"  = 0 || %_initrddir/%name condrestart >/dev/null || :


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc ChangeLog README
%_mandir/man*/*
%attr(0640,root,%username) %verify(not mtime) %config(noreplace) %_sysconfdir/mail/greylist.conf
%dir %attr(0751,%username,%username) %vardir
%dir %attr(0770,root,%username) %dbdir
%dir %attr(0700,%username,root) %rundir
%_sbindir/*

%ghost %rundir/milter-greylist.sock
%ghost %_var/run/milter-greylist.pid

%if 0%{!?_without_sysv:1}
%files sysv
  %defattr(-,root,root,-)
  %config %_initrddir/*
%endif

%changelog
* Wed Apr 25 2007 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 3.0-2
- fixed user name in config file (bz #237737)
- commented out pidfile entry; it is to be set by the init methods

* Tue Apr 17 2007 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 3.0-1
- updated to 3.0
- enabled dnsrbl
- removed -initng subpackage

* Tue Jan 30 2007 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.1.12-3
- removed -minit subpackage

* Thu Oct 05 2006 Christian Iseli <Christian.Iseli@licr.org> 2.1.12-3
- rebuilt for unwind info generation, broken in gcc-4.1.1-21

* Mon Sep 18 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.1.12-2
- updated to 2.1.12
- use new fedora-usermgmt stuff

* Sat Apr 15 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.1.4-1
- updated to 2.1.4

* Sat Feb 18 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.0.2-3
- rebuilt for FC5

* Sat Dec 24 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.0.2-2
- use /var/run/milter-greylist as directory for the socket (bz #162334#6)
- do not set user and socket in the sysv-initscript anymore; instead
  of uncomment the configfile entries
- ship minit params file as SOURCE instead of generating it on-the-fly
- added -initng subpackage
- minor specfile cleanups

* Sat Oct 22 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.0.2-1
- updated to 2.0.2

* Sat Jun 25 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.0-2
- updated to final 2.0

* Sat Jun 25 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 2.0-0.1.rc5
- updated to 2.0rc5
- added patch which changes the way how the user will be switched in
  the SysV initscript
- removed all other patches as they are upstream now

* Thu May 19 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 1.6-3
- set %%dist
- use %%global instead of %%define
- do not require 'setuidgid' for -minit anymore

* Fri Apr  7 2005 Michael Schwendt <mschwendt[AT]users.sf.net>
- rebuilt

* Thu Feb  3 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:1.6
- updated to 1.6

* Thu Oct  7 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:1.4-0.fdr.2
- rebuilt
- applied patch to build with libspf-1.0.0

* Tue Jun 15 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:1.4-0.fdr.1
- updated to 1.4

* Fri Jun 11 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:1.3.9-0.fdr.1
- updated to 1.3.9

* Thu Apr 29 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> - 0:1.2.1-1
- Initial build.