/[gentoo-x86]/mail-mta/qmail-ldap/qmail-ldap-1.03-r5.ebuild
Gentoo

Contents of /mail-mta/qmail-ldap/qmail-ldap-1.03-r5.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Mon Jun 18 08:33:32 2007 UTC (12 years, 4 months ago) by hollow
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
change noHomeDirectory to homeDirectory in controls patch; cleanup
(Portage version: 2.1.2.9)

1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail-ldap/qmail-ldap-1.03-r5.ebuild,v 1.1 2007/06/16 13:48:10 hollow Exp $
4
5 inherit eutils toolchain-funcs fixheadtails flag-o-matic
6
7 QMAIL_LDAP_PATCH=20060201
8 QMAIL_SPP_PATCH=0.42
9
10 DESCRIPTION="qmail -- a secure, reliable, efficient, simple message transfer agent"
11 HOMEPAGE="
12 http://www.qmail-ldap.org
13 http://cr.yp.to/qmail.html
14 http://qmail.org/
15 "
16 SRC_URI="
17 mirror://qmail/qmail-${PV}.tar.gz
18 http://www.nrg4u.com/qmail/${P}-${QMAIL_LDAP_PATCH}.patch.gz
19 !vanilla? (
20 qmail-spp? ( mirror://gentoo/${P}-spp-${QMAIL_SPP_PATCH}.patch )
21 )
22 "
23
24 LICENSE="as-is"
25 SLOT="0"
26 KEYWORDS="~amd64 ~ppc ~sparc ~x86"
27 IUSE="cluster gencertdaily highvolume mailwrapper qmail-spp ssl vanilla zlib"
28 RESTRICT="test"
29
30 DEPEND="
31 !mail-mta/qmail
32 sys-apps/groff
33 net-mail/queue-repair
34 ssl? ( dev-libs/openssl )
35 net-nds/openldap
36 "
37 RDEPEND="
38 mailwrapper? ( net-mail/mailwrapper )
39 !mailwrapper? ( !virtual/mta )
40 sys-apps/ucspi-tcp
41 sys-process/daemontools
42 net-mail/dot-forward
43 ${DEPEND}
44 "
45 PROVIDE="
46 virtual/mta
47 virtual/mda
48 "
49
50 # Important: QMAIL_CONF_SPLIT should always be a prime number!
51 MY_CONF_SPLIT="${QMAIL_CONF_SPLIT:-23}"
52
53 MY_S="${WORKDIR}"/qmail-${PV}
54 TCPRULES_DIR=/etc/tcprules.d
55
56 if use gencertdaily; then
57 CRON_FOLDER=cron.daily
58 else
59 CRON_FOLDER=cron.hourly
60 fi
61
62
63 src_unpack() {
64 unpack qmail-${PV}.tar.gz
65
66 cd "${MY_S}"
67
68 # main ldap patch
69 # includes: netqmail-1.05, EXTTODO, BIGTODO, TLS/SMTPAUTH, 0.0.0.0 fix
70 epatch ${DISTDIR}/${P}-${QMAIL_LDAP_PATCH}.patch.gz || die "ldap patch failed"
71
72 local LDAPFLAGS="-DALTQUEUE -DEXTERNAL_TODO -DDASH_EXT"
73
74 if ! use vanilla; then
75 use cluster && LDAPFLAGS="${LDAPFLAGS} -DQLDAP_CLUSTER"
76 use highvolume && LDAPFLAGS="${LDAPFLAGS} -DBIGTODO"
77 use zlib && LDAPFLAGS="${LDAPFLAGS} -DDATA_COMPRESS -D QMQP_COMPRESS"
78
79 if use qmail-spp; then
80 epatch ${DISTDIR}/${P}-spp-${QMAIL_SPP_PATCH}.patch
81 fi
82
83 # a lot of sed magic to get Makefile right
84 sed -i \
85 -e "s:^#LDAPFLAGS=.*:LDAPFLAGS=${LDAPFLAGS}:" \
86 -e 's:^LDAPLIBS=.*:LDAPLIBS=-L/usr/lib -lldap -llber:' \
87 -e 's:^LDAPINCLUDES=.*:LDAPINCLUDES=-I/usr/include:' \
88 Makefile || die "could not enable OpenLDAP"
89
90 sed -i -e 's:^#SHADOWLIBS=.*:SHADOWLIBS=-lcrypt:' \
91 Makefile || die "could not enable shadow passwords"
92
93 sed -i \
94 -e 's:^#\(MDIRMAKE=.*\):\1:' \
95 -e 's:^#\(HDIRMAKE=.*\):\1:' \
96 Makefile || die "could not enabled automaildirmake"
97
98 if use zlib; then
99 sed -i -e 's:^#ZLIB=.*:ZLIB=-lz:' \
100 Makefile || die "could not enable zlib"
101 fi
102
103 if use ssl; then
104 sed -i \
105 -e 's:^#\(TLS=.*\):\1:g' \
106 -e 's:^#TLSINCLUDES=.*:TLSINCLUDES=/usr/include:' \
107 -e 's:^#TLSLIBS=.*:TLSLIBS=-L/usr/lib -lssl -lcrypto:' \
108 -e 's:^#OPENSSLBIN=.*:OPENSSLBIN=/usr/bin/openssl:' \
109 Makefile || die "could not enable TLS"
110 fi
111 fi
112
113 if [[ -n "${QMAIL_PATCH_DIR}" && -d "${QMAIL_PATCH_DIR}" ]]
114 then
115 echo
116 ewarn "You enabled custom patches from ${QMAIL_PATCH_DIR}."
117 ewarn "Be warned that you won't get any support when using "
118 ewarn "this feature. You're on your own from now!"
119 ebeep
120 epatch "${QMAIL_PATCH_DIR}/"*
121 echo
122 fi
123
124 is_prime ${MY_CONF_SPLIT} || die 'QMAIL_CONF_SPLIT is not a prime number.'
125 einfo "Using conf-split value of ${MY_CONF_SPLIT}."
126
127 ht_fix_file Makefile*
128 append-ldflags $(bindnow-flags)
129
130 # The following commands patch the conf-{cc,ld} files to use the user's
131 # specified CFLAGS and LDFLAGS. These rather complex commands are needed
132 # because a user supplied patch might apply changes to these files, too.
133 # Fixes Bug #165981.
134 echo "$(head -n 1 "${MY_S}/conf-cc" | sed -e "s#^g\?cc\s\+\(-O2\)\?#$(tc-getCC) #")" \
135 "${CFLAGS}" > "${MY_S}/conf-cc.tmp" &&
136 mv "${MY_S}/conf-cc.tmp" "${MY_S}/conf-cc" || die 'Patching conf-cc failed.'
137
138 echo "$(head -n 1 "${MY_S}/conf-ld" | sed -e "s#^g\?cc\s\+\(-s\)\?#$(tc-getCC) #")" \
139 "${LDLAGS}" > "${MY_S}/conf-ld.tmp" &&
140 mv "${MY_S}/conf-ld.tmp" "${MY_S}/conf-ld" || die 'Patching conf-ld failed.'
141
142 echo -n "${MY_CONF_SPLIT}" > "${MY_S}/conf-split"
143 }
144
145 src_compile() {
146 cd "${MY_S}"
147 emake it man ldap || die "make failed"
148 }
149
150 src_install() {
151 cd "${MY_S}"
152
153 einfo "Setting up directory hierarchy ..."
154
155 diropts -m 755 -o root -g qmail
156 dodir /var/qmail/{,bin,boot,control}
157
158 keepdir /var/qmail/users
159
160 diropts -m 755 -o alias -g qmail
161 dodir /var/qmail/alias
162
163 einfo "Installing the qmail software ..."
164
165 insopts -o root -g qmail -m 755
166 insinto /var/qmail/boot
167 doins home home+df proc proc+df binm1 binm1+df binm2 \
168 binm2+df binm3 binm3+df
169
170 insinto /var/qmail/bin
171
172 insopts -o qmailq -g qmail -m 4711
173 doins qmail-queue
174
175 insopts -o root -g qmail -m 700
176 doins qmail-{lspawn,start,newu,newmrh}
177
178 insopts -o root -g qmail -m 711
179 doins qmail-{getpw,local,remote,rspawn,clean,send,pw2u} splogger
180
181 insopts -o root -g qmail -m 755
182 doins bouncesaying condredirect config-fast datemail elq \
183 except forward maildir2mbox maildirmake maildirwatch \
184 mailsubj pinq predate preline qail qbiff \
185 qmail-{inject,pop3d,popup,qmqpc,qmqpd,qmtpd,qread} \
186 qmail-{qstat,showctl,smtpd,tcpok,tcpto} \
187 qreceipt qsmhook sendmail tcp-env
188 doins auth_{imap,pop,smtp} condwrite digest dirmaker \
189 pbs{add,check,dbd} qmail-{cdb,forward,group} \
190 qmail-{ldaplookup,quotawarn,reply,secretary,todo,verify}
191
192 einfo "Installing manpages"
193 into /usr
194 doman *.[1-8]
195
196 dodoc BLURB* CHANGES FAQ INSTALL* PIC* README* REMOVE* SECURITY \
197 SENDMAIL SYSDEPS TARGETS TEST* THANKS* THOUGHTS TODO* \
198 UPGRADE VERSION* \
199 QLDAP* ${FILESDIR}/samples.ldif
200
201 # use the correct maildirmake
202 # the courier-imap one has some extensions that are nicer
203 [[ -e /usr/bin/maildirmake ]] && \
204 MAILDIRMAKE="/usr/bin/maildirmake" || \
205 MAILDIRMAKE="${D}/var/qmail/bin/maildirmake"
206
207 einfo "Adding env.d entry for qmail"
208 insopts -m 644
209 doenvd ${FILESDIR}/99qmail
210
211 einfo "Creating sendmail replacement ..."
212 diropts -m 755
213 dodir /usr/sbin /usr/lib
214
215 if use mailwrapper
216 then
217 insinto /etc/mail
218 doins ${FILESDIR}/mailer.conf
219 else
220 dosym /var/qmail/bin/sendmail /usr/sbin/sendmail
221 dosym /var/qmail/bin/sendmail /usr/lib/sendmail
222 fi
223
224 einfo "Setting up the default aliases ..."
225 diropts -m 700 -o alias -g qmail
226 ${MAILDIRMAKE} ${D}/var/qmail/alias/.maildir
227 keepdir /var/qmail/alias/.maildir/{cur,new,tmp}
228
229 for i in /var/qmail/alias/.qmail-{mailer-daemon,postmaster,root}
230 do
231 if [[ ! -f ${i} ]]; then
232 touch ${D}${i}
233 fowners alias:qmail ${i}
234 fi
235 done
236
237 einfo "Setting up maildirs by default in the account skeleton ..."
238 diropts -m 755 -o root -g root
239 insinto /etc/skel
240 newins ${FILESDIR}/dot-qmail .qmail.sample
241 fperms 644 /etc/skel/.qmail.sample
242 ${MAILDIRMAKE} ${D}/etc/skel/.maildir
243 keepdir /etc/skel/.maildir/{cur,new,tmp}
244
245 einfo "Setting up all services (send, smtp, qmtp, qmqp, pop3) ..."
246 insopts -o root -g root -m 755
247 diropts -m 755 -o root -g root
248 dodir /var/qmail/supervise
249
250 for i in send smtpd qmtpd qmqpd pop3d; do
251 insopts -o root -g root -m 755
252 diropts -m 755 -o root -g root
253 dodir /var/qmail/supervise/qmail-${i}{,/log}
254 fperms +t /var/qmail/supervise/qmail-${i}{,/log}
255 insinto /var/qmail/supervise/qmail-${i}
256 newins ${FILESDIR}/run-qmail-${i} run
257 insinto /var/qmail/supervise/qmail-${i}/log
258 newins ${FILESDIR}/run-qmail-${i}-log run
259 diropts -m 755 -o qmaill
260 keepdir /var/log/qmail/qmail-${i}
261 done
262
263 dodir ${TCPRULES_DIR}
264 insinto ${TCPRULES_DIR}
265 newins ${FILESDIR}/tcprules.d-Makefile.qmail Makefile.qmail
266 for i in smtp qmtp qmqp pop3; do
267 newins ${FILESDIR}/tcp.${i}.sample tcp.qmail-${i}
268 done
269
270 einfo "Installing OpenLDAP schema ..."
271 insinto /etc/openldap/schema
272 doins qmail.schema
273
274 einfo "Installing some stock configuration files"
275 insinto /var/qmail/control
276 insopts -o root -g root -m 644
277 doins ${FILESDIR}/conf-{common,send,qmtpd,qmqpd,pop3d}
278 newins ${FILESDIR}/conf-smtpd conf-smtpd
279 newins ${FILESDIR}/dot-qmail defaultdelivery
280 use ssl && \
281 doins ${FILESDIR}/servercert.cnf
282
283 einfo "Configuration sanity checker and launcher"
284 into /var/qmail
285 insopts -o root -g root -m 644
286 dobin ${FILESDIR}/qmail-config-system
287
288 if use qmail-spp; then
289 einfo "Installing files for qmail-spp"
290 insinto /var/qmail/control/
291 doins ${FILESDIR}/smtpplugins
292 keepdir /var/qmail/plugins/
293 fi
294
295 if use ssl; then
296 einfo "SSL Certificate creation script"
297 dobin ${FILESDIR}/mkservercert
298 einfo "RSA key generation cronjob"
299 insinto /etc/${CRON_FOLDER}
300 doins ${FILESDIR}/qmail-genrsacert.sh
301 chmod +x ${D}/etc/${CRON_FOLDER}/qmail-genrsacert.sh
302
303 # for some files
304 keepdir /var/qmail/control/tlshosts/
305 fi
306 }
307
308 rootmailfixup() {
309 # so you can check mail as root easily
310 local TMPCMD="ln -sf /var/qmail/alias/.maildir/ ${ROOT}/root/.maildir"
311 if [[ -d "${ROOT}/root/.maildir" && ! -L "${ROOT}/root/.maildir" ]] ; then
312 elog "Previously the qmail ebuilds created /root/.maildir/ but not"
313 elog "every mail was delivered there. If the directory does not"
314 elog "contain any mail, please delete it and run:"
315 elog "${TMPCMD}"
316 else
317 ${TMPCMD}
318 fi
319 chown -R alias:qmail ${ROOT}/var/qmail/alias/.maildir 2>/dev/null
320 }
321
322 buildtcprules() {
323 for i in smtp qmtp qmqp pop3; do
324 # please note that we don't check if it exists
325 # as we want it to make the cdb files anyway!
326 f=tcp.qmail-${i}
327 src=${ROOT}${TCPRULES_DIR}/${f}
328 cdb=${ROOT}${TCPRULES_DIR}/${f}.cdb
329 tmp=${ROOT}${TCPRULES_DIR}/.${f}.tmp
330 [[ -e ${src} ]] && tcprules ${cdb} ${tmp} < ${src}
331 done
332 }
333
334 pkg_postinst() {
335 einfo "Setting up the message queue hierarchy ..."
336 /usr/bin/queue-repair.py \
337 --create --split "${MY_CONF_SPLIT}" \
338 $(use highvolume && echo '--bigtodo' || echo '--no-bigtodo') \
339 ${ROOT}/var/qmail >/dev/null || \
340 die 'queue-repair failed'
341
342 rootmailfixup
343 buildtcprules
344
345 # for good measure
346 env-update
347
348 elog "To setup qmail to run out-of-the-box on your system, run:"
349 elog "emerge --config =${CATEGORY}/${PF}"
350 elog
351 elog "To start qmail at boot you have to add svscan to your startup"
352 elog "and create the following links:"
353 elog "ln -s /var/qmail/supervise/qmail-send /service/qmail-send"
354 elog "ln -s /var/qmail/supervise/qmail-smtpd /service/qmail-smtpd"
355 elog
356 elog "To start the pop3 server as well, create the following link:"
357 elog "ln -s /var/qmail/supervise/qmail-pop3d /service/qmail-pop3d"
358 elog
359 elog "Additionally, the QMTP and QMQP protocols are supported, "
360 elog "and can be started as:"
361 elog "ln -s /var/qmail/supervise/qmail-qmtpd /service/qmail-qmtpd"
362 elog "ln -s /var/qmail/supervise/qmail-qmqpd /service/qmail-qmqpd"
363 elog
364 elog "Additionally, if you wish to run qmail right now, you should "
365 elog "run this before anything else:"
366 elog "source /etc/profile"
367 elog
368 elog "If you are looking for documentation, check those links:"
369 elog "http://www.lifewithqmail.com/ldap/"
370 elog " -- Life with qmail-ldap"
371 elog
372 elog "For sample ldifs, please check"
373 elog "/usr/share/doc/${PF}/samples.ldif.gz"
374 }
375
376 pkg_preinst() {
377 mkdir -p ${TCPRULES_DIR}
378 for proto in smtp qmtp qmqp pop3; do
379 for ext in '' .cdb; do
380 old="/etc/tcp.${proto}${ext}"
381 new="${TCPRULES_DIR}/tcp.qmail-${proto}${ext}"
382 fail=0
383 if [[ -f "$old" && ! -f "$new" ]]; then
384 einfo "Moving $old to $new"
385 cp $old $new || fail=1
386 else
387 fail=1
388 fi
389 if [[ "${fail}" = 1 && -f ${old} ]]; then
390 eerror "Error moving $old to $new, be sure to check the"
391 eerror "configuration! You may have already moved the files,"
392 eerror "in which case you can delete $old"
393 fi
394 done
395 done
396 }
397
398 # Candidate for eclass
399 pkg_setup() {
400 # keep in sync with mini-qmail pkg
401 einfo "Creating groups and users"
402 enewgroup qmail 201
403 enewuser alias 200 -1 /var/qmail/alias 200
404 enewuser qmaild 201 -1 /var/qmail 200
405 enewuser qmaill 202 -1 /var/qmail 200
406 enewuser qmailp 203 -1 /var/qmail 200
407 enewuser qmailq 204 -1 /var/qmail 201
408 enewuser qmailr 205 -1 /var/qmail 201
409 enewuser qmails 206 -1 /var/qmail 201
410 }
411
412 pkg_config() {
413 # avoid some weird locale problems
414 export LC_ALL=C
415
416 if [[ ${ROOT} = / ]] ; then
417 if [[ ! -f ${ROOT}var/qmail/control/me ]] ; then
418 export qhost=$(hostname --fqdn)
419 ${ROOT}var/qmail/bin/config-fast $qhost
420 fi
421 else
422 ewarn "Skipping some configuration as it MUST be run on the final host"
423 fi
424
425 einfo "Accepting relaying by default from all ips configured on this machine."
426 LOCALIPS=$(/sbin/ifconfig | grep inet | cut -d' ' -f 12 -s | cut -b 6-20)
427 TCPSTRING=":allow,RELAYCLIENT=\"\",RBLSMTPD=\"\""
428 for ip in $LOCALIPS; do
429 myline="${ip}${TCPSTRING}"
430 for proto in smtp qmtp qmqp; do
431 f="${ROOT}${TCPRULES_DIR}/tcp.qmail-${proto}"
432 egrep -q "${myline}" ${f} || echo "${myline}" >>${f}
433 done
434 done
435
436 buildtcprules
437
438 if use ssl; then
439 ebegin "Generating RSA keys for SSL/TLS, this can take some time"
440 ${ROOT}/etc/${CRON_FOLDER}/qmail-genrsacert.sh
441 eend $?
442 einfo "Creating a self-signed ssl-certificate:"
443 ${ROOT}/var/qmail/bin/mkservercert
444 einfo "If you want to have a properly signed certificate "
445 einfo "instead, do the following:"
446 # space at the end of the string because of the current implementation
447 # of einfo
448 einfo "openssl req -new -nodes -out req.pem \\ "
449 einfo " -config /var/qmail/control/servercert.cnf \\ "
450 einfo " -keyout /var/qmail/control/servercert.pem"
451 einfo "Send req.pem to your CA to obtain signed_req.pem, and do:"
452 einfo "cat signed_req.pem >> /var/qmail/control/servercert.pem"
453 fi
454 }
455
456 # --- TODO: The following code can be moved to prime.eclass --
457 # Original Author: Michael Hanselmann <hansmi@gentoo.org>
458 # Purpose: Functions for prime numbers
459
460 # Prints a list of primes between min and max inclusive
461 #
462 # Note: this functions gets very slow when used with large numbers.
463 #
464 # Syntax: primes <min> <max>
465 primes() {
466 local min=${1} max=${2}
467 local result= primelist=2 i p
468
469 [[ ${min} -le 2 ]] && result="${result} 2"
470
471 for ((i = 3; i <= max; i += 2))
472 do
473 for p in ${primelist}
474 do
475 [[ $[i % p] == 0 || $[p * p] -gt ${i} ]] && \
476 break
477 done
478 if [[ $[i % p] != 0 ]]
479 then
480 primelist="${primelist} ${i}"
481 [[ ${i} -ge ${min} ]] && \
482 result="${result} ${i}"
483 fi
484 done
485
486 echo ${result}
487 }
488
489 # Checks wether a number is a prime number
490 #
491 # Syntax: is_prime <number>
492 is_prime() {
493 local number=${1} i
494 for i in $(primes ${number} ${number})
495 do
496 [[ ${i} == ${number} ]] && return 0
497 done
498 return 1
499 }
500 # --- end of prime.eclass ---

  ViewVC Help
Powered by ViewVC 1.1.20