dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / net-mail / courier-imap / courier-imap-5.0.7.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 inherit autotools libtool readme.gentoo-r1 systemd
6
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"
10
11 LICENSE="GPL-3"
12 SLOT="0"
13 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 s390 sparc x86"
14
15 IUSE="berkdb debug fam +gdbm gnutls ipv6 libressl selinux trashquota"
16 REQUIRED_USE="|| ( berkdb gdbm )"
17
18 CDEPEND="
19         gnutls? ( net-libs/gnutls[tools] )
20         !gnutls? (
21                 !libressl? ( dev-libs/openssl:0= )
22                 libressl? ( dev-libs/libressl:0= )
23         )
24         >=net-libs/courier-authlib-0.66.4
25         >=net-libs/courier-unicode-2
26         >=net-mail/mailbase-0.00-r8
27         net-dns/libidn:=
28         berkdb? ( sys-libs/db:= )
29         fam? ( virtual/fam )
30         gdbm? ( >=sys-libs/gdbm-1.8.0 )
31 "
32 DEPEND="${CDEPEND}
33         dev-lang/perl
34         !mail-mta/courier
35         userland_GNU? ( sys-process/procps )
36 "
37 RDEPEND="${CDEPEND}
38         selinux? ( sec-policy/selinux-courier )
39 "
40
41 # get rid of old style virtual - bug 350792
42 RDEPEND="${RDEPEND}
43         !mail-mta/courier
44         !net-mail/bincimap
45         !net-mail/cyrus-imapd
46         !net-mail/uw-imap
47 "
48
49 RC_VER="4.0.6-r1"
50 INITD_VER="4.0.6-r1"
51
52 # make check is not supported by this package due to the
53 # --enable-workarounds-for-imap-client-bugs option.
54 RESTRICT="test"
55
56 DISABLE_AUTOFORMATTING="yes"
57 DOC_CONTENTS="
58 Please read http://www.courier-mta.org/imap/INSTALL.html#upgrading
59 and remove TLS_DHPARAMS from configuration files or run mkdhparams
60
61 For a quick-start howto please refer to
62 ${PN}-gentoo.readme in /usr/share/doc/${PF}
63
64 Please convert maildir to utf8
65 and rerun mkdhparams if needed. Location has changed
66 "
67
68 PATCHES=(
69         "${FILESDIR}/${PN}-4.17-disable-fam-configure.ac.patch"
70         "${FILESDIR}/${PN}-4.17-aclocal-fix.patch"
71 )
72
73 src_prepare() {
74         default
75
76         # These patches should fix problems detecting BerkeleyDB.
77         # We now can compile with db4 support.
78         if use berkdb ; then
79                 eapply "${FILESDIR}/${PN}-4.17-db4-bdbobj_configure.ac.patch"
80                 eapply "${FILESDIR}/${PN}-4.17-db4-configure.ac.patch"
81         fi
82
83         eautoreconf
84 }
85
86 src_configure() {
87         local myconf=""
88
89         # Default to gdbm if both berkdb and gdbm are present.
90         if use gdbm ; then
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"
96         fi
97
98         if use trashquota ; then
99                 einfo "Building with Trash Quota Support"
100                 myconf="${myconf} --with-trashquota"
101         fi
102
103         use debug && myconf="${myconf} debug=true"
104
105         econf \
106                 --with-notice=unicode \
107                 --disable-root-check \
108                 --bindir=/usr/sbin \
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" \
117                 $(use_with fam) \
118                 $(use_with ipv6) \
119                 $(use_with gnutls) \
120                 ${myconf}
121 }
122
123 #src_compile() {
124         # spurious failures with parallel compiles, bug #????
125 #       emake -j1
126 #}
127
128 src_install() {
129         dodir "/var/lib/${PN}" /etc/pam.d
130         keepdir /var/lib/courier-imap
131
132         default
133         rm -r "${D}/etc/pam.d" || die
134
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}"
139         done
140
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" \
146                         || die "sed failed"
147                 sed -e "s/\/usr\/sbin\/${service}/\/usr\/sbin\/courier-${service}/" \
148                         -i "${D}/usr/$(get_libdir)/${PN}/${service}.rc" \
149                         || die "sed failed"
150         done
151
152         # Rename the config files correctly and add a value for ${MAILDIR}
153         # to them.
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}"
161         done
162
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}"
172         done
173
174         for x in "${D}/usr/sbin"/* ; do
175                 if [[ -L "${x}" ]] ; then
176                         rm "${x}" || die "failed to remove ${x}"
177                 fi
178         done
179
180         mv "${D}/usr/share"/* "${D}/usr/sbin/" || die
181         mv "${D}/usr/sbin/man" "${D}/usr/share/" || die
182
183         rm "${D}/usr/sbin/"{mkimapdcert,mkpop3dcert} || die
184
185         dosbin "${FILESDIR}/mkimapdcert" "${FILESDIR}/mkpop3dcert"
186
187         dosym ../../sbin/courierlogger "/usr/$(get_libdir)/${PN}/courierlogger"
188
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" \
192                         > "${T}/${initd}" \
193                         || die "initd libdir-sed failed"
194                 doinitd "${T}/${initd}"
195         done
196
197         cp "${FILESDIR}"/courier-*-r1.service .
198
199         sed -i \
200                 -e "s:/usr/lib/:/usr/$(get_libdir)/:" \
201                 courier-*-r1.service \
202                 || die
203
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
210
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}" \
215                         > "${T}/${exe}" \
216                         || die "exe libdir-sed failed"
217                 doexe "${T}/${exe}"
218         done
219
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"
225
226         dodoc AUTHORS INSTALL NEWS README ChangeLog
227         readme.gentoo_create_doc
228         dodoc "${FILESDIR}/${PN}-gentoo.readme"
229         docinto imap
230         dodoc libs/imap/ChangeLog libs/imap/BUGS* libs/imap/README*
231         docinto maildir
232         dodoc libs/maildir/AUTHORS libs/maildir/*.html libs/maildir/README*
233         docinto rfc2045
234         dodoc libs/rfc2045/*.html
235         docinto tcpd
236         dodoc libs/tcpd/README* libs/tcpd/*.html
237         exeinto /etc/cron.monthly
238         newexe "${FILESDIR}"/${PN}.cron ${PN}
239 }
240
241 pkg_postinst() {
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}"
245
246         readme.gentoo_print_elog
247
248         elog ""
249         elog "Courier Imap now run as user mail:mail."
250         elog ""
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 )"
254 }