summaryrefslogtreecommitdiff
path: root/mail-filter/bogofilter/bogofilter-1.2.3.ebuild
blob: 13ab78c17fcbf81ca797ea9f755bc9b7a8f3d6c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-filter/bogofilter/bogofilter-1.2.3.ebuild,v 1.8 2012/12/15 17:45:29 armin76 Exp $

EAPI=4
inherit db-use eutils flag-o-matic toolchain-funcs

DESCRIPTION="Bayesian spam filter designed with fast algorithms, and tuned for speed."
HOMEPAGE="http://bogofilter.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2
		mirror://gnu/gsl/gsl-1.15.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 sh sparc x86 ~x86-fbsd"
IUSE="berkdb sqlite tokyocabinet gsl atompkg"

DEPEND="virtual/libiconv
	berkdb?  ( >=sys-libs/db-3.2 )
	!berkdb? (
		sqlite?  ( >=dev-db/sqlite-3.6.22 )
		!sqlite? (
			tokyocabinet? ( dev-db/tokyocabinet )
			!tokyocabinet? ( >=sys-libs/db-3.2 )
		)
	)"
#	sci-libs/gsl"
#	app-arch/pax" # only needed for bf_tar
RDEPEND="${DEPEND}"

pkg_setup() {
	has_version mail-filter/bogofilter || return 0
	if  (   use berkdb && ! has_version 'mail-filter/bogofilter[berkdb]' ) || \
		( ! use berkdb &&   has_version 'mail-filter/bogofilter[berkdb]' ) || \
		(   use sqlite && ! has_version 'mail-filter/bogofilter[sqlite]' ) || \
		( ! use sqlite &&   has_version 'mail-filter/bogofilter[sqlite]' ) || \
		( has_version '>=mail-filter/bogofilter-1.2.1-r1' && \
			(   use tokyocabinet && ! has_version 'mail-filter/bogofilter[tokyocabinet]' ) || \
			( ! use tokyocabinet &&   has_version 'mail-filter/bogofilter[tokyocabinet]' )
		) ; then
		ewarn
		ewarn "If you want to switch the database backend, you must dump the wordlist"
		ewarn "with the current version (old use flags) and load it with the new version!"
		ewarn
	fi
}

src_prepare() {
	dodir /opt/bogofilter/
	dodir /opt/bogofilter/static-libs/
	cd "${WORKDIR}"/gsl-1.15/
	econf --prefix="${WORKDIR}"/gsl-1.15
	emake
	find . -iname "*libgsl.so*" || die
	dodir "${WORKDIR}"/gsl-1.15/static-libs
	mkdir "${WORKDIR}"/gsl-1.15/static-libs || die
	cp "${WORKDIR}"/gsl-1.15/.libs/libgsl.so* "${WORKDIR}"/gsl-1.15/static-libs/ || die
	cp /usr/lib64/libdb-4.8.so "${WORKDIR}"/gsl-1.15/static-libs/ || die
	#insinto /opt/bogofilter/static-libs/
	#cd /opt/bogofilter/static-libs/
	#doins "${WORKDIR}"/gsl-1.15/.libs/libgsl.so*
}

src_configure() {
	set -ex
	local myconf="" berkdb=true
	if use gsl ; then
		myconf="--prefix/opt/bogofilter/ --with-included-gsl"
	else
		myconf="--prefix=/opt/bogofilter --without-included-gsl"
	fi

	if use atompkg ; then
		export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${libdir}:${WORKDIR}/gsl-1.15/static-libs/"
		echo ${libdir}
	fi

	# determine backend: berkdb *is* default
	if use berkdb && use sqlite ; then
		elog "Both useflags berkdb and sqlite are in USE:"
		elog "Using berkdb as database backend."
	elif use berkdb && use tokyocabinet ; then
		elog "Both useflags berkdb and tokyocabinet are in USE:"
		elog "Using berkdb as database backend."
	elif use sqlite && use tokyocabinet ; then
		elog "Both useflags sqlite and tokyocabinet are in USE:"
		elog "Using sqlite as database backend."
		myconf="${myconf} --with-database=sqlite"
		berkdb=false
	elif use sqlite ; then
		myconf="${myconf} --with-database=sqlite"
		berkdb=false
	elif use tokyocabinet ; then
		myconf="${myconf} --with-database=tokyocabinet"
		berkdb=false
	elif ! use berkdb ; then
		elog "Neither berkdb nor sqlite nor tokyocabinet are in USE:"
		elog "Using berkdb as database backend."
	fi

	# Include the right berkdb headers for FreeBSD
	if ${berkdb} ; then
		append-cppflags "-I$(db_includedir)"
	fi

	# bug #324405
	if [[ $(gcc-version) == "3.4" ]] ; then
		epatch "${FILESDIR}"/${PN}-1.2.2-gcc34.patch
	fi

	LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${libdir}:${WORKDIR}/gsl-1.15/static-libs econf ${myconf}
}

src_install() {
	emake DESTDIR="${D}" install
	echo $LD_PRELOAD

	exeinto /usr/share/${PN}/contrib
	doexe contrib/{bogofilter-qfe,parmtest,randomtrain}.sh \
		contrib/{bfproxy,bogominitrain,mime.get.rfc822,printmaildir}.pl \
		contrib/{spamitarium,stripsearch}.pl

	insinto /usr/share/${PN}/contrib
	doins contrib/{README.*,dot-qmail-bogofilter-default} \
		contrib/{bogogrep.c,bogo.R,bogofilter-milter.pl,*.example} \
		contrib/vm-bogofilter.el \
		contrib/{trainbogo,scramble}.sh

	dodoc AUTHORS NEWS README RELEASE.NOTES* TODO GETTING.STARTED \
		doc/integrating-with-* doc/README.{db,sqlite}

	dohtml doc/*.html

	dodir /usr/share/doc/${PF}/samples
	mv "${D}"/etc/bogofilter.cf.example "${D}"/usr/share/doc/${PF}/samples/
	rmdir "${D}"/etc

	echo $LD_PATH
	echo $LD_LIBRARY_PATH
	#die
}

pkg_postinst() {
	echo
	elog "If you need \"${ROOT}usr/bin/bf_tar\" please install app-arch/pax."
	echo
}