*/*: [QA] Remove redundant `|| die` guards
[gentoo.git] / mail-client / mutt / mutt-1.10.1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit eutils flag-o-matic autotools
7
8 PATCHREV="r0"
9 PATCHSET="gentoo-${PVR}/${PATCHREV}"
10
11 DESCRIPTION="A small but very powerful text-based mail client"
12 HOMEPAGE="http://www.mutt.org/"
13 MUTT_G_PATCHES="mutt-gentoo-${PV}-patches-${PATCHREV}.tar.xz"
14 SRC_URI="ftp://ftp.mutt.org/pub/mutt/${P}.tar.gz
15         https://bitbucket.org/${PN}/${PN}/downloads/${P}.tar.gz
16         https://dev.gentoo.org/~grobian/distfiles/${MUTT_G_PATCHES}"
17 IUSE="berkdb crypt debug doc gdbm gnutls gpg gpgme +hcache idn +imap kerberos libressl +lmdb mbox nls nntp notmuch pgp_classic pop qdbm +sasl selinux slang smime smime_classic +smtp +ssl tokyocabinet vanilla prefix"
18 # hcache: allow multiple, bug #607360
19 REQUIRED_USE="
20         hcache?           ( || ( berkdb gdbm lmdb qdbm tokyocabinet ) )
21         imap?             ( ssl )
22         pop?              ( ssl )
23         nntp?             ( ssl )
24         smime?            ( ssl !gnutls )
25         smime_classic?    ( ssl !gnutls )
26         smtp?             ( ssl sasl )
27         sasl?             ( || ( imap pop smtp nntp ) )
28         kerberos?         ( || ( imap pop smtp nntp ) )"
29 SLOT="0"
30 LICENSE="GPL-2"
31 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
32 # yes, we overdepend on the backend impls here, hopefully one day we can
33 # have REQUIRED_USE do what it is made for again. bug #607360
34 CDEPEND="
35         app-misc/mime-types
36
37         berkdb?        ( >=sys-libs/db-4:= )
38         gdbm?          ( sys-libs/gdbm )
39         lmdb?          ( dev-db/lmdb:= )
40         qdbm?          ( dev-db/qdbm )
41         tokyocabinet?  ( dev-db/tokyocabinet )
42
43         ssl? (
44                 gnutls?    ( >=net-libs/gnutls-1.0.17:= )
45                 !gnutls? (
46                         libressl? ( dev-libs/libressl:= )
47                         !libressl? ( >=dev-libs/openssl-0.9.6:0= )
48                 )
49         )
50
51         nls?           ( virtual/libintl )
52         sasl?          ( >=dev-libs/cyrus-sasl-2 )
53         kerberos?      ( virtual/krb5 )
54         idn?           ( net-dns/libidn2 )
55         gpg?           ( >=app-crypt/gpgme-0.9.0:= )
56         gpgme?         ( >=app-crypt/gpgme-0.9.0:= )
57         notmuch?       ( net-mail/notmuch:= )
58         slang?         ( sys-libs/slang )
59         !slang?        ( >=sys-libs/ncurses-5.2:0= )
60 "
61 DEPEND="${CDEPEND}
62         net-mail/mailbase
63         doc? (
64                 dev-libs/libxml2
65                 dev-libs/libxslt
66                 app-text/docbook-xsl-stylesheets
67                 || ( www-client/lynx www-client/w3m www-client/elinks )
68         )"
69 RDEPEND="${CDEPEND}
70         selinux? ( sec-policy/selinux-mutt )
71         smime? ( || ( dev-libs/libressl >=dev-libs/openssl-0.9.6:0 ) )
72         smime_classic? ( || ( dev-libs/libressl >=dev-libs/openssl-0.9.6:0 ) )
73         crypt? ( app-crypt/gnupg )
74         pgp_classic? ( app-crypt/gnupg )
75 "
76
77 src_prepare() {
78         local PATCHDIR="${WORKDIR}"/mutt-gentoo-${PV}-patches-${PATCHREV}
79
80         if use !vanilla ; then
81                 # apply patches
82                 export EPATCH_FORCE="yes"
83                 export EPATCH_SUFFIX="patch"
84                 # http://hg.code.sf.net/p/gentoomuttpatches/code/file/mutt-1.10
85                 local patches=(
86                         patches-mutt
87                         bugs-gentoo
88                         features-common
89                         features-extra
90                         gentoo
91                 )
92                 local patchset
93                 for patchset in "${patches[@]}" ; do
94                         [[ -d "${PATCHDIR}/${patchset}" ]] || continue
95                         einfo "Patches for ${PATCHSET} patchset ${patchset}"
96                         EPATCH_SOURCE="${PATCHDIR}"/${patchset} epatch \
97                                 || die "patchset ${patchset} failed"
98                 done
99                 # add some explanation as to why not to go upstream
100                 sed -i \
101                         -e '/ReachingUs = N_(/aThis release of Mutt is heavily enriched with patches.\\nFor this reason, any bugs are better reported at https://bugs.gentoo.org/\\nor re-emerge with USE=vanilla and try to reproduce your problem.\\n\\' \
102                         main.c || die "Failed to add bug instructions"
103         fi
104
105         local upatches=
106         # allow user patches
107         eapply_user && upatches=" with user patches"
108
109         # patch version string for bug reports
110         local patchset=
111         use vanilla || patchset=", ${PATCHSET}"
112         sed -i -e 's|"Mutt %s (%s)"|"Mutt %s (%s'"${patchset}${upatches}"')"|' \
113                 muttlib.c || die "failed patching in Gentoo version"
114
115         # many patches touch the buildsystem, we always need this
116         AT_M4DIR="m4" eautoreconf
117
118         # the configure script contains some "cleverness" whether or not to setgid
119         # the dotlock program, resulting in bugs like #278332
120         sed -i -e 's/@DOTLOCK_GROUP@//' Makefile.in || die "sed failed"
121 }
122
123 src_configure() {
124         local myconf=(
125                 # signing and encryption
126                 # clumpsy blocks for transition period of USE-flag renames
127                 $(use crypt         && use_enable crypt pgp)
128                 $(use pgp_classic   && use_enable pgp_classic pgp)
129                 $(use !crypt && use !pgp_classic && echo "--disable-pgp")
130
131                 $(use smime         && use_enable smime)
132                 $(use smime_classic && use_enable smime_classic smime)
133                 $(use !smime && use !smime_classic && echo "--disable-smime")
134
135                 $(use gpg           && use_enable gpg gpgme)
136                 $(use gpgme         && use_enable gpgme)
137                 $(use !gpg && use !gpgme && echo "--disable-gpgme")
138
139                 # features
140                 $(use_enable debug)
141                 $(use_enable doc)
142                 $(use_enable nls)
143                 $(use_enable notmuch)
144
145                 # protocols
146                 $(use_enable imap)
147                 $(use_enable pop)
148                 $(use_enable nntp)
149                 $(use_enable smtp)
150
151                 $(use  ssl && use  gnutls && echo --with-gnutls    --without-ssl)
152                 $(use  ssl && use !gnutls && echo --without-gnutls --with-ssl   )
153                 $(use !ssl &&                echo --without-gnutls --without-ssl)
154
155                 $(use_with sasl)
156                 $(use_with idn) --without-idn  # avoid automagic libidn dep
157                 $(use_with kerberos gss)
158                 "$(use slang && echo --with-slang="${EPREFIX}"/usr || echo a=b)"
159                 "$(use_with !slang curses "${EPREFIX}"/usr)"
160
161                 "--enable-compressed"
162                 "--enable-external-dotlock"
163                 "--enable-nfs-fix"
164                 "--enable-sidebar"
165                 "--sysconfdir=${EPREFIX}/etc/${PN}"
166                 "--with-docdir=${EPREFIX}/usr/share/doc/${PN}-${PVR}"
167                 "--with-regex"
168                 "--with-exec-shell=${EPREFIX}/bin/sh"
169         )
170
171         if [[ ${CHOST} == *-solaris2.* && ${CHOST#*-solaris2.} -le 10 ]] ; then
172                 # arrows in index view do not show when using wchar_t
173                 # or misalign due to wrong computations
174                 myconf+=( "--without-wc-funcs" )
175         fi
176
177         # note: REQUIRED_USE should have selected only one of these, but for
178         # bug #607360 we're forced to allow multiple.  For that reason, this
179         # list is ordered to preference, and only the first is taken.
180         local hcaches=(
181                 "lmdb"
182                 "qdbm"
183                 "tokyocabinet"
184                 "gdbm"
185                 "berkdb:bdb"
186         )
187         local ucache hcache lcache
188         for hcache in "${hcaches[@]}" ; do
189                 if use ${hcache%%:*} ; then
190                         ucache=${hcache}
191                         break
192                 fi
193         done
194         if [[ -n ${ucache} ]] ; then
195                 myconf+=( "--enable-hcache" )
196         else
197                 myconf+=( "--disable-hcache" )
198         fi
199         for hcache in "${hcaches[@]}" ; do
200                 [[ ${hcache} == ${ucache} ]] \
201                         && myconf+=( "--with-${hcache#*:}" ) \
202                         || myconf+=( "--without-${hcache#*:}" )
203         done
204
205         if use mbox; then
206                 myconf+=( "--with-mailpath=${EPREFIX}/var/spool/mail" )
207         else
208                 myconf+=( "--with-homespool=Maildir" )
209         fi
210
211         econf "${myconf[@]}"
212 }
213
214 src_install() {
215         emake DESTDIR="${D}" install
216         if use mbox; then
217                 insinto /etc/mutt
218                 newins "${FILESDIR}"/Muttrc.mbox Muttrc
219         else
220                 insinto /etc/mutt
221                 doins "${FILESDIR}"/Muttrc
222         fi
223
224         # A newer file is provided by app-misc/mime-types. So we link it.
225         rm "${ED}"/etc/${PN}/mime.types
226         dosym "${EPREFIX}"/etc/mime.types /etc/${PN}/mime.types
227
228         # A man-page is always handy, so fake one
229         if use !doc; then
230                 emake -C doc DESTDIR="${D}" muttrc.man
231                 # make the fake slightly better, bug #413405
232                 sed -e 's#@docdir@/manual.txt#http://www.mutt.org/doc/devel/manual.html#' \
233                         -e 's#in @docdir@,#at http://www.mutt.org/,#' \
234                         -e "s#@sysconfdir@#${EPREFIX}/etc/${PN}#" \
235                         -e "s#@bindir@#${EPREFIX}/usr/bin#" \
236                         doc/mutt.man > mutt.1 || die
237                 cp doc/muttrc.man muttrc.5 || die
238                 doman mutt.1 muttrc.5
239         else
240                 # nuke manpages that should be provided by an MTA, bug #177605
241                 rm "${ED}"/usr/share/man/man5/{mbox,mmdf}.5 \
242                         || ewarn "failed to remove files, please file a bug"
243         fi
244
245         if use !prefix ; then
246                 fowners root:mail /usr/bin/mutt_dotlock
247                 fperms g+s /usr/bin/mutt_dotlock
248         fi
249
250         dodoc BEWARE COPYRIGHT ChangeLog NEWS OPS* PATCHES README* TODO VERSION
251 }
252
253 pkg_postinst() {
254         if [[ -z ${REPLACING_VERSIONS} ]] ; then
255                 echo
256                 elog "If you are new to mutt you may want to take a look at"
257                 elog "the Gentoo QuickStart Guide to Mutt E-Mail:"
258                 elog "   https://wiki.gentoo.org/wiki/Mutt"
259                 echo
260         fi
261         if use crypt || use gpg || use smime ; then
262                 ewarn "Please note that the crypto related USE-flags of mutt have changed."
263                 ewarn "To remove some unclarity, the following USE-flags are renamed:"
264                 ewarn "(see https://bugs.gentoo.org/637176)"
265                 ewarn "  crypt -> pgp_classic"
266                 ewarn "  gpg   -> gpgme"
267                 ewarn "  smime -> smime_classic"
268                 ewarn "The old USE flags still work but their use is deprecated and will"
269                 ewarn "be removed in a future release.  Please update your package.use"
270                 if use gpg && ( use crypt || use smime ) ; then
271                         ewarn "  Note that gpgme (old gpg) includes both pgp and smime"
272                         ewarn "  support.  You can probably remove pgp_classic (old crypt)"
273                         ewarn "  and smime_classic (old smime) from your USE-flags and"
274                         ewarn "  only enable gpgme."
275                 fi
276         fi
277         if use gpgme ; then
278                 ewarn "Note: in order for Mutt to actually use the gpgme backend"
279                 ewarn "      you MUST include 'set crypt_use_gpgme=yes' in .muttrc"
280                 ewarn "      https://www.mutt.org/doc/manual/#crypt-use-gpgme"
281         fi
282 }