1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 inherit autotools flag-o-matic pam ssl-cert user
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"
11 LICENSE="BSD-with-attribution GPL-2"
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 )"
22 >=dev-libs/cyrus-sasl-2.1.13:2
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 )
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=] )
48 xapian? ( >=dev-libs/xapian-1.4.0:0= )
51 test? ( dev-util/cunit )
54 # all blockers really needed?
55 # file collision with app-arch/dump - bug 619584
59 !net-mail/courier-imap
71 # https://bugs.gentoo.org/678754
72 # TODO: check underlinking for other libraries
73 PATCHES=( "${FILESDIR}/cyrus-imapd-libcap-libs-r1.patch" )
76 enewuser cyrus -1 -1 /usr/cyrus mail
77 # https://bugs.gentoo.org/604466
78 append-ldflags $(no-as-needed)
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"
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"
95 # lock.h to afs/lock.h
96 sed -i -e '/lock.h/s:lock.h:afs/lock.h:' \
97 ptclient/afskrb.c || die
105 myconf+=" --with-afs-libdir=/usr/$(get_libdir)"
106 myconf+=" --with-afs-incdir=/usr/include/afs"
108 # sphinx is unmaintained and dead, bug #662944
110 --enable-unit-tests \
113 --enable-event-notification \
114 --enable-autocreate \
117 --with-cyrus-user=cyrus \
125 $(use_enable afs krb5afspts) \
126 $(use_enable backup) \
127 $(use_enable calalarm calalarmd) \
128 $(use_with caps libcap) \
132 $(use_enable replication) \
133 $(use_enable kerberos gssapi) \
137 $(use_with postgres pgsql) \
140 $(use_with ssl openssl) \
141 $(use_enable server) \
142 $(use_enable sieve) \
144 $(use_enable static-libs static) \
145 $(use_with tcpd libwrap) \
146 $(use_enable xapian) \
151 emake DESTDIR="${D}" INSTALLDIRS=vendor install
155 cp -r contrib tools "${D}/usr/share/doc/${PF}"
156 rm -f doc/text/Makefile*
158 mv "${D}"usr/libexec/{master,cyrusmaster} || die
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
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|' \
169 sed -i -e 's|/var/imap/socket/lmtp|/run/cyrus/socket/lmtp|' \
170 -e 's|/var/imap/socket/notify|/run/cyrus/socket/notify|' \
173 # turn off sieve if not installed
175 sed -i -e "/sieve/s/^/#/" "${D}/etc/cyrus.conf" || die
177 # same thing for http(s) as well
179 sed -i -e "/http/s/^/#/" "${D}/etc/cyrus.conf" || die
182 newinitd "${FILESDIR}/cyrus.rc8" cyrus
183 newconfd "${FILESDIR}/cyrus.confd" cyrus
184 newpamd "${FILESDIR}/cyrus.pam-include" sieve
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}"
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}"
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"
207 elog "You have to add user cyrus to the sasldb2. Do this with:"
208 elog " saslpasswd2 cyrus"
213 # do not install server.{key,pem) if they exist
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}
222 einfo "Please see https://www.cyrusimap.org/imap/download/upgrade.html"
223 einfo "for upgrade instructions."