
%define pdir    Mail
%define pnam    SpamAssassin

%define version 3.3.1
%define real_version 3.3.1
%define release 1%{_dist_release}
%define cfdate 20110406
%define name spamassassin
%define _initrddir /etc/rc.d/init.d/
%define initdir %{_initrddir}
#%define __find_provides /usr/lib/rpm/find-provides.perl
#%define __find_requires /usr/lib/rpm/find-requires.perl

Summary: a spam filter for email which can be invoked from mail delivery agents
Summary(ja): MDA から起動できる spam email filter
Group: Applications/Internet
Name: %{name}
Version: %{version}
Release: %{release}
License: Apache License 2.0
URL: http://spamassassin.org/
Source0: http://spamassassin.org/released/Mail-SpamAssassin-%{real_version}.tar.bz2
Source1: sample-japanese-local.cf-%{cfdate}
Source2: README.vine
Source3: filter.sh
Source4: sa-update.cronscript
Source5: sa-update.crontab
Source6: sa-update.logrotate
Patch0: spamassassin-3.1.7_rules.patch
Patch1: spamassassin-3.3.1-fix-deprecated.patch
Patch2: spamassassin-3.3.1-fix-deprecated2.patch
Buildroot: %{_tmppath}/%{name}-%{version}-root
Requires(pre): /sbin/chkconfig
Requires(pre): perl-Mail-SpamAssassin = %{version}-%{release}
Requires(pre): spamassassin-tools = %{version}-%{release}
Requires: perl >= 1:5.10.0
Requires: perl(Pod::Usage), perl(HTML::Parser) >= 3.43 perl(Digest::SHA1)
Requires: perl(Net::DNS)
# sa-update's Requires
Requires: perl(Archive::Tar) >= 1.23 perl(IO::Zlib) >= 1.04 perl(LWP) 

BuildRequires: perl >= 1:5.10.0 perl(HTML::Parser) >= 3.43 perl(Digest::SHA1)
BuildRequires: perl(Archive::Tar) >= 1.23 perl(IO::Zlib) >= 1.04
BuildRequires: perl(Net::DNS)
BuildRequires: perl(NetAddr::IP)

Vendor: Project Vine
Distribution: Vine Linux

%description
SpamAssassin provides you with a way to reduce if not completely eliminate
Unsolicited Commercial Email (spam) from your incoming email.  It can
be invoked by a MDA such as sendmail or postfix, or can be called from
a procmail script, .forward file, etc.  It uses a genetic-algorithm
evolved scoring system to identify messages which look spammy, then
adds headers to the message so they can be filtered by the user's mail
reading software.  This distribution includes the spamd/spamc components
which create a server that considerably speeds processing of mail.

%description -l ja
SpamAssassin は商用電子メール(スパム)を除去する手段を提供する filter です。

sendmail または postfix のような MDA から SpamAssassin を起動することが
可能です。
また procmail スクリプト、.forward ファイルなどからも呼ぶことができます。

SpamAssassin は、スパムメッセージを識別するために遺伝的アルゴリズムを
発展させた、得点システムを使用しています。
ユーザのメールソフト (MUA) がそれらをフィルタリングすることができるように、
メッセージにヘッダーを加えます。
また、メイルの処理速度を要求されるサーバーで用いる spamd/spamc コンポー
ネントを含んでいます。

日本語のスパムメール用の local.cf を含めています。
/usr/doc/spamassassin-*/sample-japanese-local.conf を見てください。

%package tools
Summary: Miscellaneous tools for SpamAssassin
Summary(ja): SpamAssassin 向けの各種ツール
Group: Applications/Internet
Requires(pre): perl-Mail-SpamAssassin = %{version}-%{release}
Requires: perl >= 1:5.6.1
Autoreq: no

%description tools
Miscellaneous tools from various authors, distributed with SpamAssassin.
See /usr/share/doc/SpamAssassin-tools-*/.

%package -n perl-Mail-SpamAssassin
Summary: %{pdir}::%{pnam} -- SpamAssassin e-mail filter Perl modules
Requires: perl >= 1:5.6.1 perl(Pod::Usage) perl(HTML::Parser) >= 3.43
Group: Development/Libraries

%description -n perl-Mail-SpamAssassin
Mail::SpamAssassin is a module to identify spam using text analysis and
several internet-based realtime blacklists. Using its rule base, it uses a
wide range of heuristic tests on mail headers and body text to identify
``spam'', also known as unsolicited commercial email. Once identified, the
mail can then be optionally tagged as spam for later filtering using the
user's own mail user-agent application.

%prep -q
%setup -q -n %{pdir}-%{pnam}-%{real_version}
# %setup -D -a 1 -T -n %{pdir}-%{pnam}-%{real_version}

%patch0 -p0 -b .rules

%patch1 -p0 -b .fix-deprecated
%patch2 -p0 -b .fix-deprecated2

# Japanese sample file / README
cp -p %{SOURCE1} sample-japanese-local.cf
cp -p %{SOURCE2} README.vine
cp -p %{SOURCE3} filter.sh
# sa-update sample
cp -p %{SOURCE4} .
cp -p %{SOURCE5} .
cp -p %{SOURCE6} .
# change README filename
cp spamd/README spamd/README.spamd

