2 # Need to version-upgrade RH builds due to different directory locations.
5 %define courier_release %(release="`rpm -q --queryformat='.%{VERSION}' redhat-release 2>/dev/null`" ; echo "$release")
7 Summary: Courier 0.26.20000822 mail server
10 Release: 1%{courier_release}
12 Group: Applications/Mail
13 Source: courier-0.26.20000822.tar.gz
15 BuildRoot: /var/tmp/courier-install
18 Requires: /sbin/chkconfig
21 # RH custom locations.
24 # manpages /usr/man /usr/share/man
25 # httpd /home/httpd /var/www
26 # initscripts /etc/rc.d/init.d /etc/init.d
28 %{expand:%%define manpagedir %(if test -d %{_prefix}/share/man ; then echo %{_prefix}/share/man ; else echo %{_prefix}/man ; fi)}
30 %define apachedir %(if test -d /var/www ; then echo /var/www ; else echo /home/httpd ; fi)
32 %define _prefix /usr/lib/courier
33 %define _localstatedir /var/spool/courier
34 %define _sysconfdir /etc/courier
35 %define _mandir %{manpagedir}
37 %define initdir %(if test -d /etc/init.d/. ; then echo /etc/init.d ; else echo /etc/rc.d/init.d ; fi)
39 # Change the following if your DocumentRoot and cgibindir differ. This is
40 # the default redhat build:
42 %define _cgibindir %{apachedir}/cgi-bin
43 %define _documentrootdir %{apachedir}/html
44 %define _imageurl /webmail/
46 %package sendmail-wrapper
47 Summary: Courier 0.26.20000822 soft links for sendmail
48 Group: Applications/Mail
51 Summary: Courier 0.26.20000822 Integrated POP3 server
52 Group: Applications/Mail
53 Requires: courier = 0.26.20000822
56 Summary: Courier 0.26.20000822 Integrated IMAP server
57 Group: Applications/Mail
58 Requires: courier = 0.26.20000822
59 Obsoletes: courier-imap
62 Summary: Courier 0.26.20000822 Integrated HTTP (webmail) server
63 Group: Applications/Mail
64 Requires: courier = 0.26.20000822 %{_cgibindir} %{_documentrootdir}
67 Summary: Courier 0.26.20000822 Integrated Mailing List Manager
68 Group: Applications/Mail
69 Requires: courier = 0.26.20000822
72 Summary: Courier 0.26.20000822 Integrated mail filter
73 Group: Applications/Mail
74 Requires: courier = 0.26.20000822
76 %package maildrop-wrapper
77 Summary: Courier 0.26.20000822 soft links for maildrop
78 Group: Applications/Mail
79 Requires: courier-maildrop = 0.26.20000822
82 Summary: Courier 0.26.20000822 mail server authenticated ESMTP module
83 Group: Applications/Mail
84 Requires: courier = 0.26.20000822
88 Courier is a fully functional mail server, that can completely take
89 over the mail services normally provided by sendmail, Qmail, or any
90 other mail server. Although Courier does not support all legacy
91 features of existing mail servers, the number of obsoleted functions
92 is very small, and there are better, and more robust, alternatives
95 Courier implements many SMTP extensions: DSN, PIPELINING, 8BITMIME.
96 Courier also implements several new SMTP extensions for mailing list
97 management and spam filtering.
99 %description sendmail-wrapper
100 This package contains two soft links from /usr/sbin/sendmail and
101 /usr/lib/sendmail to %{_bindir}/sendmail. This allows application
102 that use sendmail to transparently use Courier for sending mail.
105 This package installs Courier mail server's integrated POP3 server,
106 which allows you to download mail from your mailbox using any POP3
107 client. Courier's POP3 server can only be used to download mail
108 from maildir mailboxes. This server does not support mailbox files.
109 If you do not need the ability to download your mail using a POP3
110 client, you do not need to install this package.
113 This package installs Courier mail server's integrated IMAP server.
114 If you do not need the ability to download your mail using an IMAP
115 mail client, you do not need to install this package. Courier's
116 IMAP server can only be used to download mail from maildir
117 mailboxes. This server does not support mailbox files.
119 This package requires that Courier must be already installed, this
120 is NOT the standalone version of the Courier-IMAP server, and you
121 cannot install both this package, and the standalone version of
122 Courier-IMAP. If you have the standalone version of the
123 Courier-IMAP server already installed, installing this package
124 will automatically remove the standalone version.
127 This package installs Courier mail server's integrated HTTP webmail
128 server. If you do not need the ability to access your mail using a
129 web browser, you do not need to install this package. Courier's
130 webmail server can only be used to download mail from maildir
131 mailboxes. This server does not support mailbox files.
133 This is the same server that's distributed separately under the
134 name of SqWebMail, however its configuration is customized for the
137 %description maildrop
138 This package installs Courier mail server's integrated mail filter.
139 You need to install this package if you want to be able to filter
143 This package installs couriermlm - a mailing list manager for the
144 Courier mail server. If you do not need the ability to manage
145 mailing lists, you do not need to install this package.
147 couriermlm is used to set up, maintain, and run a mailing list.
148 couriermlm automatically processes subscription and unsubscription
149 requests, and removes undeliverable addresses from the subscription
150 rolls. Mailing lists managed by couriermlm require zero human
151 administrative oversight. couriermlm supports digests, write-only
152 posting aliases, and moderated mailing lists.
154 %description maildrop-wrapper
155 This package installs several soft links from the /usr/local/bin
156 directory to Courier's integrated maildrop mail filter. Maildrop is
157 available as a standalone package, which installs in /usr/local/bin.
158 If you have applications that expect to find maildrop in /usr/local/bin
159 you can install this package to create soft links that point to
160 Courier's integrated maildrop version instead, in order to continue
161 to use those applications, without needing to reconfigure them.
163 %description smtpauth
164 Authenticated ESMTP allows remote users to authenticate themselves
165 and be able to relay outbound mail through the Courier mail server.
171 --localstatedir=%{_localstatedir} \
172 --sysconfdir=%{_sysconfdir} \
173 --mandir=%{_mandir} \
174 --enable-imageurl=%{_imageurl}
176 cat >README.REDHAT <<EOF
178 This installation of Courier is configured as follows:
180 Installation directory: %{_prefix}
181 Binary installation directory: %{_exec_prefix}
183 Superuser binaries: %{_sbindir}
184 Program executables: %{_libexecdir}
185 Configuration files: %{_sysconfdir}
186 Scripts, other non-binaries: %{_datadir}
187 Mail queue, temporary files: %{_localstatedir}
188 Manual pages: %{_mandir}
198 test "$RPM_BUILD_ROOT" != "" && rm -rf $RPM_BUILD_ROOT
199 mkdir -p $RPM_BUILD_ROOT%{_prefix}
200 mkdir -p $RPM_BUILD_ROOT/etc/pam.d
202 if test "%{_package_maintainer}" = "1"
204 make install DESTDIR=$RPM_BUILD_ROOT
206 make install-strip DESTDIR=$RPM_BUILD_ROOT
209 ln -s %{_sysconfdir}/pop3d.authpam $RPM_BUILD_ROOT/etc/pam.d/pop3
210 ln -s %{_sysconfdir}/esmtp.authpam $RPM_BUILD_ROOT/etc/pam.d/esmtp
211 ln -s %{_sysconfdir}/imapd.authpam $RPM_BUILD_ROOT/etc/pam.d/imap
212 ln -s %{_sysconfdir}/webmail.authpam $RPM_BUILD_ROOT/etc/pam.d/webmail
217 # We're going to create some more config files later, so let's just make
218 # sure they're processed as all other Courier config files
221 echo '/etc/pam.d/esmtp 644 root root' >>permissions.dat
222 echo '/etc/profile.d/courier.sh 755 bin bin config' >>permissions.dat
223 echo '/etc/profile.d/courier.csh 755 bin bin config' >>permissions.dat
224 echo '%{initdir}/courier 755 bin bin config' >>permissions.dat
227 # Translate permissions.dat to spec file filelist.
231 $buildroot=$ENV{"RPM_BUILD_ROOT"};
232 $prefix="%{_prefix}";
233 $exec_prefix="%{_exec_prefix}";
238 ($file,$mode,$uid,$gid,$special)=split(/ +/);
239 $file=$prefix if $file eq "$prefix/.";
241 next if $special eq "doc";
242 next if $file eq "$prefix/doc";
244 # Ignore dir/. entries
246 next if $file =~ /\/\.$/;
248 # Ignore man directories
250 next if $file eq "%{_mandir}";
251 next if substr($file, 0, length("%{_mandir}")) eq "%{_mandir}"
252 && substr($file, length("%{_mandir}")) =~ /^\/man[1-9]$/;
254 $mode = "-" if $special eq "%doc";
255 $special="%config" if $special eq "config";
256 $special="%dir" if ! -l "$buildroot/$file" && -d "$buildroot/$file";
257 if ($special eq "man")
259 if ( -l "$buildroot/$file" )
261 print STDERR "ln -s " . readlink("$buildroot$file")
262 . ".gz $buildroot/$file.gz\n";
263 symlink readlink("$buildroot$file")
264 . ".gz", "$buildroot/$file.gz";
268 print STDERR "gzip <$buildroot$file >$buildroot$file.gz\n";
269 system("gzip <$buildroot$file >$buildroot$file.gz ; rm -f $buildroot$file");
273 $special="" unless $special =~ /%/;
275 $special="%attr($mode, $uid, $gid) $special";
276 print "$special $file\n";
279 ' <permissions.dat >filelist1 || exit 1
281 sed -n '/imap[\.a-z0-9]*$/p;/imapd-ssl/p' <filelist1 >filelist.imap
282 sed -n '/pop3[\.a-z0-9]*$/p' <filelist1 >filelist.pop3
283 sed -n '/couriermlm/p' <filelist1 >filelist.mlm
284 sed -n '/authstart$/p;/authend$/p' <filelist1 >filelist.auth
285 sed -n '/maildrop[^/]*$/p;/reformail[^/]*$/p;/reformime[^/]*$/p' <filelist1 >filelist.maildrop
286 sed '/imap[\.a-z0-9]*$/d;/imapd-ssl/d;/pop3[\.a-z0-9]*$/d;/couriermlm/d;/webmail/d;/ldapaddressbook$/d;/maildrop[^/]*$/d;/reformail[^/]*$/d;/reformime[^/]*$/d;/authstart$/d;/authend$/d' <filelist1 >filelist
288 sed -n '/sqwebmail/p;/webmail.authpam/p;/webmail-logincache/p;/ldapaddressbook$/p' <filelist1 | sed '/images/d' >filelist.webmail
290 # Note that we delete all 'webmail's, but copy over only 'sqwebmail's.
291 # This removes all webmail-related stuff from the main filelist,
292 # and adds everything except the executable, webmail, to filelist.webmail.
295 mkdir -p $RPM_BUILD_ROOT%{_cgibindir}
296 cp $RPM_BUILD_ROOT%{_libexecdir}/courier/webmail/webmail \
297 $RPM_BUILD_ROOT%{_cgibindir}/webmail
299 # And here's why we delete all images from filelist.webmail:
301 mkdir -p $RPM_BUILD_ROOT%{_documentrootdir}
302 mv $RPM_BUILD_ROOT%{_datadir}/sqwebmail/images $RPM_BUILD_ROOT%{_documentrootdir}/webmail
304 # Do we need to install a cron job to clean out webmail's cache?
306 if test -f webmail/cron.cmd
308 mkdir -p $RPM_BUILD_ROOT/etc/cron.hourly
309 cp webmail/cron.cmd $RPM_BUILD_ROOT/etc/cron.hourly/courier-webmail-cleancache
310 echo "%attr(555, root, wheel) /etc/cron.hourly/courier-webmail-cleancache" >>filelist.webmail
314 # Move .html documentation back to build dir, so that RPM will move it to
315 # the appropriate docdir
320 cp $RPM_BUILD_ROOT%{_datadir}/htmldoc/* htmldoc
323 # Manually set POP3DSTART and IMAPDSTART to yes, they'll go into a separate
324 # package, so after it's installed they should be runnable.
326 sed 's/^POP3DSTART.*/POP3DSTART=YES/' <$RPM_BUILD_ROOT%{_sysconfdir}/pop3d >$RPM_BUILD_ROOT%{_sysconfdir}/pop3d.new
327 mv $RPM_BUILD_ROOT%{_sysconfdir}/pop3d.new $RPM_BUILD_ROOT%{_sysconfdir}/pop3d
329 sed 's/^IMAPDSTART.*/IMAPDSTART=YES/' <$RPM_BUILD_ROOT%{_sysconfdir}/imapd >$RPM_BUILD_ROOT%{_sysconfdir}/imapd.new
330 mv $RPM_BUILD_ROOT%{_sysconfdir}/imapd.new $RPM_BUILD_ROOT%{_sysconfdir}/imapd
332 sed 's/^IMAPDSSLSTART.*/IMAPDSSLSTART=YES/' <$RPM_BUILD_ROOT%{_sysconfdir}/imapd-ssl >$RPM_BUILD_ROOT%{_sysconfdir}/imapd.new-ssl
333 mv $RPM_BUILD_ROOT%{_sysconfdir}/imapd.new-ssl $RPM_BUILD_ROOT%{_sysconfdir}/imapd-ssl
336 # Red Hat init.d file
339 mkdir -p $RPM_BUILD_ROOT%{initdir}
341 cp courier.sysvinit $RPM_BUILD_ROOT%{initdir}/courier
344 # Red Hat /etc/profile.d scripts
347 mkdir -p $RPM_BUILD_ROOT/etc/profile.d
348 cat >$RPM_BUILD_ROOT/etc/profile.d/courier.sh <<EOF
349 if echo "\$PATH" | tr ':' '\012' | fgrep -qx %{_bindir}
355 PATH="%{_sbindir}:\$PATH"
357 PATH="%{_bindir}:\$PATH"
362 cat >$RPM_BUILD_ROOT/etc/profile.d/courier.csh <<EOF
364 echo "\$PATH" | tr ':' '\012' | fgrep -qx %{_bindir}
372 setenv PATH "%{_sbindir}:\$PATH"
374 setenv PATH "%{_bindir}:\$PATH"
379 # sendmail soft links
382 mkdir -p $RPM_BUILD_ROOT/usr/sbin
383 mkdir -p $RPM_BUILD_ROOT/usr/lib
384 mkdir -p $RPM_BUILD_ROOT/usr/bin
386 ln -s %{_bindir}/sendmail $RPM_BUILD_ROOT/usr/sbin/sendmail
387 ln -s %{_bindir}/sendmail $RPM_BUILD_ROOT/usr/lib/sendmail
388 ln -s %{_bindir}/sendmail $RPM_BUILD_ROOT/usr/bin/sendmail
391 # maildrop wrapper soft links
394 mkdir -p $RPM_BUILD_ROOT/usr/local/bin
396 for f in dotlock maildirmake maildrop makedat reformail reformime deliverquota
398 ln -s %{_bindir}/$f $RPM_BUILD_ROOT/usr/local/bin/$f
401 for f in makeuserdb pw2userdb userdb userdbpw vchkpw2userdb
403 ln -s %{_sbindir}/$f $RPM_BUILD_ROOT/usr/local/bin/$f
407 # The following directories are not created by default, but I want them here.
410 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/userdb
411 mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/tmp/broken
413 . courier/uidgid || exit 1
418 echo "%attr(700, $mailuser, $mailgroup) %dir %{_sysconfdir}/userdb" >>filelist
419 echo "%attr(755, $mailuser, $mailgroup) %dir %{_localstatedir}/tmp/broken" >>filelist
422 /sbin/chkconfig --del courier
423 /sbin/chkconfig --add courier
424 %{_sbindir}/makealiases 2>/dev/null || true
425 %{_sbindir}/makesmtpaccess 2>/dev/null || true
427 # If we do not have a certificate, make one up.
429 if test ! -f %{_datadir}/esmtpd.pem
431 %{_sbindir}/mkesmtpdcert
435 %{initdir}/courier stop
438 /sbin/chkconfig --del courier
442 # If we do not have a certificate, make one up.
444 if test ! -f %{_datadir}/imapd.pem
446 %{_sbindir}/mkimapdcert
449 %{_sbindir}/imapd stop
450 %{_sbindir}/imapd-ssl stop
453 %{_sbindir}/pop3d stop
456 %{_sbindir}/esmtpd stop
457 %{_sbindir}/esmtpd start
460 %{_sbindir}/esmtpd stop
461 %{_sbindir}/esmtpd start
465 %attr(555, bin, bin) %doc README.REDHAT AUTHORS COPYING
466 %attr(555, bin, bin) %doc htmldoc/*
468 %files sendmail-wrapper
469 %attr(-, bin, bin) /usr/sbin/sendmail
470 %attr(-, bin, bin) /usr/bin/sendmail
471 %attr(-, bin, bin) /usr/lib/sendmail
473 %files maildrop-wrapper
475 %attr(-, bin, bin) /usr/local/bin/*
477 %files pop3d -f filelist.pop3
478 %attr(644, root, wheel) /etc/pam.d/pop3
480 %files imapd -f filelist.imap
481 %attr(644, root, wheel) /etc/pam.d/imap
483 %files webmail -f filelist.webmail
484 %attr(4511, root, wheel) %{_cgibindir}/webmail
485 %attr(644, root, wheel) /etc/pam.d/webmail
486 %attr(755, bin, bin) %dir %{_documentrootdir}/webmail
487 %attr(444, bin, bin) %{_documentrootdir}/webmail/*
489 %files maildrop -f filelist.maildrop
491 %files mlm -f filelist.mlm
493 %files smtpauth -f filelist.auth
496 rm -rf $RPM_BUILD_ROOT