summaryrefslogtreecommitdiff
blob: 81bce4d417ba8d864b07188c088f4c4a29832bdd (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-filter/maildrop/maildrop-1.8.0-r3.ebuild,v 1.8 2005/05/30 03:05:08 solar Exp $

inherit eutils gnuconfig

DESCRIPTION="Mail delivery agent/filter"
[ -z "${PV/?.?/}" ] && SRC_URI="mirror://sourceforge/courier/${P}.tar.bz2"
[ -z "${PV/?.?.?/}" ] && SRC_URI="mirror://sourceforge/courier/${P}.tar.bz2"
[ -z "${SRC_URI}" ] && SRC_URI="http://www.courier-mta.org/beta/courier/${P%%_pre}.tar.bz2"
HOMEPAGE="http://www.courier-mta.org/maildrop/"
S="${WORKDIR}/${P%%_pre}"

SLOT="0"
LICENSE="GPL-2"
# not in keywords due to missing dependencies: ~arm ~s390 ~ppc64
KEYWORDS="alpha ~amd64 ia64 ~ppc sparc x86"
IUSE="mysql ldap gdbm berkdb debug postgres"

PROVIDE="virtual/mda"

DEPEND="gdbm? ( >=sys-libs/gdbm-1.8.0 )
	!gdbm? ( berkdb? ( >=sys-libs/db-3 ) )
	mysql? ( net-libs/courier-authlib )
	postgres? ( net-libs/courier-authlib )
	ldap? ( net-libs/courier-authlib )"

RDEPEND="${DEPEND}
	dev-lang/perl"

src_unpack() {
	unpack ${A}
	cd ${S}

	# Do not use lazy bindings on /usr/bin/maildrop
	sed -i -e 's~^maildrop_LDFLAGS =~& -Wl,-z,now~g' maildrop/Makefile.in
	use elibc_uclibc && sed -i -e 's:linux-gnu\*:linux-gnu\*\ \|\ linux-uclibc:' config.sub
	if use gdbm ; then
		use berkdb && einfo "Both gdbm and berkdb selected. Using gdbm."
	else
		if use berkdb ; then
			epatch ${FILESDIR}/maildrop-1.8.0-db4.patch \
				|| die "patch failed."
			export WANT_AUTOCONF="2.5"
			gnuconfig_update
			libtoolize --copy --force
			ebegin "Recreating configure."
				autoconf || die "recreate configure failed."
			eend $?
			cd ${S}/bdbobj
			libtoolize --copy --force
			ebegin "Recreating configure in bdbobj."
				autoconf || die "recreate configure failed."
			eend $?
		else
			einfo "Building without database support"
		fi
	fi
}

src_compile() {
	local myconf

	if use gdbm ; then
		myconf="${myconf} --with-db=gdbm"
	else
		[ use berkdb ] &&  myconf="${myconf} --with-db=db" || \
			myconf="${myconf} --without-db"
	fi

	if ! use mysql && ! use postgres && ! use ldap ; then
		myconf="${myconf} --disable-authlib"
	fi

	econf \
		--with-devel \
		--disable-tempdir \
		--enable-syslog=1 \
		--enable-use-flock=1 \
		--enable-maildirquota \
		--enable-use-dotlock=1 \
		--enable-restrict-trusted=1 \
		--enable-trusted-users='apache dspam root mail daemon postmaster qmaild mmdf vmail' \
		--enable-maildrop-uid=root \
		--enable-maildrop-gid=mail \
		--with-default-maildrop=./.maildir/ \
		--enable-sendmail=/usr/sbin/sendmail \
		--cache-file=${S}/configuring.cache \
		${myconf} || die

	emake || die "compile problem"
}

src_install() {
	make DESTDIR=${D} install || die

	fperms 4755 /usr/bin/maildrop

	dodoc AUTHORS COPYING ChangeLog INSTALL NEWS README \
		README.postfix UPGRADE maildroptips.txt

	dodir /usr/share/doc/${PF}
	mv ${D}/usr/share/maildrop/html ${D}/usr/share/doc/${PF}

	dohtml {INSTALL,README,UPGRADE}.html

	insinto /etc
	doins ${FILESDIR}/maildroprc

	insinto /etc/maildrop
	insopts -m0640
	if use mysql ; then
		sed -e "s:/var/lib/mysql/mysql.sock:/var/run/mysqld/mysqld.sock:" \
		 	${S}/maildropmysql.config > ${S}/maildropmysql.cf
		newins ${S}/maildropmysql.cf maildropmysql.cf
	fi
	use ldap && newins ${S}/maildropldap.config maildropldap.cf
}

pkg_postinst() {
	if use ldap || use mysql ; then
		echo
		ewarn
		ewarn "Due to a security bug (#91465) you should change the permissions of:"
		use ldap && ewarn "   /etc/maildrop/maildropldap.cf"
		use mysql && ewarn "   /etc/maildrop/maildropmysql.cf"
		ewarn "  by running chmod 0640 on them."
		ewarn
		echo
	fi
}