%build
CFLAGS="$RPM_OPT_FLAGS"; export CFLAGS
%{__perl} Makefile.PL INSTALLDIRS=vendor < /dev/null
%{__make} 
%{__make} spamd/libspamc.so

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install

install -d $RPM_BUILD_ROOT/%{initdir}
install -m 0755 spamd/redhat-rc-script.sh $RPM_BUILD_ROOT/%{initdir}/spamassassin
mkdir -p $RPM_BUILD_ROOT/etc/mail/spamassassin
mkdir -p $RPM_BUILD_ROOT/var/spool/spamassassin

# [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

%post
# install
# if [ $1 = 1 ]; then
#         /sbin/chkconfig --add spamassassin
# fi

if [ -x /usr/bin/sa-update ] ; then
echo "Update rules"
/usr/bin/sa-update ||:
fi

# update
if [ $1 = 2 ]; then
    if [ -x /usr/bin/sa-learn ] ; then
	echo "Sync DB (sa-learn --sync)"
	/usr/bin/sa-learn --sync
    fi
    if [ -f /var/lock/subsys/spamassassin ]; then
	echo "restarting spamd"
        %{initdir}/spamassassin restart
    else
	echo 'If you use spamd,'
	echo '  "/etc/rc.d/init.d/spamassassin start"'
	echo 'to start the spamd daemon.'
    fi
fi

%post -n perl-Mail-SpamAssassin
if [ -x /usr/bin/sa-update ] ; then
echo "Update rules"
/usr/bin/sa-update ||:
fi

%pre -n perl-Mail-SpamAssassin
# update
if [ $1 = 2 ]; then
    if [ -x /usr/bin/sa-learn ] ; then
	echo "Sync DB (sa-learn --sync)"
	/usr/bin/sa-learn --sync ||:
    fi
fi

%preun
# remove
if [ $1 = 0 ]; then
        if [ -f /var/lock/subsys/spamassassin ]; then
                %{initdir}/spamassassin stop 1>&2
        fi
        /sbin/chkconfig --del spamassassin
fi

