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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Tue Jul 7 20:41:30 2009 UTC (10 years, 3 months ago) by hollow
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
FILE REMOVED
fix #272913 and remove obsolete ebuild
(Portage version: 2.2_rc33/cvs/Linux i686)

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

  ViewVC Help
Powered by ViewVC 1.1.20