net-mail/rss2email: x86 stable wrt bug #721418
[gentoo.git] / net-mail / dovecot / dovecot-2.3.10.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 # do not add a ssl USE flag.  ssl is mandatory
7 SSL_DEPS_SKIP=1
8 inherit autotools ssl-cert systemd toolchain-funcs
9
10 MY_P="${P/_/.}"
11 #MY_S="${PN}-ce-${PV}"
12 major_minor="$(ver_cut 1-2)"
13 sieve_version="0.5.10"
14 if [[ ${PV} == *_rc* ]] ; then
15         rc_dir="rc/"
16 else
17         rc_dir=""
18 fi
19 SRC_URI="https://dovecot.org/releases/${major_minor}/${rc_dir}${MY_P}.tar.gz
20         sieve? (
21         https://pigeonhole.dovecot.org/releases/${major_minor}/${rc_dir}${PN}-${major_minor}-pigeonhole-${sieve_version}.tar.gz
22         )
23         managesieve? (
24         https://pigeonhole.dovecot.org/releases/${major_minor}/${rc_dir}${PN}-${major_minor}-pigeonhole-${sieve_version}.tar.gz
25         ) "
26 DESCRIPTION="An IMAP and POP3 server written with security primarily in mind"
27 HOMEPAGE="https://www.dovecot.org/"
28
29 SLOT="0"
30 LICENSE="LGPL-2.1 MIT"
31 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
32
33 IUSE_DOVECOT_AUTH="kerberos ldap lua mysql pam postgres sqlite vpopmail"
34 IUSE_DOVECOT_COMPRESS="bzip2 lzma lz4 zlib"
35 IUSE_DOVECOT_OTHER="argon2 caps doc ipv6 libressl lucene managesieve selinux sieve solr static-libs suid tcpd textcat"
36
37 IUSE="${IUSE_DOVECOT_AUTH} ${IUSE_DOVECOT_COMPRESS} ${IUSE_DOVECOT_OTHER}"
38
39 DEPEND="argon2? ( dev-libs/libsodium )
40         bzip2? ( app-arch/bzip2 )
41         caps? ( sys-libs/libcap )
42         kerberos? ( virtual/krb5 )
43         ldap? ( net-nds/openldap )
44         lua? ( dev-lang/lua:* )
45         lucene? ( >=dev-cpp/clucene-2.3 )
46         lzma? ( app-arch/xz-utils )
47         lz4? ( app-arch/lz4 )
48         mysql? ( dev-db/mysql-connector-c:0= )
49         pam? ( sys-libs/pam )
50         postgres? ( dev-db/postgresql:* !dev-db/postgresql[ldap,threads] )
51         selinux? ( sec-policy/selinux-dovecot )
52         solr? ( net-misc/curl dev-libs/expat )
53         sqlite? ( dev-db/sqlite:* )
54         !libressl? ( dev-libs/openssl:0= )
55         libressl? ( dev-libs/libressl:0= )
56         suid? ( acct-group/mail )
57         tcpd? ( sys-apps/tcp-wrappers )
58         textcat? ( app-text/libexttextcat )
59         vpopmail? ( net-mail/vpopmail )
60         zlib? ( sys-libs/zlib )
61         virtual/libiconv
62         dev-libs/icu:="
63
64 RDEPEND="${DEPEND}
65         acct-group/dovecot
66         acct-group/dovenull
67         acct-user/dovecot
68         acct-user/dovenull
69         net-mail/mailbase"
70
71 pkg_setup() {
72         if use managesieve && ! use sieve; then
73                 ewarn "managesieve USE flag selected but sieve USE flag unselected"
74                 ewarn "sieve USE flag will be turned on"
75         fi
76 }
77
78 src_prepare() {
79         default
80         # bug 657108
81         elibtoolize
82         #eautoreconf
83 }
84
85 src_configure() {
86         local conf=""
87
88         if use postgres || use mysql || use sqlite; then
89                 conf="${conf} --with-sql"
90         fi
91
92         # turn valgrind tests off. Bug #340791
93         VALGRIND=no econf \
94                 --with-rundir="${EPREFIX}/run/dovecot" \
95                 --with-statedir="${EPREFIX}/var/lib/dovecot" \
96                 --with-moduledir="${EPREFIX}/usr/$(get_libdir)/dovecot" \
97                 --without-stemmer \
98                 --disable-rpath \
99                 --without-libbsd \
100                 --with-icu \
101                 --with-ssl \
102                 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
103                 $( use_with argon2 sodium ) \
104                 $( use_with bzip2 bzlib ) \
105                 $( use_with caps libcap ) \
106                 $( use_with kerberos gssapi ) \
107                 $( use_with lua ) \
108                 $( use_with ldap ) \
109                 $( use_with lucene ) \
110                 $( use_with lz4 ) \
111                 $( use_with lzma ) \
112                 $( use_with mysql ) \
113                 $( use_with pam ) \
114                 $( use_with postgres pgsql ) \
115                 $( use_with sqlite ) \
116                 $( use_with solr ) \
117                 $( use_with tcpd libwrap ) \
118                 $( use_with textcat ) \
119                 $( use_with vpopmail ) \
120                 $( use_with zlib ) \
121                 $( use_enable static-libs static ) \
122                 ${conf}
123
124         if use sieve || use managesieve ; then
125                 # The sieve plugin needs this file to be build to determine the plugin
126                 # directory and the list of libraries to link to.
127                 emake dovecot-config
128                 cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
129                 econf \
130                         $( use_enable static-libs static ) \
131                         --localstatedir="${EPREFIX}/var" \
132                         --enable-shared \
133                         --with-dovecot="${S}" \
134                         $( use_with managesieve )
135         fi
136 }
137
138 src_compile() {
139         default
140         if use sieve || use managesieve ; then
141                 cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
142                 emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"
143         fi
144 }
145
146 src_test() {
147         default
148         if use sieve || use managesieve ; then
149                 cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
150                 default
151         fi
152 }
153
154 src_install() {
155         default
156
157         # insecure:
158         # use suid && fperms u+s /usr/libexec/dovecot/deliver
159         # better:
160         if use suid;then
161                 einfo "Changing perms to allow deliver to be suided"
162                 fowners root:mail "/usr/libexec/dovecot/dovecot-lda"
163                 fperms 4750 "/usr/libexec/dovecot/dovecot-lda"
164         fi
165
166         newinitd "${FILESDIR}"/dovecot.init-r6 dovecot
167
168         rm -rf "${ED}"/usr/share/doc/dovecot
169
170         dodoc AUTHORS NEWS README TODO
171         dodoc doc/*.{txt,cnf,xml,sh}
172         docinto example-config
173         dodoc doc/example-config/*.{conf,ext}
174         docinto example-config/conf.d
175         dodoc doc/example-config/conf.d/*.{conf,ext}
176         docinto wiki
177         dodoc doc/wiki/*
178         doman doc/man/*.{1,7}
179
180         # Create the dovecot.conf file from the dovecot-example.conf file that
181         # the dovecot folks nicely left for us....
182         local conf="${ED}/etc/dovecot/dovecot.conf"
183         local confd="${ED}/etc/dovecot/conf.d"
184
185         insinto /etc/dovecot
186         doins doc/example-config/*.{conf,ext}
187         insinto /etc/dovecot/conf.d
188         doins doc/example-config/conf.d/*.{conf,ext}
189         fperms 0600 /etc/dovecot/dovecot-{ldap,sql}.conf.ext
190         rm -f "${confd}/../README"
191
192         # .maildir is the Gentoo default
193         local mail_location="maildir:~/.maildir"
194         sed -i -e \
195                 "s|#mail_location =|mail_location = ${mail_location}|" \
196                 "${confd}/10-mail.conf" \
197                 || die "failed to update mail location settings in 10-mail.conf"
198
199         # We're using pam files (imap and pop3) provided by mailbase
200         if use pam; then
201                 sed -i -e '/driver = pam/,/^[ \t]*}/ s|#args = dovecot|args = "\*"|' \
202                         "${confd}/auth-system.conf.ext" \
203                         || die "failed to update PAM settings in auth-system.conf.ext"
204                 # mailbase does not provide a sieve pam file
205                 use managesieve && dosym imap /etc/pam.d/sieve
206                 sed -i -e \
207                         's/#!include auth-system.conf.ext/!include auth-system.conf.ext/' \
208                         "${confd}/10-auth.conf" \
209                         || die "failed to update PAM settings in 10-auth.conf"
210         fi
211
212         # Disable ipv6 if necessary
213         if ! use ipv6; then
214                 sed -i -e 's/^#listen = \*, ::/listen = \*/g' "${conf}" \
215                         || die "failed to update listen settings in dovecot.conf"
216         fi
217
218         # Update ssl cert locations
219         sed -i -e 's:^#ssl = yes:ssl = yes:' "${confd}/10-ssl.conf" \
220                 || die "ssl conf failed"
221         sed -i -e 's:^ssl_cert =.*:ssl_cert = </etc/ssl/dovecot/server.pem:' \
222                 -e 's:^ssl_key =.*:ssl_key = </etc/ssl/dovecot/server.key:' \
223                 "${confd}/10-ssl.conf" || die "failed to update SSL settings in 10-ssl.conf"
224
225         # Install SQL configuration
226         if use mysql || use postgres; then
227                 sed -i -e \
228                         's/#!include auth-sql.conf.ext/!include auth-sql.conf.ext/' \
229                         "${confd}/10-auth.conf" || die "failed to update SQL settings in \
230                         10-auth.conf"
231         fi
232
233         # Install LDAP configuration
234         if use ldap; then
235                 sed -i -e \
236                         's/#!include auth-ldap.conf.ext/!include auth-ldap.conf.ext/' \
237                         "${confd}/10-auth.conf" \
238                         || die "failed to update ldap settings in 10-auth.conf"
239         fi
240
241         if use vpopmail; then
242                 sed -i -e \
243                         's/#!include auth-vpopmail.conf.ext/!include auth-vpopmail.conf.ext/' \
244                         "${confd}/10-auth.conf" \
245                         || die "failed to update vpopmail settings in 10-auth.conf"
246         fi
247
248         if use sieve || use managesieve ; then
249                 cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
250                 emake DESTDIR="${ED}" install
251                 sed -i -e \
252                         's/^[[:space:]]*#mail_plugins = $mail_plugins/mail_plugins = sieve/' "${confd}/15-lda.conf" \
253                         || die "failed to update sieve settings in 15-lda.conf"
254                 rm -rf "${ED}"/usr/share/doc/dovecot
255                 docinto example-config/conf.d
256                 dodoc doc/example-config/conf.d/*.conf
257                 insinto /etc/dovecot/conf.d
258                 doins doc/example-config/conf.d/90-sieve{,-extprograms}.conf
259                 use managesieve && doins doc/example-config/conf.d/20-managesieve.conf
260                 docinto sieve/rfc
261                 dodoc doc/rfc/*.txt
262                 docinto sieve/devel
263                 dodoc doc/devel/DESIGN
264                 docinto plugins
265                 dodoc doc/plugins/*.txt
266                 docinto extensions
267                 dodoc doc/extensions/*.txt
268                 docinto locations
269                 dodoc doc/locations/*.txt
270                 doman doc/man/*.{1,7}
271         fi
272
273         use static-libs || find "${ED}"/usr/lib* -name '*.la' -delete
274 }
275
276 pkg_postinst() {
277         # Let's not make a new certificate if we already have one
278         if ! [[ -e "${ROOT}"/etc/ssl/dovecot/server.pem && \
279                 -e "${ROOT}"/etc/ssl/dovecot/server.key ]];     then
280                 einfo "Creating SSL     certificate"
281                 SSL_ORGANIZATION="${SSL_ORGANIZATION:-Dovecot IMAP Server}"
282                 install_cert /etc/ssl/dovecot/server
283         fi
284
285         elog "Please read https://doc.dovecot.org/installation_guide/upgrading/ for upgrade notes."
286 }