dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / net-mail / cyrus-imapd / cyrus-imapd-3.0.11.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 inherit autotools flag-o-matic pam ssl-cert user
6
7 DESCRIPTION="The Cyrus IMAP Server"
8 HOMEPAGE="https://www.cyrusimap.org/"
9 SRC_URI="https://github.com/cyrusimap/${PN}/releases/download/${P}/${P}.tar.gz"
10
11 LICENSE="BSD-with-attribution GPL-2"
12 SLOT="0"
13 KEYWORDS="~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
14 IUSE="afs backup calalarm caps clamav http kerberos ldap lmdb \
15         mysql nntp pam perl postgres replication +server sieve snmp \
16         sqlite ssl static-libs tcpd test xapian"
17 RESTRICT="!test? ( test )"
18
19 CDEPEND="
20         sys-libs/zlib:0=
21         dev-libs/libpcre:3
22         >=dev-libs/cyrus-sasl-2.1.13:2
23         dev-libs/jansson
24         dev-libs/icu:0=
25         sys-libs/e2fsprogs-libs
26         afs? ( net-fs/openafs )
27         calalarm? ( dev-libs/libical:0= )
28         caps? ( sys-libs/libcap )
29         clamav? ( app-antivirus/clamav )
30         http? ( dev-libs/libxml2:2 dev-libs/libical:0= )
31         kerberos? ( virtual/krb5 )
32         ldap? ( net-nds/openldap )
33         lmdb? ( dev-db/lmdb:0= )
34         mysql? ( dev-db/mysql-connector-c:0= )
35         nntp? ( !net-nntp/leafnode )
36         pam? (
37                         sys-libs/pam
38                         >=net-mail/mailbase-1
39                 )
40         perl? ( dev-lang/perl:= )
41         postgres? ( dev-db/postgresql:* )
42         snmp? ( >=net-analyzer/net-snmp-5.2.2-r1:0= )
43         ssl? ( >=dev-libs/openssl-1.0.1e:0=[-bindist] )
44         sqlite? ( dev-db/sqlite:3 )
45         tcpd? ( >=sys-apps/tcp-wrappers-7.6
46                 snmp? ( net-analyzer/net-snmp:0=[tcpd=] )
47                 )
48         xapian? ( >=dev-libs/xapian-1.4.0:0= )
49 "
50 DEPEND="${CDEPEND}
51         test? ( dev-util/cunit )
52 "
53
54 # all blockers really needed?
55 # file collision with app-arch/dump - bug 619584
56 RDEPEND="${CDEPEND}
57         !mail-mta/courier
58         !net-mail/bincimap
59         !net-mail/courier-imap
60         !net-mail/uw-imap
61         !app-arch/dump
62 "
63
64 REQUIRED_USE="
65         afs? ( kerberos )
66         backup? ( sqlite )
67         calalarm? ( http )
68         http? ( sqlite )
69 "
70
71 # https://bugs.gentoo.org/678754
72 # TODO: check underlinking for other libraries
73 PATCHES=( "${FILESDIR}/cyrus-imapd-libcap-libs-r1.patch" )
74
75 pkg_setup() {
76         enewuser cyrus -1 -1 /usr/cyrus mail
77         # https://bugs.gentoo.org/604466
78         append-ldflags $(no-as-needed)
79 }
80
81 src_prepare() {
82         default
83         # Fix master(8)->cyrusmaster(8) manpage.
84         for i in `grep -rl -e 'master\.8' -e 'master(8)' "${S}"` ; do
85                 sed -i -e 's:master\.8:cyrusmaster.8:g' \
86                         -e 's:master(8):cyrusmaster(8):g' \
87                         "${i}" || die "sed failed" || die "sed failed"
88         done
89         mv man/master.8 man/cyrusmaster.8 || die "mv failed"
90         sed -i -e "s:MASTER:CYRUSMASTER:g" \
91                 -e "s:Master:Cyrusmaster:g" \
92                 -e "s:master:cyrusmaster:g" \
93                 man/cyrusmaster.8 || die "sed failed"
94
95         # lock.h to afs/lock.h
96         sed -i -e '/lock.h/s:lock.h:afs/lock.h:' \
97                 ptclient/afskrb.c || die
98
99         eautoreconf
100 }
101
102 src_configure() {
103         local myconf
104         if use afs ; then
105                 myconf+=" --with-afs-libdir=/usr/$(get_libdir)"
106                 myconf+=" --with-afs-incdir=/usr/include/afs"
107         fi
108         # sphinx is unmaintained and dead, bug #662944
109         econf \
110                 --enable-unit-tests \
111                 --enable-murder \
112                 --enable-idled \
113                 --enable-event-notification \
114                 --enable-autocreate \
115                 --enable-pcre \
116                 --with-com_err \
117                 --with-cyrus-user=cyrus \
118                 --with-sasl \
119                 --without-krb \
120                 --without-krbdes \
121                 --disable-sphinx \
122                 --enable-squat \
123                 --with-zlib \
124                 $(use_enable afs) \
125                 $(use_enable afs krb5afspts) \
126                 $(use_enable backup) \
127                 $(use_enable calalarm calalarmd) \
128                 $(use_with caps libcap) \
129                 $(use_with clamav) \
130                 $(use_enable nntp) \
131                 $(use_enable http) \
132                 $(use_enable replication) \
133                 $(use_enable kerberos gssapi) \
134                 $(use_with ldap) \
135                 $(use_with lmdb) \
136                 $(use_with mysql) \
137                 $(use_with postgres pgsql) \
138                 $(use_with perl) \
139                 $(use_with sqlite) \
140                 $(use_with ssl openssl) \
141                 $(use_enable server) \
142                 $(use_enable sieve) \
143                 $(use_with snmp) \
144                 $(use_enable static-libs static) \
145                 $(use_with tcpd libwrap) \
146                 $(use_enable xapian) \
147                 ${myconf}
148 }
149
150 src_install() {
151         emake DESTDIR="${D}" INSTALLDIRS=vendor install
152
153         dodoc README*
154         dodoc -r doc
155         cp -r contrib tools "${D}/usr/share/doc/${PF}"
156         rm -f doc/text/Makefile*
157
158         mv "${D}"usr/libexec/{master,cyrusmaster} || die
159
160         insinto /etc
161         newins "${D}usr/share/doc/${PF}/doc/examples/cyrus_conf/normal.conf" cyrus.conf
162         newins "${D}usr/share/doc/${PF}/doc/examples/imapd_conf/normal.conf" imapd.conf
163
164         sed -i -e '/^configdirectory/s|/var/.*|/var/imap|' \
165                 -e '/^partition-default/s|/var/.*|/var/spool/imap|' \
166                 -e '/^sievedir/s|/var/.*|/var/imap/sieve|' \
167                 "${D}"etc/imapd.conf
168
169         sed -i -e 's|/var/imap/socket/lmtp|/run/cyrus/socket/lmtp|' \
170                 -e 's|/var/imap/socket/notify|/run/cyrus/socket/notify|' \
171                 "${D}"etc/cyrus.conf
172
173         # turn off sieve if not installed
174         if ! use sieve; then
175                 sed -i -e "/sieve/s/^/#/" "${D}/etc/cyrus.conf" || die
176         fi
177         # same thing for http(s) as well
178         if ! use http; then
179                 sed -i -e "/http/s/^/#/" "${D}/etc/cyrus.conf" || die
180         fi
181
182         newinitd "${FILESDIR}/cyrus.rc8" cyrus
183         newconfd "${FILESDIR}/cyrus.confd" cyrus
184         newpamd "${FILESDIR}/cyrus.pam-include" sieve
185
186         for subdir in imap/{,db,log,msg,proc,socket,sieve} spool/imap/{,stage.} ; do
187                 keepdir "/var/${subdir}"
188                 fowners cyrus:mail "/var/${subdir}"
189                 fperms 0750 "/var/${subdir}"
190         done
191         for subdir in imap/{user,quota,sieve} spool/imap ; do
192                 for i in a b c d e f g h i j k l m n o p q r s t v u w x y z ; do
193                         keepdir "/var/${subdir}/${i}"
194                         fowners cyrus:mail "/var/${subdir}/${i}"
195                         fperms 0750 "/var/${subdir}/${i}"
196                 done
197         done
198 }
199
200 pkg_preinst() {
201         if ! has_version ${CATEGORY}/${PN} ; then
202                 elog "For correct logging add the following to /etc/syslog.conf:"
203                 elog "    local6.*         /var/log/imapd.log"
204                 elog "    auth.debug       /var/log/auth.log"
205                 echo
206
207                 elog "You have to add user cyrus to the sasldb2. Do this with:"
208                 elog "    saslpasswd2 cyrus"
209         fi
210 }
211
212 pkg_postinst() {
213         # do not install server.{key,pem) if they exist
214         if use ssl ; then
215                 if [ ! -f "${ROOT}"etc/ssl/cyrus/server.key ]; then
216                         install_cert /etc/ssl/cyrus/server
217                         chown cyrus:mail "${ROOT}"etc/ssl/cyrus/server.{key,pem}
218                 fi
219         fi
220
221         echo
222         einfo "Please see https://www.cyrusimap.org/imap/download/upgrade.html"
223         einfo "for upgrade instructions."
224         echo
225 }