1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 inherit autotools libtool readme.gentoo-r1 systemd
7 DESCRIPTION="An IMAP daemon designed specifically for maildirs"
8 HOMEPAGE="https://www.courier-mta.org/imap/"
9 SRC_URI="mirror://sourceforge/courier/${P}.tar.bz2"
13 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 sparc x86"
15 IUSE="berkdb debug fam +gdbm gnutls ipv6 libressl selinux trashquota"
16 REQUIRED_USE="|| ( berkdb gdbm )"
19 gnutls? ( net-libs/gnutls[tools] )
21 !libressl? ( dev-libs/openssl:0= )
22 libressl? ( dev-libs/libressl:0= )
24 >=net-libs/courier-authlib-0.66.4
25 >=net-libs/courier-unicode-2
26 >=net-mail/mailbase-0.00-r8
28 berkdb? ( sys-libs/db:= )
30 gdbm? ( >=sys-libs/gdbm-1.8.0 )
35 userland_GNU? ( sys-process/procps )
38 selinux? ( sec-policy/selinux-courier )
41 # get rid of old style virtual - bug 350792
52 # make check is not supported by this package due to the
53 # --enable-workarounds-for-imap-client-bugs option.
56 DISABLE_AUTOFORMATTING="yes"
58 Please read http://www.courier-mta.org/imap/INSTALL.html#upgrading
59 and remove TLS_DHPARAMS from configuration files or run mkdhparams
61 For a quick-start howto please refer to
62 ${PN}-gentoo.readme in /usr/share/doc/${PF}
64 Please convert maildir to utf8
65 and rerun mkdhparams if needed. Location has changed
69 "${FILESDIR}/${PN}-4.17-disable-fam-configure.ac.patch"
70 "${FILESDIR}/${PN}-4.17-aclocal-fix.patch"
76 # These patches should fix problems detecting BerkeleyDB.
77 # We now can compile with db4 support.
79 eapply "${FILESDIR}/${PN}-4.17-db4-bdbobj_configure.ac.patch"
80 eapply "${FILESDIR}/${PN}-4.17-db4-configure.ac.patch"
89 # Default to gdbm if both berkdb and gdbm are present.
91 einfo "Building with GDBM support"
92 myconf="${myconf} --with-db=gdbm"
93 elif use berkdb ; then
94 einfo "Building with BerkeleyDB support"
95 myconf="${myconf} --with-db=db"
98 if use trashquota ; then
99 einfo "Building with Trash Quota Support"
100 myconf="${myconf} --with-trashquota"
103 use debug && myconf="${myconf} debug=true"
106 --with-notice=unicode \
107 --disable-root-check \
109 --sysconfdir="/etc/${PN}" \
110 --libexecdir="/usr/$(get_libdir)/${PN}" \
111 --localstatedir="/var/lib/${PN}" \
112 --with-authdaemonvar="/var/lib/${PN}/authdaemon" \
113 --enable-workarounds-for-imap-client-bugs \
114 --with-mailuser=mail \
115 --with-mailgroup=mail \
116 --with-certsdir="/etc/courier-imap" \
124 # spurious failures with parallel compiles, bug #????
129 dodir "/var/lib/${PN}" /etc/pam.d
130 keepdir /var/lib/courier-imap
133 rm -r "${D}/etc/pam.d" || die
135 # Avoid name collisions in /usr/sbin wrt imapd and pop3d
136 for name in imapd pop3d ; do
137 mv "${D}/usr/sbin/"{,courier-}${name} \
138 || die "failed to rename ${name} to courier-${name}"
141 # Hack /usr/lib/courier-imap/foo.rc to use ${MAILDIR} instead of
142 # 'Maildir', and to use /usr/sbin/courier-foo names.
143 for service in {imapd,pop3d}{,-ssl} ; do
144 sed -e 's/Maildir/${MAILDIR}/' \
145 -i "${D}/usr/$(get_libdir)/${PN}/${service}.rc" \
147 sed -e "s/\/usr\/sbin\/${service}/\/usr\/sbin\/courier-${service}/" \
148 -i "${D}/usr/$(get_libdir)/${PN}/${service}.rc" \
152 # Rename the config files correctly and add a value for ${MAILDIR}
154 for service in {imapd,pop3d}{,-ssl} ; do
155 mv "${D}/etc/${PN}/${service}"{.dist,} \
156 || die "failed to rename ${service}.dist to ${service}"
157 echo -e '\n# Hardwire a value for ${MAILDIR}' \
158 >> "${D}/etc/${PN}/${service}"
159 echo 'MAILDIR=.maildir' >> "${D}/etc/${PN}/${service}"
160 echo 'MAILDIRPATH=.maildir' >> "${D}/etc/${PN}/${service}"
163 for service in imapd pop3d ; do
164 echo -e '# Put any program for ${PRERUN} here' \
165 >> "${D}/etc/${PN}/${service}"
166 echo 'PRERUN=' >> "${D}/etc/${PN}/${service}"
167 echo -e '# Put any program for ${LOGINRUN} here' \
168 >> "${D}/etc/${PN}/${service}"
169 echo -e '# this is for relay-ctrl-allow in 4*' \
170 >> "${D}/etc/${PN}/${service}"
171 echo 'LOGINRUN=' >> "${D}/etc/${PN}/${service}"
174 for x in "${D}/usr/sbin"/* ; do
175 if [[ -L "${x}" ]] ; then
176 rm "${x}" || die "failed to remove ${x}"
180 mv "${D}/usr/share"/* "${D}/usr/sbin/" || die
181 mv "${D}/usr/sbin/man" "${D}/usr/share/" || die
183 rm "${D}/usr/sbin/"{mkimapdcert,mkpop3dcert} || die
185 dosbin "${FILESDIR}/mkimapdcert" "${FILESDIR}/mkpop3dcert"
187 dosym ../../sbin/courierlogger "/usr/$(get_libdir)/${PN}/courierlogger"
189 for initd in courier-{imapd,pop3d}{,-ssl} ; do
190 sed -e "s:GENTOO_LIBDIR:$(get_libdir):g" \
191 "${FILESDIR}/${PN}-${INITD_VER}-${initd}.rc6" \
193 || die "initd libdir-sed failed"
194 doinitd "${T}/${initd}"
197 cp "${FILESDIR}"/courier-*-r1.service .
200 -e "s:/usr/lib/:/usr/$(get_libdir)/:" \
201 courier-*-r1.service \
204 systemd_newunit courier-authdaemond-r1.service \
205 courier-authdaemond.service
206 systemd_newunit courier-imapd-ssl-r1.service \
207 courier-imapd-ssl.service
208 systemd_newunit courier-imapd-r1.service \
209 courier-imapd.service
211 exeinto "/usr/$(get_libdir)/${PN}"
212 for exe in gentoo-{imapd,pop3d}{,-ssl}.rc courier-{imapd,pop3d}.indirect ; do
213 sed -e "s:GENTOO_LIBDIR:$(get_libdir):g" \
214 "${FILESDIR}/${PN}-${RC_VER}-${exe}" \
216 || die "exe libdir-sed failed"
220 # Avoid a collision with mail-mta/netqmail, bug 482098.
221 mv "${D}/usr/sbin/"{,courier-}maildirmake \
222 || die "failed to rename maildirmake to courier-maildirmake"
223 mv "${D}/usr/share/man/man1/"{,courier-}maildirmake.1 \
224 || die "failed to rename maildirmake.1 to courier-maildirmake.1"
226 dodoc AUTHORS INSTALL NEWS README ChangeLog
227 readme.gentoo_create_doc
228 dodoc "${FILESDIR}/${PN}-gentoo.readme"
230 dodoc libs/imap/ChangeLog libs/imap/BUGS* libs/imap/README*
232 dodoc libs/maildir/AUTHORS libs/maildir/*.html libs/maildir/README*
234 dodoc libs/rfc2045/*.html
236 dodoc libs/tcpd/README* libs/tcpd/*.html
237 exeinto /etc/cron.monthly
238 newexe "${FILESDIR}"/${PN}.cron ${PN}
242 # Some users have been reporting that permissions on this directory were
243 # getting scrambled, so let's ensure that they are sane.
244 fperms 0755 "${ROOT}/usr/$(get_libdir)/${PN}"
246 readme.gentoo_print_elog
249 elog "Courier Imap now run as user mail:mail."
251 elog "This require you to enable read/write access to the caches:"
252 elog "/var/lib/courier-imap/courierssl*cache (chown mail:mail)"
253 elog "and read access to the certificates (e.g. /etc/courier-imap/pop3d.pem )"