File spamassassin.spec of Package spamassassin

#
# spec file for package spamassassin (Version 3.3.1)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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/
#

# norootforbuild

%define sa_version 3.3.1
%define ix_version 1.5.5
%define spd_version 2.20

%define IXHASH iXhash-%{ix_version}
%define SPAMPD spampd-%{spd_version}

Name:           spamassassin
Summary:        Extensible email filter which is used to identify spam
Version:        %{sa_version}
Release:        8
License:        Apache Software License ..
Group:          Productivity/Networking/Email/Utilities
AutoReqProv:    on
Url:            http://spamassassin.org/
Source:         Mail-SpamAssassin-%{sa_version}.tar.bz2
Source1:        Mail-SpamAssassin-rules-%{sa_version}.tar.bz2
Source2:        %{IXHASH}.tgz
Source3:        %{SPAMPD}.tar.gz
Source10:       local.cf
Source11:       init.spamd
Source12:       sysconfig.spamd
Source13:       init.spampd
Source14:       sysconfig.spampd
Source15:       suse.cron-sa-update
Patch0:         patch-utf8
Patch1:         patch-PgSQL
Patch2:         patch-URIDNSBL
Patch3:         patch-SQL_ASCII_SORT
Patch4:         Mail-SpamAssassin-3.3.1-deprecated.patch
Patch5:         Mail-SpamAssassin-3.3.1-MIMEEval.patch
Patch6:         bnc#582111.diff
Patch7:         sa#6392.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{perl_requires}
PreReq:         %insserv_prereq %fillup_prereq
BuildRequires:  dos2unix
BuildRequires:  openssl-devel
#
Requires:       perl-Mail-SpamAssassin = %{sa_version}
Requires:       re2c
Requires:       perl(Net::Server::PreForkSimple)

%description
spamassassin adds a header line that shows if the mail has been
determined spam or not. This way, you can decide what to do with the
mail within the scope of your own filtering rules in your MUA (Mail
User Agent, your mail program) or your LDA (Local Delivery Agent).

See the files in the documentation directory
/usr/share/doc/packages/spamassassin/ for more information on how to
use the filter.



Authors:
--------
    Justin Mason <me@jmason.org>

%package -n perl-Mail-SpamAssassin
Summary:        Perl Modules For Using Spamassassin Within An Own Perl Script
License:        Apache Software License ..
Group:          Development/Libraries/Perl
BuildRequires:  perl
BuildRequires:  perl-macros
BuildRequires:  perl(Digest::SHA1)
BuildRequires:  perl(Errno)
BuildRequires:  perl(File::Spec) >= 0.8
BuildRequires:  perl(File::Copy) >= 2.02
BuildRequires:  perl(HTML::Parser) >= 3.43
BuildRequires:  perl(Archive::Tar) >= 1.23
BuildRequires:  perl(IO::Zlib) >= 1.04
BuildRequires:  perl(Mail::DKIM) >= 0.37
BuildRequires:  perl(Net::DNS) >= 0.34
BuildRequires:  perl(NetAddr::IP) >= 4.000
BuildRequires:  perl(Pod::Usage) >= 1.10
BuildRequires:  perl(Sys::Hostname)
BuildRequires:  perl(Time::HiRes)
BuildRequires:  perl(Time::Local)
# optional, but want them for build (test)
%if 0%{?suse_version} >= 1100
BuildRequires:  perl(Mail::SPF)
%endif
BuildRequires:  perl(IP::Country)
BuildRequires:  perl(Razor2::Client::Agent) >= 2.61
BuildRequires:  perl(Net::Ident)
BuildRequires:  perl(IO::Socket::INET6)
BuildRequires:  perl(IO::Socket::SSL)
BuildRequires:  perl(DBI)
BuildRequires:  perl(Encode::Detect)
#
Requires:       perl-libwww-perl
Requires:       perl(Digest::SHA1)
Requires:       perl(Errno)
Requires:       perl(File::Spec) >= 0.8
Requires:       perl(File::Copy) >= 2.02
Requires:       perl(HTML::Parser) >= 3.43
Requires:       perl(Archive::Tar) >= 1.23
Requires:       perl(IO::Zlib) >= 1.04
Requires:       perl(Mail::DKIM) >= 0.37
Requires:       perl(Net::DNS) >= 0.34
Requires:       perl(NetAddr::IP) >= 4.000
Requires:       perl(Pod::Usage) >= 1.10
Requires:       perl(Sys::Hostname)
Requires:       perl(Time::HiRes)
Requires:       perl(Time::Local)
# optional
%if 0%{?suse_version} >= 1100
Recommends:     perl(Mail::SPF)
%endif
Recommends:     perl(IP::Country)
Recommends:     perl(Razor2::Client::Agent) >= 2.61
Recommends:     perl(Net::Ident)
Recommends:     perl(IO::Socket::INET6)
Recommends:     perl(IO::Socket::SSL)
Recommends:     perl(DBI)
Recommends:     perl(Encode::Detect)
Provides:       perl-spamassassin = %{sa_version}
Obsoletes:      perl-spamassassin < %{sa_version}

