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")
6 # we aren't RH we are PLD
7 %define courier_release 0
9 Summary: Courier %{version} mail server
11 Version: 0.26.20000822
12 Release: 1%{courier_release}
14 Group: Applications/Mail
15 Source: courier-0.26.20000822.tar.gz
16 #Packager: %{PACKAGER}
17 #BuildRoot: /var/tmp/courier-install
18 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
21 Requires: /sbin/chkconfig
24 # RH custom locations.
27 # manpages /usr/man /usr/share/man
28 # httpd /home/httpd /var/www
29 # initscripts /etc/rc.d/init.d /etc/init.d
31 #%{expand:%%define manpagedir %(if test -d %{_prefix}/share/man ; then echo %{_prefix}/share/man ; else echo %{_prefix}/man ; fi)}
33 %define apachedir %(if test -d /var/www ; then echo /var/www ; else echo /home/httpd ; fi)
35 %define _prefix /usr/lib/courier
36 %define _localstatedir /var/spool/courier
37 %define _sysconfdir /etc/courier
39 #%define _mandir %{manpagedir}
41 %define initdir %(if test -d /etc/init.d/. ; then echo /etc/init.d ; else echo /etc/rc.d/init.d ; fi)
43 # Change the following if your DocumentRoot and cgibindir differ. This is
44 # the default redhat build:
46 %define _cgibindir %{apachedir}/cgi-bin
47 %define _documentrootdir %{apachedir}/html
48 %define _imageurl /webmail/
50 %package sendmail-wrapper
51 Summary: Courier %{version} soft links for sendmail
52 Group: Applications/Mail
55 Summary: Courier %{version} Integrated POP3 server
56 Group: Applications/Mail
57 Requires: courier = %{version}
60 Summary: Courier %{version} Integrated IMAP server
61 Group: Applications/Mail
62 Requires: courier = %{version}
63 Obsoletes: courier-imap
66 Summary: Courier %{version} Integrated HTTP (webmail) server
67 Group: Applications/Mail
68 Requires: courier = %{version} %{_cgibindir} %{_documentrootdir}
71 Summary: Courier %{version} Integrated Mailing List Manager
72 Group: Applications/Mail
73 Requires: courier = %{version}
76 Summary: Courier %{version} Integrated mail filter
77 Group: Applications/Mail
78 Requires: courier = %{version}
80 %package maildrop-wrapper
81 Summary: Courier %{version} soft links for maildrop
82 Group: Applications/Mail
83 Requires: courier-maildrop = %{version}
86 Summary: Courier %{version} mail server authenticated ESMTP module
87 Group: Applications/Mail
88 Requires: courier = %{version}
92 Courier is a fully functional mail server, that can completely take
93 over the mail services normally provided by sendmail, Qmail, or any
94 other mail server. Although Courier does not support all legacy
95 features of existing mail servers, the number of obsoleted functions
96 is very small, and there are better, and more robust, alternatives
99 Courier implements many SMTP extensions: DSN, PIPELINING, 8BITMIME.
100 Courier also implements several new SMTP extensions for mailing list
101 management and spam filtering.
103 %description sendmail-wrapper
104 This package contains two soft links from /usr/sbin/sendmail and
105 /usr/lib/sendmail to %{_bindir}/sendmail. This allows application
106 that use sendmail to transparently use Courier for sending mail.
109 This package installs Courier mail server's integrated POP3 server,
110 which allows you to download mail from your mailbox using any POP3
111 client. Courier's POP3 server can only be used to download mail
112 from maildir mailboxes. This server does not support mailbox files.
113 If you do not need the ability to download your mail using a POP3
114 client, you do not need to install this package.
117 This package installs Courier mail server's integrated IMAP server.
118 If you do not need the ability to download your mail using an IMAP
119 mail client, you do not need to install this package. Courier's
120 IMAP server can only be used to download mail from maildir
121 mailboxes. This server does not support mailbox files.
123 This package requires that Courier must be already installed, this
124 is NOT the standalone version of the Courier-IMAP server, and you
125 cannot install both this package, and the standalone version of
126 Courier-IMAP. If you have the standalone version of the
127 Courier-IMAP server already installed, installing this package
128 will automatically remove the standalone version.
131 This package installs Courier mail server's integrated HTTP webmail
132 server. If you do not need the ability to access your mail using a
133 web browser, you do not need to install this package. Courier's
134 webmail server can only be used to download mail from maildir
135 mailboxes. This server does not support mailbox files.
137 This is the same server that's distributed separately under the
138 name of SqWebMail, however its configuration is customized for the
141 %description maildrop
142 This package installs Courier mail server's integrated mail filter.
143 You need to install this package if you want to be able to filter
147 This package installs couriermlm - a mailing list manager for the
148 Courier mail server. If you do not need the ability to manage
149 mailing lists, you do not need to install this package.
151 couriermlm is used to set up, maintain, and run a mailing list.
152 couriermlm automatically processes subscription and unsubscription
153 requests, and removes undeliverable addresses from the subscription
154 rolls. Mailing lists managed by couriermlm require zero human
155 administrative oversight. couriermlm supports digests, write-only
156 posting aliases, and moderated mailing lists.
158 %description maildrop-wrapper
159 This package installs several soft links from the /usr/local/bin
160 directory to Courier's integrated maildrop mail filter. Maildrop is
161 available as a standalone package, which installs in /usr/local/bin.
162 If you have applications that expect to find maildrop in /usr/local/bin
163 you can install this package to create soft links that point to
164 Courier's integrated maildrop version instead, in order to continue
165 to use those applications, without needing to reconfigure them.
167 %description smtpauth
168 Authenticated ESMTP allows remote users to authenticate themselves
169 and be able to relay outbound mail through the Courier mail server.
175 --localstatedir=%{_localstatedir} \
176 --sysconfdir=%{_sysconfdir} \
177 --mandir=%{_mandir} \
178 --enable-imageurl=%{_imageurl}
180 cat >README.REDHAT <<EOF
182 This installation of Courier is configured as follows:
184 Installation directory: %{_prefix}
185 Binary installation directory: %{_exec_prefix}
187 Superuser binaries: %{_sbindir}
188 Program executables: %{_libexecdir}
189 Configuration files: %{_sysconfdir}
190 Scripts, other non-binaries: %{_datadir}
191 Mail queue, temporary files: %{_localstatedir}
192 Manual pages: %{_mandir}
202 test "$RPM_BUILD_ROOT" != "" && rm -rf $RPM_BUILD_ROOT
203 install -d $RPM_BUILD_ROOT%{_prefix}
204 install -d $RPM_BUILD_ROOT/etc/pam.d
206 if test "%{_package_maintainer}" = "1"
208 make install DESTDIR=$RPM_BUILD_ROOT
210 make install-strip DESTDIR=$RPM_BUILD_ROOT
213 ln -s %{_sysconfdir}/pop3d.authpam $RPM_BUILD_ROOT/etc/pam.d/pop3
214 ln -s %{_sysconfdir}/esmtp.authpam $RPM_BUILD_ROOT/etc/pam.d/esmtp
215 ln -s %{_sysconfdir}/imapd.authpam $RPM_BUILD_ROOT/etc/pam.d/imap
216 ln -s %{_sysconfdir}/webmail.authpam $RPM_BUILD_ROOT/etc/pam.d/webmail
221 # We're going to create some more config files later, so let's just make
222 # sure they're processed as all other Courier config files
225 echo '/etc/pam.d/esmtp 644 root root' >>permissions.dat
226 echo '/etc/profile.d/courier.sh 755 bin bin config' >>permissions.dat
227 echo '/etc/profile.d/courier.csh 755 bin bin config' >>permissions.dat
228 echo '%{initdir}/courier 755 bin bin config' >>permissions.dat
231 # Translate permissions.dat to spec file filelist.
235 $buildroot=$ENV{"RPM_BUILD_ROOT"};
236 $prefix="%{_prefix}";
237 $exec_prefix="%{_exec_prefix}";
242 ($file,$mode,$uid,$gid,$special)=split(/ +/);
243 $file=$prefix if $file eq "$prefix/.";
245 next if $special eq "doc";
246 next if $file eq "$prefix/doc";
248 # Ignore dir/. entries
250 next if $file =~ /\/\.$/;
252 # Ignore man directories
254 next if $file eq "%{_mandir}";
255 next if substr($file, 0, length("%{_mandir}")) eq "%{_mandir}"
256 && substr($file, length("%{_mandir}")) =~ /^\/man[1-9]$/;
258 $mode = "-" if $special eq "%doc";
259 $special="%config" if $special eq "config";
260 $special="%dir" if ! -l "$buildroot/$file" && -d "$buildroot/$file";
261 if ($special eq "man")
263 if ( -l "$buildroot/$file" )
265 print STDERR "ln -s " . readlink("$buildroot$file")
266 . ".gz $buildroot/$file.gz\n";
267 symlink readlink("$buildroot$file")
268 . ".gz", "$buildroot/$file.gz";
272 print STDERR "gzip <$buildroot$file >$buildroot$file.gz\n";
273 system("gzip <$buildroot$file >$buildroot$file.gz ; rm -f $buildroot$file");
277 $special="" unless $special =~ /%/;
279 $special="%attr($mode, $uid, $gid) $special";
280 print "$special $file\n";
283 ' <permissions.dat >filelist1 || exit 1
285 sed -n '/imap[\.a-z0-9]*$/p;/imapd-ssl/p' <filelist1 >filelist.imap
286 sed -n '/pop3[\.a-z0-9]*$/p' <filelist1 >filelist.pop3
287 sed -n '/couriermlm/p' <filelist1 >filelist.mlm
288 sed -n '/authstart$/p;/authend$/p' <filelist1 >filelist.auth
289 sed -n '/maildrop[^/]*$/p;/reformail[^/]*$/p;/reformime[^/]*$/p' <filelist1 >filelist.maildrop
290 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
292 sed -n '/sqwebmail/p;/webmail.authpam/p;/webmail-logincache/p;/ldapaddressbook$/p' <filelist1 | sed '/images/d' >filelist.webmail
294 # Note that we delete all 'webmail's, but copy over only 'sqwebmail's.
295 # This removes all webmail-related stuff from the main filelist,
296 # and adds everything except the executable, webmail, to filelist.webmail.
299 install -d $RPM_BUILD_ROOT%{_cgibindir}
300 cp $RPM_BUILD_ROOT%{_libexecdir}/courier/webmail/webmail \
301 $RPM_BUILD_ROOT%{_cgibindir}/webmail
303 # And here's why we delete all images from filelist.webmail:
305 install -d $RPM_BUILD_ROOT%{_documentrootdir}
306 mv $RPM_BUILD_ROOT%{_datadir}/sqwebmail/images $RPM_BUILD_ROOT%{_documentrootdir}/webmail
308 # Do we need to install a cron job to clean out webmail's cache?
310 if test -f webmail/cron.cmd
312 install -d $RPM_BUILD_ROOT/etc/cron.hourly
313 cp webmail/cron.cmd $RPM_BUILD_ROOT/etc/cron.hourly/courier-webmail-cleancache
314 echo "%attr(555, root, wheel) /etc/cron.hourly/courier-webmail-cleancache" >>filelist.webmail
318 # Move .html documentation back to build dir, so that RPM will move it to
319 # the appropriate docdir
324 cp $RPM_BUILD_ROOT%{_datadir}/htmldoc/* htmldoc
327 # Manually set POP3DSTART and IMAPDSTART to yes, they'll go into a separate
328 # package, so after it's installed they should be runnable.
330 sed 's/^POP3DSTART.*/POP3DSTART=YES/' <$RPM_BUILD_ROOT%{_sysconfdir}/pop3d >$RPM_BUILD_ROOT%{_sysconfdir}/pop3d.new
331 mv $RPM_BUILD_ROOT%{_sysconfdir}/pop3d.new $RPM_BUILD_ROOT%{_sysconfdir}/pop3d
333 sed 's/^IMAPDSTART.*/IMAPDSTART=YES/' <$RPM_BUILD_ROOT%{_sysconfdir}/imapd >$RPM_BUILD_ROOT%{_sysconfdir}/imapd.new
334 mv $RPM_BUILD_ROOT%{_sysconfdir}/imapd.new $RPM_BUILD_ROOT%{_sysconfdir}/imapd
336 sed 's/^IMAPDSSLSTART.*/IMAPDSSLSTART=YES/' <$RPM_BUILD_ROOT%{_sysconfdir}/imapd-ssl >$RPM_BUILD_ROOT%{_sysconfdir}/imapd.new-ssl
337 mv $RPM_BUILD_ROOT%{_sysconfdir}/imapd.new-ssl $RPM_BUILD_ROOT%{_sysconfdir}/imapd-ssl
340 # Red Hat init.d file
343 install -d $RPM_BUILD_ROOT%{initdir}
345 cp courier.sysvinit $RPM_BUILD_ROOT%{initdir}/courier
348 # Red Hat /etc/profile.d scripts
351 install -d $RPM_BUILD_ROOT/etc/profile.d
352 cat >$RPM_BUILD_ROOT/etc/profile.d/courier.sh <<EOF
353 if echo "\$PATH" | tr ':' '\012' | fgrep -qx %{_bindir}
359 PATH="%{_sbindir}:\$PATH"
361 PATH="%{_bindir}:\$PATH"
366 cat >$RPM_BUILD_ROOT/etc/profile.d/courier.csh <<EOF
368 echo "\$PATH" | tr ':' '\012' | fgrep -qx %{_bindir}
376 setenv PATH "%{_sbindir}:\$PATH"
378 setenv PATH "%{_bindir}:\$PATH"
383 # sendmail soft links
386 install -d $RPM_BUILD_ROOT/usr/sbin
387 install -d $RPM_BUILD_ROOT/usr/lib
388 install -d $RPM_BUILD_ROOT/usr/bin
390 ln -s %{_bindir}/sendmail $RPM_BUILD_ROOT/usr/sbin/sendmail
391 ln -s %{_bindir}/sendmail $RPM_BUILD_ROOT/usr/lib/sendmail
392 ln -s %{_bindir}/sendmail $RPM_BUILD_ROOT/usr/bin/sendmail
395 # maildrop wrapper soft links
398 install -d $RPM_BUILD_ROOT/usr/local/bin
400 for f in dotlock maildirmake maildrop makedat reformail reformime deliverquota
402 ln -s %{_bindir}/$f $RPM_BUILD_ROOT/usr/local/bin/$f
405 for f in makeuserdb pw2userdb userdb userdbpw vchkpw2userdb
407 ln -s %{_sbindir}/$f $RPM_BUILD_ROOT/usr/local/bin/$f
411 # The following directories are not created by default, but I want them here.
414 install -d $RPM_BUILD_ROOT%{_sysconfdir}/userdb
415 install -d $RPM_BUILD_ROOT%{_localstatedir}/tmp/broken
417 . courier/uidgid || exit 1
422 echo "%attr(700, $mailuser, $mailgroup) %dir %{_sysconfdir}/userdb" >>filelist
423 echo "%attr(755, $mailuser, $mailgroup) %dir %{_localstatedir}/tmp/broken" >>filelist
427 %{_sbindir}/makealiases 2>/dev/null || true
428 %{_sbindir}/makesmtpaccess 2>/dev/null || true
430 # If we do not have a certificate, make one up.
432 if test ! -f %{_datadir}/esmtpd.pem
434 %{_sbindir}/mkesmtpdcert
438 %{initdir}/courier stop
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