summaryrefslogtreecommitdiff
blob: fb79d9897fc6c51df7d4e4ba72c147e0e8a974f2 (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="7"

inherit toolchain-funcs

DESCRIPTION="A standalone anti-spam greylisting algorithm on top of Postfix"
HOMEPAGE="http://www.gasmi.net/gld.html"
SRC_URI="http://www.gasmi.net/down/${P}.tgz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ppc x86"
IUSE="libressl postgres"
# Not adding a mysql USE flag. The package defaults to it, so we will too.
DEPEND="sys-libs/zlib
	!libressl? ( dev-libs/openssl:0= )
	libressl? ( dev-libs/libressl )
	!postgres? ( dev-db/mysql-connector-c:0= )
	postgres? ( dev-db/postgresql:*[server] )"
RDEPEND="${DEPEND}"

src_prepare() {
	sed -i gld.conf \
		-e 's:^LOOPBACKONLY=.*:LOOPBACKONLY=1:' \
		-e 's:^#USER=.*:USER=nobody:' \
		-e 's:^#GROUP=.*:GROUP=nobody:' \
		|| die "sed gld.conf failed"

	sed -i Makefile.in \
		-e '/ -c /{s|-O2|$(CFLAGS)|g}' \
		-e '/ -o /{s|-O2|$(CFLAGS) $(LDFLAGS)|g}' \
		-e '/strip/d' \
		|| die "sed Makefile.in failed"

	sed -i tables.{my,pg}sql \
		-e '/ip char/s/16/39/' \
		|| die "sed sql tables failed"

	sed -i configure \
		-e "/SQL_LIBS/{s~/lib~/$(get_libdir)~g}" || die

	default
}

src_configure() {
	tc-export CC

	# It's kind of weird. $(use_with postgres pgsql) won't work if you don't
	# use it...
	econf $(usex postgres '--with-pgsql' '')
}

src_install() {
	dobin gld

	insinto /etc
	newins gld.conf gld.conf.example

	dodoc HISTORY README*

	insinto /usr/share/${PN}/sql
	doins *.pgsql *-whitelist.sql "${FILESDIR}"/tables.sql

	newinitd "${FILESDIR}"/gld.rc gld
}

pkg_preinst() {
	elog "Please read the README file in /usr/share/doc/${PF} for"
	elog "details on how to setup gld."
	elog
	elog "The sql files have been installed to /usr/share/${PN}/sql."
	local old_ver
	for old_ver in ${REPLACING_VERSIONS} ; do
		if ver_test ${old_ver} -eq "1.7-r1" ; then
			elog "You might want to use the ALTER_TABLE command to change the"
			elog "ip field width to 39 chars to accomodate ipv6 addresses."
			elog "Please see your sql server documentation."
		fi
	done
}