%description -n perl-Mail-SpamAssassin
This package contains the perl modules for the spamassassin, including
the filter rules. This package is required for the package
"spamassassin", the commandline tool.

%package -n perl-Mail-SpamAssassin-Plugin-iXhash
Summary:        The iXhash plugin for SpamAssassin
License:        Apache License 2.0
Group:          Development/Libraries/Perl
Version:        %{ix_version}
Release:        8
%{perl_requires}
Requires:       perl-Mail-SpamAssassin = %{sa_version}

%description -n perl-Mail-SpamAssassin-Plugin-iXhash
This archive contains the iXhash plugin for the SpamAssassin spam filtering
software, along with an example config file.

Basically the plugin provides a network-based test just as razor2, pyzor
and DCC do. Working solely on the body of an email, it removes parts of it
and computes a hash value from the rest. These values will then be looked up
via DNS using the domains given in the config file(s). You need Net::DNS and
Digest::MD5 installed

%prep
%setup -q -n Mail-SpamAssassin-%{sa_version} -a 2 -a 3
%patch0 -p0
%patch1 -p0
%patch2 -p0
%patch3 -p0
%if 0%{?suse_version} > 1120
# perl > 5.12 complaines about deprecated stuff
%patch4 -p1
%endif
%patch5 -p1
%patch6 -p0
%patch7 -p0
# fix wrong-file-end-of-line-encoding
dos2unix %{IXHASH}/CHANGELOG

%build
if [ -e t/data/whitelists/winxpnews.com ]; then
    echo "t/data/whitelists/winxpnews.com is not allowed to be distributed."
    echo "see #102221"
    #exit -1 # hidden bug description, so I can't see there - ignored
fi;
if [ -e build/cf_to_html ]; then
    echo "build/cf_to_html is not allowed to be distributed."
    echo "see #102221"
    #exit -1 # hidden bug description, so I can't see there - ignored
fi;

export CFLAGS="$RPM_OPT_FLAGS"
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS" \
 CONTACT_ADDRESS="postmaster" ENABLE_SSL="yes"

%{__make}

%check
%{__make} test