%files 
%defattr(-,root,root)
%doc CREDITS Changes INSTALL INSTALL.VMS LICENSE MANIFEST MANIFEST.SKIP
%doc NOTICE PACKAGING README README.vine TRADEMARK UPGRADE USAGE
%doc sql
%doc filter.sh
%doc sample-nonspam.txt sample-spam.txt 
%doc spamd/README.spamd 
%doc sample-japanese-local.cf
%doc sa-update.*
%attr(755,root,root) %{_bindir}/*
%config %attr(755,root,root) %{initdir}/spamassassin
%{_mandir}/man1/*

%files -n spamassassin-tools
%defattr(644,root,root,755)
%doc sql

%files -n perl-Mail-SpamAssassin
%defattr(644,root,root,755)
%{perl_vendorlib}/Mail/*
%{perl_vendorlib}/spamassassin-run.pod

%config(noreplace) %{_sysconfdir}/mail/spamassassin
%{_datadir}/spamassassin
%{_mandir}/man3/*
%attr(775,root,root) /var/spool/spamassassin

%changelog
* Fri Apr 08 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.3.1-1
- new upstream release.
- replaced "Prereq:" and "BuildPrereq".
- updated sample-japanese-local.cf.
- added Patch1 and Patch2 for perl-5.12.x.

* Mon Jun 22 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.5-1
- new upstream release.
- wrote spec in UTF-8.
- updated sample-japanese-local.cf.

* Thu May  1 2008 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net>
- 3.2.4-1
- rebuilt with perl-5.10.0.

* Sun Feb 24 2008 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.2.4-0vl1
- new upstream release (built for VineSeed)
- update Requires/BuildRequires tag perl(HTML::Parser) >= 3.43
- enable Requires for sa-update
- remove "(noreplace)" from init script
- remove Vine 3.x if-endif section
- remove script for upgrading from sa 2.x
- turn on daemon restart message 
- update sample-japanese-local.cf

* Wed Jan 02 2008 Shu KONNO <owa@bg.wakwak.com> 3.2.3-0vl1
- new upstream release

* Thu Feb 20 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.8-0vl2
- rebuilt for VinePlus 4.x
- installed perl modules to vendor_perl dir 

* Sun Feb 18 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.8-0vl1
- built for VinePlus 3.x
- installed perl modules to site_perl dir 
- add restart spamd process automactically (update)

  - * Thu Dec 07 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
  - 3.1.7-0vl1.1
  - fix file list
  - sample-japanese-local.cf update
  - README.vine update

* Sun Feb 18 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.8-0vl0.1
- test package (not released)
- built for VinePlus 4.0
- new upstream release with security fix (CVE-2007-0451)
- add Source4,5,6 for sa-update sample file

* Tue Nov 07 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.7-0vl3
- fix file list 
- sample-japanese-local.cf update
- README.vine update
- fix changelog missing

* Mon Oct 16 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.7-0vl2
- built for VinePlus 4.0
- This package is based on VinePlus 3.x package
- installed perl modules to vendor_perl dir

  - * Tue Jul 11 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.64-0vl3
  - rebuilt with perl 5.8.6
  - changed Group to Applications/Internet
  - installed perl modules to vendor_perl dir

* Sat Oct 14 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.7-0vl1
- new upstream release
- add %pre -n perl-Mail-SpamAssassin script for updating package
- add README.vine filter.sh
- change License to Apache License 2.0

* Sat Oct 07 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 3.1.5-0vl1
- new upstream release
- built for VinePlus 3.2

* Sat Nov 27 2004 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.64-0vl2
- rebuild for VinePlus 3.0

* Sat Nov 27 2004 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.64-0vl1
- rebuild for VinePlus 2.5/2.6
- Source version up
- Sample-japanese-local.cf update

* Sun Apr 10 2004 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.63-0vl4
- rebuild for VineSeed Plus
- Sample-japanese-local.cf update

* Mon Apr 05 2004 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.63-0vl3
- Source version up
- Sample-japanese-local.cf update

* Sun Apr 04 2004 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.63-0vl2
- Source version up
- Sample-japanese-local.cf update

* Sat Dec 23 2003 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.61-0vl1
- Source version up
- Sample-japanese-local.cf update
- Change make & install method for 2.61
- fix Require
- add post/preun script for update from 2.5x
- add Vendor/Distribution tag

* Sat May 24 2003 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.55-0vl2
- Sample-japanese-local.cf update

* Sat May 24 2003 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.55-0vl1
- Source version up

* Fri Apr 25 2003 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.53-0vl1
- Source version up
- Sample-japanese-local.cf update

* Fri Mar 28 2003 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.52-0vl1
- Source version up

* Thu Feb 06 2003 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.44-0vl1
- Source version up
- Sample-japanese-local.cf update
- Fix japanese discription

* Wed Oct 23 2002 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.43-0vl2
- Update & fix sample-japanese-local.cf 

* Fri Oct 18 2002 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.43-0vl1
- Source version up
- Change make & install method for 2.43
- Update sample-japanese-local.cf 
    - Thanx to MATSUDA Yoh-ichi <matsuda@palnet.or.jp> san
- Change Buildprereq, Requires (perl 5.6.0 -> 5.6.1) for Vine 2.5
- Add doc qmail
- Fix cvs version tags (Patch0)

* Thu Oct 10 2002 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.42-3vl3
- stop install sample-japanese-local.cf to /etc/mail/spamassassin
- add japanese discription
- Fix Buildrequires

* Tue Oct 08 2002 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.42-3vl2
- Fix Requires, Buildrequires
- add local.cf for Japanese (from Linux-Users ML spam filter)

* Mon Oct 07 2002 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp>
- 2.42-3vl1
- first build for Vine Linux
- NO run post/preun script
- add requires perl(Time::HiRes)
- add define _initrcdir

* Sat Oct 05 2002 Theo Van Dinter <felicity@kluge.net> -3
- fixed some small typos in the spec file

* Fri Oct 04 2002 Theo Van Dinter <felicity@kluge.net> -2
- small bug where 2.42 still called itself 2.42-cvs

* Fri Oct 04 2002 Theo Van Dinter <felicity@kluge.net> -1
- updated to SA 2.42

* Wed Sep 11 2002 Justin Mason <jm-spec@jmason.org>
- spamassassin RPM now requires perl-Mail-SpamAssassin; from Theo

* Tue Sep 03 2002 Theo Van Dinter <felicity@kluge.net>
- added INSTALL to documentation files
- install man pages via _manpage macro to make things consistent
- added perl requires statement
- cleaned out some cruft
- fixed "file listed twice" bug

* Wed Aug 28 2002 Justin Mason <jm-spec@jmason.org>
- merged code from PLD rpm, split into spamassassin, perl-Mail-SpamAssassin,
  and spamassassin-tools rpms

* Mon Jul 29 2002 Justin Mason <jm-spec@jmason.org>
- removed migrate_cfs code, obsolete

* Thu Jul 25 2002 Justin Mason <jm-spec@jmason.org>
- removed findbin patch, obsolete

* Fri Apr 19 2002 Theo Van Dinter <felicity@kluge.net>
- Updated for 2.20 release
- made /etc/mail/spamassassin a config directory so local.cf doesn't get wiped out
- added a patch to remove findbin stuff

* Wed Feb 27 2002 Craig Hughes <craig@hughes-family.org>
- Updated for 2.1 release

* Sat Feb 02 2002 Theo Van Dinter <felicity@kluge.net>
- Updates for 2.01 release
- Fixed rc file
- RPM now buildable as non-root
- fixed post_service errors
- fixed provides to include perl modules
- use file find instead of manually specifying files

* Tue Jan 15 2002 Craig Hughes <craig@hughes-family.org>
- Updated for 2.0 release

* Wed Dec 05 2001 Craig Hughes <craig@hughes-family.org>
- Updated for final 1.5 distribution.

* Sun Nov 18 2001 Craig Hughes <craig@hughes-family.org>
- first version of rpm.

