dev-python/agate: Bump to 1.13.0
[gentoo/gentoo.git] / net-mail / courier-imap / courier-imap-5.1.2-r1.ebuild
blob303441bd0d0a79d563080682abcfb85d234dfe2e
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=7
5 inherit autotools readme.gentoo-r1 systemd
7 DESCRIPTION="An IMAP daemon designed specifically for maildirs"
8 HOMEPAGE="https://www.courier-mta.org/imap/"
9 SRC_URI="https://downloads.sourceforge.net/courier/${P}.tar.bz2"
11 LICENSE="GPL-3"
12 SLOT="0"
13 KEYWORDS="~alpha amd64 arm arm64 ~hppa ~mips ~ppc ppc64 ~s390 sparc x86"
15 IUSE="berkdb debug fam +gdbm gnutls ipv6 selinux trashquota"
16 REQUIRED_USE="|| ( berkdb gdbm )"
18 CDEPEND="
19         gnutls? ( net-libs/gnutls:=[tools] )
20         !gnutls? (
21                 dev-libs/openssl:0=
22         )
23         >=net-libs/courier-authlib-0.71
24         >=net-libs/courier-unicode-2:=
25         >=net-mail/mailbase-0.00-r8
26         net-dns/libidn:=
27         berkdb? ( sys-libs/db:= )
28         fam? ( virtual/fam )
29         gdbm? ( >=sys-libs/gdbm-1.8.0:= )
31 DEPEND="${CDEPEND}
32         dev-lang/perl
33         !mail-mta/courier
34         sys-process/procps
36 RDEPEND="${CDEPEND}
37         selinux? ( sec-policy/selinux-courier )
40 # get rid of old style virtual - bug 350792
41 RDEPEND="${RDEPEND}
42         !mail-mta/courier
43         !net-mail/cyrus-imapd
46 RC_VER="4.0.6-r1"
47 INITD_VER="4.0.6-r1"
49 # make check is not supported by this package due to the
50 # --enable-workarounds-for-imap-client-bugs option.
51 RESTRICT="test"
53 DISABLE_AUTOFORMATTING="yes"
54 DOC_CONTENTS="
55 Please read http://www.courier-mta.org/imap/INSTALL.html#upgrading
56 and remove TLS_DHPARAMS from configuration files or run mkdhparams
58 For a quick-start howto please refer to
59 ${PN}-gentoo.readme in /usr/share/doc/${PF}
61 Please convert maildir to utf8
62 and rerun mkdhparams if needed. Location has changed
65 PATCHES=(
66         "${FILESDIR}/${PN}-4.17-aclocal-fix.patch"
67         "${FILESDIR}/${PN}-5.0.8-ar-fix.patch"
70 src_prepare() {
71         default
73         # These patches should fix problems detecting BerkeleyDB.
74         # We now can compile with db4 support.
75         if use berkdb ; then
76                 eapply "${FILESDIR}/${PN}-4.17-db4-bdbobj_configure.ac.patch"
77                 eapply "${FILESDIR}/${PN}-4.17-db4-configure.ac.patch"
78         fi
80         eautoreconf
83 src_configure() {
84         local myconf=""
86         # Default to gdbm if both berkdb and gdbm are present.
87         if use gdbm ; then
88                 einfo "Building with GDBM support"
89                 myconf="${myconf} --with-db=gdbm"
90         elif use berkdb ; then
91                 einfo "Building with BerkeleyDB support"
92                 myconf="${myconf} --with-db=db"
93         fi
95         if use trashquota ; then
96                 einfo "Building with Trash Quota Support"
97                 myconf="${myconf} --with-trashquota"
98         fi
100         use debug && myconf="${myconf} debug=true"
102         econf \
103                 --with-notice=unicode \
104                 --disable-root-check \
105                 --bindir=/usr/sbin \
106                 --sysconfdir="/etc/${PN}" \
107                 --libexecdir="/usr/$(get_libdir)/${PN}" \
108                 --localstatedir="/var/lib/${PN}" \
109                 --with-authdaemonvar="/var/lib/${PN}/authdaemon" \
110                 --enable-workarounds-for-imap-client-bugs \
111                 --with-mailuser=mail \
112                 --with-mailgroup=mail \
113                 --with-certsdir="/etc/courier-imap" \
114                 $(use_with fam) \
115                 $(use_with ipv6) \
116                 $(use_with gnutls) \
117                 ${myconf}
120 #src_compile() {
121         # spurious failures with parallel compiles, bug #????
122 #       emake -j1
125 src_install() {
126         dodir "/var/lib/${PN}" /etc/pam.d
127         keepdir /var/lib/courier-imap
129         default
130         rm -r "${D}/etc/pam.d" || die
132         # Avoid name collisions in /usr/sbin wrt imapd and pop3d
133         for name in imapd pop3d ; do
134                 mv "${D}/usr/sbin/"{,courier-}${name} \
135                         || die "failed to rename ${name} to courier-${name}"
136         done
138         # Hack /usr/lib/courier-imap/foo.rc to use ${MAILDIR} instead of
139         # 'Maildir', and to use /usr/sbin/courier-foo names.
140         for service in {imapd,pop3d}{,-ssl} ; do
141                 sed -e 's/Maildir/${MAILDIR}/' \
142                         -i "${D}/usr/$(get_libdir)/${PN}/${service}.rc" \
143                         || die "sed failed"
144                 sed -e "s/\/usr\/sbin\/${service}/\/usr\/sbin\/courier-${service}/" \
145                         -i "${D}/usr/$(get_libdir)/${PN}/${service}.rc" \
146                         || die "sed failed"
147         done
149         # Rename the config files correctly and add a value for ${MAILDIR}
150         # to them.
151         for service in {imapd,pop3d}{,-ssl} ; do
152                 mv "${D}/etc/${PN}/${service}"{.dist,} \
153                         || die "failed to rename ${service}.dist to ${service}"
154                 echo -e '\n# Hardwire a value for ${MAILDIR}' \
155                          >> "${D}/etc/${PN}/${service}"
156                 echo 'MAILDIR=.maildir' >> "${D}/etc/${PN}/${service}"
157                 echo 'MAILDIRPATH=.maildir' >> "${D}/etc/${PN}/${service}"
158         done
160         for service in imapd pop3d ; do
161                 echo -e '# Put any program for ${PRERUN} here' \
162                          >> "${D}/etc/${PN}/${service}"
163                 echo 'PRERUN=' >> "${D}/etc/${PN}/${service}"
164                 echo -e '# Put any program for ${LOGINRUN} here' \
165                          >> "${D}/etc/${PN}/${service}"
166                 echo -e '# this is for relay-ctrl-allow in 4*' \
167                          >> "${D}/etc/${PN}/${service}"
168                 echo 'LOGINRUN=' >> "${D}/etc/${PN}/${service}"
169         done
171         for x in "${D}/usr/sbin"/* ; do
172                 if [[ -L "${x}" ]] ; then
173                         rm "${x}" || die "failed to remove ${x}"
174                 fi
175         done
177         mv "${D}/usr/share"/* "${D}/usr/sbin/" || die
178         mv "${D}/usr/sbin/man" "${D}/usr/share/" || die
180         rm "${D}/usr/sbin/"{mkimapdcert,mkpop3dcert} || die
182         dosbin "${FILESDIR}/mkimapdcert" "${FILESDIR}/mkpop3dcert"
184         dosym ../../sbin/courierlogger "/usr/$(get_libdir)/${PN}/courierlogger"
186         for initd in courier-{imapd,pop3d}{,-ssl} ; do
187                 sed -e "s:GENTOO_LIBDIR:$(get_libdir):g" \
188                         "${FILESDIR}/${PN}-${INITD_VER}-${initd}.rc6" \
189                         > "${T}/${initd}" \
190                         || die "initd libdir-sed failed"
191                 doinitd "${T}/${initd}"
192         done
194         cp "${FILESDIR}"/courier-*-r1.service .
196         sed -i \
197                 -e "s:/usr/lib/:/usr/$(get_libdir)/:" \
198                 courier-*-r1.service \
199                 || die
201         systemd_newunit courier-authdaemond-r1.service \
202                                         courier-authdaemond.service
203         systemd_newunit courier-imapd-ssl-r1.service \
204                                         courier-imapd-ssl.service
205         systemd_newunit courier-imapd-r1.service \
206                                         courier-imapd.service
208         exeinto "/usr/$(get_libdir)/${PN}"
209         for exe in gentoo-{imapd,pop3d}{,-ssl}.rc courier-{imapd,pop3d}.indirect ; do
210                 sed -e "s:GENTOO_LIBDIR:$(get_libdir):g" \
211                         "${FILESDIR}/${PN}-${RC_VER}-${exe}" \
212                         > "${T}/${exe}" \
213                         || die "exe libdir-sed failed"
214                 doexe "${T}/${exe}"
215         done
217         # Avoid a collision with mail-mta/netqmail, bug 482098.
218         mv "${D}/usr/sbin/"{,courier-}maildirmake \
219                 || die "failed to rename maildirmake to courier-maildirmake"
220         mv "${D}/usr/share/man/man1/"{,courier-}maildirmake.1 \
221                 || die "failed to rename maildirmake.1 to courier-maildirmake.1"
223         dodoc AUTHORS INSTALL NEWS README ChangeLog
224         readme.gentoo_create_doc
225         dodoc "${FILESDIR}/${PN}-gentoo.readme"
226         docinto imap
227         dodoc libs/imap/ChangeLog libs/imap/BUGS* libs/imap/README*
228         docinto maildir
229         dodoc libs/maildir/AUTHORS libs/maildir/*.html libs/maildir/README*
230         docinto rfc2045
231         dodoc libs/rfc2045/*.html
232         docinto tcpd
233         dodoc libs/tcpd/README* libs/tcpd/*.html
234         exeinto /etc/cron.monthly
235         newexe "${FILESDIR}"/${PN}.cron ${PN}
238 pkg_postinst() {
239         # Some users have been reporting that permissions on this directory were
240         # getting scrambled, so let's ensure that they are sane.
241         chmod 0755 "${ROOT}/usr/$(get_libdir)/${PN}"
243         readme.gentoo_print_elog
245         elog ""
246         elog "Courier Imap now run as user mail:mail."
247         elog ""
248         elog "This require you to enable read/write access to the caches:"
249         elog "/var/lib/courier-imap/courierssl*cache (chown mail:mail)"
250         elog "and read access to the certificates (e.g. /etc/courier-imap/pop3d.pem )"