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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20