forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dspam-3.10.2-r1.ebuild
222 lines (185 loc) · 5.84 KB
/
dspam-3.10.2-r1.ebuild
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=4
inherit eutils user
DESCRIPTION="A statistical-algorithmic hybrid anti-spam filter"
HOMEPAGE="http://dspam.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
LICENSE="AGPL-3"
SLOT="0"
KEYWORDS="amd64 ~arm ~ppc x86"
DRIVERS_IUSE="+hash mysql postgres sqlite"
SCALES_IUSE="small-scale +domain-scale large-scale"
IUSE="clamav daemon debug ldap static-libs syslog virtual-users user-homedirs ${DRIVERS_IUSE} ${SCALES_IUSE}"
DEPEND="
net-mail/mailbase
ldap? ( net-nds/openldap )
mysql? ( >=virtual/mysql-5.0 )
postgres? ( dev-db/postgresql )
sqlite? ( dev-db/sqlite:3 )
"
RDEPEND="
${DEPEND}
clamav? ( app-antivirus/clamav )
syslog? ( virtual/logger )
"
# Demands on sane USE flags:
# - find out what driver to use: select at least one
# - if static-libs is set, only one driver may be selected
# - find out what scale to use: select exactly one
# - user-homedirs does not work with virtual-users
REQUIRED_USE="
|| ( ${DRIVERS_IUSE//+} )
static-libs? ( ^^ ( ${DRIVERS_IUSE//+} ) )
^^ ( ${SCALES_IUSE//+} )
virtual-users? ( !user-homedirs )
"
# dspam setup defaults
DSPAM_HOME=/var/spool/dspam
DSPAM_CONF=/etc/dspam
DSPAM_LOG=/var/log/dspam
DSPAM_MODE=2510
DSPAM_DRIVERS=
DSPAM_DRIVERS_EXTRAS=
pkg_setup() {
# setup storage, this sets DSPAM_DRIVERS
dspam_setup_storage_drivers
# create dspam user and group
dspam_setup_user
}
src_configure() {
econf \
--sysconfdir=${DSPAM_CONF} \
--with-dspam-home=${DSPAM_HOME} \
--with-dspam-home-group=dspam \
--with-dspam-mode=${DSPAM_MODE} \
--with-dspam-group=dspam \
--with-logdir=${DSPAM_LOG} \
--enable-external-lookup \
--enable-long-usernames \
--enable-split-configuration \
$(use_enable clamav) \
$(use_enable daemon) \
$(use_enable debug) \
$(use_enable debug bnr-debug) \
$(use_enable debug verbose-debug) \
$(use_enable domain-scale) \
$(use_enable large-scale) \
$(use_enable static-libs static) \
$(use_enable syslog) \
$(use_enable user-homedirs homedir) \
$(use_enable virtual-users) \
--with-storage-driver=${DSPAM_DRIVERS} ${DSPAM_DRIVERS_EXTRAS} \
$(use mysql || use postgres && echo "--enable-preferences-extension") \
$(use syslog || echo "--with-logfile=${DSPAM_LOG}/dspam.log")
}
dspam_setup_user() {
# DSPAM CGI web gui (www-apps/dspam-web) needs to run as a regular user
# under suexec in apache, so DSPAM user/group need to be regular users too
local euid egid
for euid in {1000..5000} ; do
[ -z "$(egetent passwd ${euid})" ] && break
done
for egid in {1000..5000} ; do
[ -z "$(egetent group ${egid})" ] && break
done
enewgroup dspam ${egid}
enewuser dspam ${euid} -1 "${DSPAM_HOMEDIR}" dspam,mail
}
dspam_setup_storage_drivers() {
# Find out which storage drivers need to be enabled, and set some
# variables so that src_configure can pick them up
if use hash; then
DSPAM_DRIVERS+=",hash_drv"
fi
if use mysql; then
DSPAM_DRIVERS+=",mysql_drv"
DSPAM_DRIVERS_EXTRAS+="--with-mysql-includes=/usr/include/mysql "
fi
if use postgres; then
DSPAM_DRIVERS+=",pgsql_drv"
fi
if use sqlite; then
DSPAM_DRIVERS+=",sqlite3_drv"
fi
if ! use static-libs; then
# set the driver name twice to avoid a static build
DSPAM_DRIVERS+=${DSPAM_DRIVERS}
fi
# remove first comma separator
DSPAM_DRIVERS=${DSPAM_DRIVERS:1}
einfo "Building with drivers: ${DSPAM_DRIVERS}"
#echo DSPAM_DRIVERS_EXTRAS=$DSPAM_DRIVERS_EXTRAS
}
src_install() {
default
if use daemon; then
newinitd "${FILESDIR}/dspam.initd" dspam
newconfd "${FILESDIR}/dspam.confd" dspam
fi
if use mysql; then
insinto "/usr/share/${PN}/mysql"
local files="mysql_objects-4.1.sql mysql_objects-space.sql mysql_objects-speed.sql purge-4.1.sql purge.sql"
if use virtual-users; then
files+=" virtual_user_aliases.sql virtual_users.sql"
fi
for file in $files; do
doins src/tools.mysql_drv/${file}
done
fi
if use postgres; then
insinto "/usr/share/${PN}/pgsql"
local files="pgsql_objects.sql purge-pe.sql purge.sql"
if use virtual-users; then
files+=" virtual_users.sql"
fi
for file in $files; do
doins src/tools.pgsql_drv/${file}
done
fi
if use sqlite; then
insinto "/usr/share/${PN}/sqlite"
newins src/tools.sqlite_drv/purge-3.sql purge.sql
fi
insinto "${DSPAM_HOME}/txt"
doins txt/*.txt
for i in spam nonspam; do
echo "Scanned and tagged with DSPAM ${PV} on Gentoo Linux as ${i} by ISP" > "${T}/msgtag.${i}"
doins "${T}/msgtag.${i}"
done
newbin contrib/dspam_maintenance/dspam_maintenance.sh dspam_maintenance
exeinto /etc/cron.daily
newexe "${FILESDIR}/dspam.cron-r4" dspam
insinto /etc/logrotate.d
newins "${FILESDIR}/dspam.logrotate" dspam
dodoc CHANGELOG README* RELEASE.NOTES UPGRADING doc/*.txt
# stop logrotate-3.8 from complaining
dodir /var/log/dspam
fowners dspam:dspam /var/log/dspam
fperms 0750 /var/log/dspam
# Install dspamc setgid
fowners root:dspam /usr/bin/dspamc &&
fperms g+s /usr/bin/dspamc ||
die "failed to alter dspamc owner:group or mode"
}
pkg_preinst() {
# dspam-3.10.0: config dir change, should be removed at some later point
if [ -d "${ROOT}/etc/mail/dspam" ]; then
ewarn "The configuration directory of DSPAM has been relocated from /etc/mail/dspam to ${DSPAM_CONF}."
if [ -h "${ROOT}${DSPAM_CONF}" ]; then
# symlink, this is the setup in older ebuilds
ewarn "Moving contents of /etc/mail/dspam to ${DSPAM_CONF} ..."
rm "${ROOT}${DSPAM_CONF}" && mv "${ROOT}/etc/mail/dspam" "${DSPAM_CONF}"
eend $?
elif [ -d "${ROOT}${DSPAM_CONF}" ]; then
# directory and no symlink, do it manually since we cannot decide.
ewarn "You have both /etc/mail/dspam and ${DSPAM_CONF} directories, please delete the former."
else
# nothing interesting in /etc/dspam
ewarn "Moving contents of /etc/mail/dspam to ${DSPAM_CONF} ..."
mv "${ROOT}/etc/mail/dspam" "${DSPAM_CONF}"
eend $?
fi
fi
}