%install
## perl-Mail-SpamAssassin stuff
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
# remove %{_bindir} from filelist
%{__sed} -i -e "/\/usr\/bin/d" %{name}.files
# package only %{_mandir}/man3
%{__sed} -i -e "s,%{_mandir}/man?,%{_mandir}/man3," %{name}.files
#
## perl-Mail-SpamAssassin-Plugin-iXhash stuff
%{__install} -d $RPM_BUILD_ROOT/etc/mail/spamassassin
cp %{IXHASH}/iXhash/iXhash.pm $RPM_BUILD_ROOT%{perl_vendorlib}/Mail/SpamAssassin/Plugin
sed 's/^\(load.*iXhash\) .*$/\1/' %{IXHASH}/iXhash/iXhash.cf >$RPM_BUILD_ROOT/etc/mail/spamassassin/iXhash.cf
#
## spamassassin stuff
%{__install} -d $RPM_BUILD_ROOT/etc/cron.daily/
%{__install} -m 0755 %{S:15} $RPM_BUILD_ROOT/etc/cron.daily/
%{__install} -D -m0755 %{SPAMPD}/spampd $RPM_BUILD_ROOT%{_sbindir}/spampd
mv $RPM_BUILD_ROOT%{_bindir}/spamd $RPM_BUILD_ROOT%{_sbindir}/
%{__install} -m 0644 %{S:10} $RPM_BUILD_ROOT/etc/mail/spamassassin/local.cf
%{__install} -D -m 0644 %{S:11} $RPM_BUILD_ROOT/etc/init.d/spamd
%{__install} -m 0644 %{S:13} $RPM_BUILD_ROOT/etc/init.d/spampd
%{__ln_s} ../../etc/init.d/spamd $RPM_BUILD_ROOT/usr/sbin/rcspamd
%{__ln_s} ../../etc/init.d/spampd $RPM_BUILD_ROOT/usr/sbin/rcspampd
echo "Most of the documentation is at ../perl-Mail-SpamAssassin/." > README.SuSE
%{__install} -D -m 0640 %{S:12} $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.spamd
%{__install} -m 0640 %{S:14} $RPM_BUILD_ROOT/var/adm/fillup-templates/
test -f $RPM_BUILD_ROOT/usr/share/spamassassin/user_prefs.template || {
	echo "MakeMaker is broken again..."
	exit 1
}
%{__install} -d $RPM_BUILD_ROOT/usr/share/spamassassin
pushd $RPM_BUILD_ROOT/usr/share/spamassassin && tar -xjf %{S:1} && popd

%post
%{fillup_and_insserv -n spamd}
%{fillup_and_insserv -n spampd}

%preun
%stop_on_removal spamd

%postun
%restart_on_update spamd
%insserv_cleanup
exit 0

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc spamd/README* spamd/PROTOCOL
%doc %{_mandir}/man1/*
%attr(755,root,root) %{_bindir}/*
%attr(755,root,root) %{_sbindir}/*
%config %attr(744,root,root) /etc/init.d/spamd
%config %attr(744,root,root) /etc/init.d/spampd
/var/adm/fillup-templates/sysconfig.spamd
/var/adm/fillup-templates/sysconfig.spampd

%files -n perl-Mail-SpamAssassin -f %{name}.files
%defattr(-,root,root)
%doc CREDITS Changes INSTALL LICENSE MANIFEST* NOTICE PACKAGING README
%doc TRADEMARK UPGRADE USAGE sample-nonspam.txt sample-spam.txt
%doc ldap sql
%dir /etc/mail
#%dir /etc/cron.daily/
%config(noreplace) /etc/mail/spamassassin
%config(noreplace) /etc/cron.daily/suse.cron-sa-update
%exclude /etc/mail/spamassassin/iXhash.cf
%dir /usr/share/spamassassin
/usr/share/spamassassin/*

%files -n perl-Mail-SpamAssassin-Plugin-iXhash
%defattr(-,root,root)
%doc %{IXHASH}/CHANGELOG %{IXHASH}/LICENSE %{IXHASH}/README 
%doc %{IXHASH}/WHERE_ARE_THE_OTHER_FILES
%doc %{IXHASH}/hashcheck
%doc %{IXHASH}/iXhash.eml
%config(noreplace) /etc/mail/spamassassin/iXhash.cf
%{perl_vendorlib}/Mail/SpamAssassin/Plugin/iXhash.pm

%changelog