app-admin/consul: 1.7.3 bump
[gentoo.git] / mail-filter / gld / gld-1.7-r2.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="4"
5
6 inherit toolchain-funcs
7
8 DESCRIPTION="A standalone anti-spam greylisting algorithm on top of Postfix"
9 HOMEPAGE="http://www.gasmi.net/gld.html"
10 SRC_URI="http://www.gasmi.net/down/${P}.tgz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="amd64 ppc x86"
15 IUSE="postgres"
16 # Not adding a mysql USE flag. The package defaults to it, so we will too.
17 DEPEND="sys-libs/zlib
18         >=dev-libs/openssl-0.9.6
19         postgres? ( dev-db/postgresql[server] )
20         !postgres? ( virtual/mysql )"
21 RDEPEND="${DEPEND}"
22
23 src_prepare() {
24         sed -i gld.conf \
25                 -e 's:^LOOPBACKONLY=.*:LOOPBACKONLY=1:' \
26                 -e 's:^#USER=.*:USER=nobody:' \
27                 -e 's:^#GROUP=.*:GROUP=nobody:' \
28                 || die "sed gld.conf failed"
29
30         sed -i Makefile.in \
31                 -e '/ -c /{s|-O2|$(CFLAGS)|g}' \
32                 -e '/ -o /{s|-O2|$(CFLAGS) $(LDFLAGS)|g}' \
33                 -e '/strip/d' \
34                 || die "sed Makefile.in failed"
35
36         sed -i tables.{my,pg}sql \
37                 -e '/ip char/s/16/39/' \
38                 || die "sed sql tables failed"
39 }
40
41 src_configure() {
42         tc-export CC
43         # It's kind of weird. $(use_with postgres pgsql) won't work if you don't
44         # use it...
45         if use postgres ; then
46                 myconf="${myconf} --with-pgsql"
47         fi
48
49         econf ${myconf}
50 }
51
52 src_install() {
53         dobin gld
54
55         insinto /etc
56         newins gld.conf gld.conf.example
57
58         dodoc HISTORY README*
59
60         insinto /usr/share/${PN}/sql
61         doins *.pgsql *-whitelist.sql "${FILESDIR}"/tables.sql
62
63         newinitd "${FILESDIR}"/gld.rc gld
64 }
65
66 pkg_preinst() {
67         elog "Please read the README file in /usr/share/doc/${PF} for"
68         elog "details on how to setup gld."
69         elog
70         elog "The sql files have been installed to /usr/share/${PN}/sql."
71         if [[ $REPLACING_VERSIONS == "1.7-r1" ]]; then
72                 elog "You might want to use the ALTER_TABLE command to change the"
73                 elog "ip field width to 39 chars to accomodate ipv6 addresses."
74                 elog "Please see your sql server documentation."
75         fi
76 }