summaryrefslogtreecommitdiff
blob: fe657b3ff0fa81fe4d6a208a18d68794125a3fb7 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-filter/amavisd-new/amavisd-new-2.3.1.ebuild,v 1.8 2005/08/23 13:12:06 ticho Exp $

inherit eutils

DESCRIPTION="High-performance interface between the MTA and content checkers."
HOMEPAGE="http://www.ijs.si/software/amavisd/"
SRC_URI="http://www.ijs.si/software/amavisd/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~ppc ppc64 ~sparc x86"
IUSE="ldap mysql postgres milter"

DEPEND=">=sys-apps/sed-4
	>=dev-lang/perl-5.8.2"

RDEPEND="${DEPEND}
	>=sys-apps/coreutils-5.0-r3
	app-arch/gzip
	app-arch/bzip2
	app-arch/arc
	app-arch/cabextract
	app-arch/freeze
	app-arch/lha
	app-arch/unarj
	app-arch/unrar
	app-arch/zoo
	dev-perl/Archive-Tar
	>=dev-perl/Archive-Zip-1.14
	dev-perl/Compress-Zlib
	dev-perl/Convert-TNEF
	>=dev-perl/Convert-UUlib-1.051
	perl-core/MIME-Base64
	>=dev-perl/MIME-tools-5.415
	>=dev-perl/MailTools-1.58
	dev-perl/net-server
	>=dev-perl/libnet-1.16
	dev-perl/IO-stringy
	>=perl-core/Time-HiRes-1.49
	dev-perl/Unix-Syslog
	>=sys-libs/db-3.1
	dev-perl/BerkeleyDB
	virtual/mta
	virtual/antivirus
	ldap? ( dev-perl/perl-ldap )
	mysql? ( dev-perl/DBD-mysql )
	postgres? ( dev-perl/DBD-Pg )
	milter? ( >=mail-mta/sendmail-8.12 )"

AMAVIS_ROOT=/var/amavis

src_unpack() {
	if ! $(has_version ">=mail-filter/spamassassin-3.0.0") ; then
		echo
		ewarn "WARNING: Amavisd-new will not work with SpamAssassin older than 3.0.0."
		ewarn "         Consider upgrading your SpamAssassin installation."
		ebeep 3
		sleep 5
	fi
	unpack ${A}
	cd ${S}
	if $(has_version mail-mta/courier) ; then
		einfo "Patching with courier support."
		epatch "amavisd-new-courier.patch" || die "patch failed"
	fi

	if $(has_version mail-mta/qmail) || $(has_version mail-mta/qmail-ldap) ; then
		einfo "Patching with qmail qmqp support."
		epatch "amavisd-new-qmqpqq.patch" || die "patch failed"

		einfo "Patching with qmail lf bug workaround."
		epatch "${FILESDIR}/${PN}-2.2.1-qmail-lf-workaround.patch" || die "patch failed"
	fi

	epatch "${FILESDIR}/${PN}-2.3.0-amavisd.conf-gentoo.patch" || die "patch failed"
}

src_compile() {
	if use milter ; then
		cd "${S}/helper-progs"

		econf --with-runtime-dir=${AMAVIS_ROOT} \
			--with-sockname=${AMAVIS_ROOT}/amavisd.sock \
			--with-user=amavis || die "helper-progs econf failed"
		emake || die "helper-progs compile problem"

		cd "${S}"
	fi
}

src_install() {
	dosbin amavisd amavisd-agent amavisd-nanny

	insinto /etc
	insopts -m0640
	newins amavisd.conf-sample amavisd.conf
	fowners root:amavis /etc/amavisd.conf
	dosed "s:^#\\?\\\$MYHOME[^;]*;:\$MYHOME = '$AMAVIS_ROOT';:" \
		/etc/amavisd.conf
	if [ "$(domainname)" = "(none)" ] ; then
		dosed "s:^#\\?\\\$mydomain[^;]*;:\$mydomain = '$(hostname)';:" \
			/etc/amavisd.conf
	else
		dosed "s:^#\\?\\\$mydomain[^;]*;:\$mydomain = '$(domainname)';:" \
			/etc/amavisd.conf
	fi
	if ! $(has_version mail-filter/spamassassin) ; then
		einfo "Disabling anti-spam code in amavisd.conf..."

		dosed "s:^#[\t ]*@bypass_spam_checks_maps[\t ]*=[\t ]*(1);:\@bypass_spam_checks_maps = (1);:" \
			/etc/amavisd.conf
	fi

	newinitd "${FILESDIR}/amavisd.rc6" amavisd
	dosed "s:/var/run/amavis/:$AMAVIS_ROOT/:g" /etc/init.d/amavisd

	keepdir ${AMAVIS_ROOT}
	keepdir ${AMAVIS_ROOT}/db
	keepdir ${AMAVIS_ROOT}/quarantine
	keepdir ${AMAVIS_ROOT}/tmp

	if $(has_version net-nds/openldap ) ; then
		einfo "Adding ${P} schema to openldap schema dir."
		dodir /etc/openldap/schema
		insinto /etc/openldap/schema
		insopts -o root -g root -m 644
		newins LDAP.schema ${PN}.schema || die
		newins LDAP.schema ${PN}.schema.default || die
	fi

	newdoc test-messages/README README.samples
	dodoc AAAREADME.first INSTALL LICENSE MANIFEST RELEASE_NOTES \
		README_FILES/* test-messages/sample-* amavisd.conf-default amavisd-agent

	if use milter ; then
		cd "${S}/helper-progs"
		einstall
	fi
}

pkg_postinst() {
	enewgroup amavis
	enewuser amavis -1 -1 ${AMAVIS_ROOT} amavis

	for i in whitelist blacklist spam_lovers; do
		if [ ! -f ${AMAVIS_ROOT}/${i} ]; then
			touch ${AMAVIS_ROOT}/${i}
		fi
	done

	if $(has_version mail-filter/razor) ; then
		einfo "Setting up initial razor config files..."

		razor-admin -create -home=${ROOT}${AMAVIS_ROOT}/.razor
		sed -i -e "s:debuglevel\([ ]*\)= .:debuglevel\1= 0:g" \
			${ROOT}${AMAVIS_ROOT}/.razor/razor-agent.conf
	fi

	chown -R amavis:amavis ${AMAVIS_ROOT}
	find ${AMAVIS_ROOT} -name "*" -type d -exec chmod 0750 \{\} \;
	find ${AMAVIS_ROOT} -name "*" -type f -exec chmod 0640 \{\} \;

	if ! $(has_version mail-filter/spamassassin) ; then
		echo
		einfo "Amavisd-new no longer requires SpamAssassin, but no anti-spam checking"
		einfo "will be performed without it. Since you do not have SpamAssassin installed,"
		einfo "all spam checks have been disabled. To enable them, install SpamAssassin"
		einfo "and comment out the line containing: "
		einfo "@bypass_spam_checks_maps = (1); in /etc/amavisd.conf."
	fi
	echo
	ewarn "Adjusting permissions for /etc/amavisd.conf (0 for world, owner root:amavis)"
	echo
	chmod o-rwx /etc/amavisd.conf
	chown root:amavis /etc/amavisd.conf
}