mail-client/mutt: add back ~x86-fbsd keyword after masking USE=notmuch, bug #587560
[gentoo.git] / mail-client / mutt / mutt-1.7.2.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="6"
6
7 inherit eutils flag-o-matic autotools
8
9 PATCHREV="r1"
10 PATCHSET="gentoo-${PVR}/${PATCHREV}"
11
12 DESCRIPTION="A small but very powerful text-based mail client"
13 HOMEPAGE="http://www.mutt.org/"
14 MUTT_G_PATCHES="mutt-gentoo-${PV}-patches-${PATCHREV}.tar.xz"
15 SRC_URI="ftp://ftp.mutt.org/pub/mutt/${P}.tar.gz
16         https://bitbucket.org/${PN}/${PN}/downloads/${P}.tar.gz
17         https://dev.gentoo.org/~grobian/distfiles/${MUTT_G_PATCHES}"
18 IUSE="berkdb crypt debug doc gdbm gnutls gpg idn imap kerberos libressl mbox nls nntp notmuch pop qdbm sasl selinux sidebar slang smime smtp ssl tokyocabinet vanilla"
19 SLOT="0"
20 LICENSE="GPL-2"
21 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~x64-freebsd ~x86-freebsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
22 CDEPEND="
23         app-misc/mime-types
24         nls? ( virtual/libintl )
25         tokyocabinet?  ( dev-db/tokyocabinet )
26         !tokyocabinet? (
27                 qdbm?  ( dev-db/qdbm )
28                 !qdbm? (
29                         gdbm?  ( sys-libs/gdbm )
30                         !gdbm? ( berkdb? ( >=sys-libs/db-4:= ) )
31                 )
32         )
33         imap?    (
34                 gnutls?  ( >=net-libs/gnutls-1.0.17:= )
35                 !gnutls? (
36                         ssl? (
37                                 !libressl? ( >=dev-libs/openssl-0.9.6:0= )
38                                 libressl? ( dev-libs/libressl:= )
39                         )
40                 )
41                 sasl?    ( >=dev-libs/cyrus-sasl-2 )
42         )
43         kerberos? ( virtual/krb5 )
44         pop?     (
45                 gnutls?  ( >=net-libs/gnutls-1.0.17:= )
46                 !gnutls? (
47                         ssl? (
48                                 !libressl? ( >=dev-libs/openssl-0.9.6:0= )
49                                 libressl? ( dev-libs/libressl:= )
50                         )
51                 )
52                 sasl?    ( >=dev-libs/cyrus-sasl-2 )
53         )
54         smtp?     (
55                 gnutls?  ( >=net-libs/gnutls-1.0.17:= )
56                 !gnutls? (
57                         ssl? (
58                                 !libressl? ( >=dev-libs/openssl-0.9.6:0= )
59                                 libressl? ( dev-libs/libressl:= )
60                         )
61                 )
62                 sasl?    ( >=dev-libs/cyrus-sasl-2 )
63         )
64         idn?     ( net-dns/libidn )
65         gpg?     ( >=app-crypt/gpgme-0.9.0:= )
66         smime?   (
67                 !libressl? ( >=dev-libs/openssl-0.9.6:0= )
68                 libressl? ( dev-libs/libressl:= )
69         )
70         notmuch? ( net-mail/notmuch:= )
71         slang? ( sys-libs/slang )
72         !slang? ( >=sys-libs/ncurses-5.2:0= )
73 "
74 DEPEND="${CDEPEND}
75         net-mail/mailbase
76         doc? (
77                 dev-libs/libxml2
78                 dev-libs/libxslt
79                 app-text/docbook-xsl-stylesheets
80                 || ( www-client/lynx www-client/w3m www-client/elinks )
81         )"
82 RDEPEND="${CDEPEND}
83         selinux? ( sec-policy/selinux-mutt )
84 "
85
86 src_prepare() {
87         local PATCHDIR="${WORKDIR}"/gentoo-mutt-${PV}-patches
88
89         if use !vanilla ; then
90                 # apply patches
91                 export EPATCH_FORCE="yes"
92                 export EPATCH_SUFFIX="patch"
93                 local patches=(
94                         patches-mutt
95                         bugs-gentoo
96                         features-common
97                         features-extra
98                         gentoo
99                 )
100                 local patchset
101                 for patchset in "${patches[@]}" ; do
102                         einfo "Applying ${PATCHSET} patchset ${patchset}"
103                         EPATCH_SOURCE="${PATCHDIR}"/${patchset} epatch \
104                                 || die "patchset ${patchset} failed"
105                 done
106                 # add some explanation as to why not to go upstream
107                 sed -i \
108                         -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\\' \
109                         main.c || die "Failed to add bug instructions"
110         fi
111
112         local upatches=
113         # allow user patches
114         eapply_user && upatches=" with user patches"
115
116         # patch version string for bug reports
117         local patchset=
118         use vanilla || patchset=", ${PATCHSET}"
119         sed -i -e 's|"Mutt %s (%s)"|"Mutt %s (%s'"${patchset}${upatches}"')"|' \
120                 muttlib.c || die "failed patching in Gentoo version"
121
122         # many patches touch the buildsystem, we always need this
123         AT_M4DIR="m4" eautoreconf
124
125         # the configure script contains some "cleverness" whether or not to setgid
126         # the dotlock program, resulting in bugs like #278332
127         sed -i -e 's/@DOTLOCK_GROUP@//' \
128                 Makefile.in || die "sed failed"
129 }
130
131 src_configure() {
132         local myconf=(
133                 "$(use_enable crypt pgp)"
134                 "$(use_enable debug)"
135                 "$(use_enable doc)"
136                 "$(use_enable gpg gpgme)"
137                 "$(use_enable imap)"
138                 "$(use_enable nls)"
139                 "$(use_enable nntp)"
140                 "$(use_enable pop)"
141                 "$(use_enable sidebar)"
142                 "$(use_enable smime)"
143                 "$(use_enable smtp)"
144                 "$(use_enable notmuch)"
145                 "$(use_with idn)"
146                 "$(use_with kerberos gss)"
147                 "--with-$(use slang && echo slang || echo curses)=${EPREFIX}/usr"
148                 "--enable-compressed"
149                 "--enable-external-dotlock"
150                 "--enable-nfs-fix"
151                 "--sysconfdir=${EPREFIX}/etc/${PN}"
152                 "--with-docdir=${EPREFIX}/usr/share/doc/${PN}-${PVR}"
153                 "--with-regex"
154                 "--with-exec-shell=${EPREFIX}/bin/sh"
155         )
156
157         if [[ ${CHOST} == *-solaris* ]] ; then
158                 # arrows in index view do not show when using wchar_t
159                 myconf+=( "--without-wc-funcs" )
160         fi
161
162         # mutt prioritizes gdbm over bdb, so we will too.
163         # hcache feature requires at least one database is in USE.
164         local hcaches=(
165                 "tokyocabinet"
166                 "qdbm"
167                 "gdbm"
168                 "berkdb:bdb"
169         )
170         local ucache hcache lcache
171         for hcache in "${hcaches[@]}" ; do
172                 if use ${hcache%%:*} ; then
173                         ucache=${hcache}
174                         break
175                 fi
176         done
177         if [[ -n ${ucache} ]] ; then
178                 myconf+=( "--enable-hcache" )
179         else
180                 myconf+=( "--disable-hcache" )
181         fi
182         for hcache in "${hcaches[@]}" ; do
183                 [[ ${hcache} == ${ucache} ]] \
184                         && myconf+=( "--with-${hcache#*:}" ) \
185                         || myconf+=( "--without-${hcache#*:}" )
186         done
187
188         # there's no need for gnutls, ssl or sasl without socket support
189         if use pop || use imap || use smtp ; then
190                 if use gnutls; then
191                         myconf+=( "--with-gnutls" )
192                 elif use ssl; then
193                         myconf+=( "--with-ssl" )
194                 fi
195                 # not sure if this should be mutually exclusive with the other two
196                 myconf+=( "$(use_with sasl)" )
197         else
198                 myconf+=(
199                         "--without-gnutls"
200                         "--without-ssl"
201                         "--without-sasl"
202                 )
203         fi
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[@]}" || die "configure failed"
212 }
213
214 src_install() {
215         emake DESTDIR="${D}" install || die "install failed"
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 /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 || die
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
237                 cp doc/muttbug.man flea.1
238                 cp doc/muttrc.man muttrc.5
239                 doman mutt.1 flea.1 muttrc.5
240         else
241                 # nuke manpages that should be provided by an MTA, bug #177605
242                 rm "${ED}"/usr/share/man/man5/{mbox,mmdf}.5 \
243                         || ewarn "failed to remove files, please file a bug"
244         fi
245
246         if use !prefix ; then
247                 fowners root:mail /usr/bin/mutt_dotlock
248                 fperms g+s /usr/bin/mutt_dotlock
249         fi
250
251         dodoc BEWARE COPYRIGHT ChangeLog NEWS OPS* PATCHES README* TODO VERSION
252 }
253
254 pkg_postinst() {
255         if [[ -z ${REPLACING_VERSIONS} ]] ; then
256                 echo
257                 elog "If you are new to mutt you may want to take a look at"
258                 elog "the Gentoo QuickStart Guide to Mutt E-Mail:"
259                 elog "   https://wiki.gentoo.org/wiki/Mutt"
260                 echo
261         else
262                 local ver
263                 local preconddate=
264                 for ver in ${REPLACING_VERSIONS} ; do
265                         [[ ${ver} == "1.5"* || ${ver} == "1.6"* ]] && preconddate=true
266                 done
267                 if [[ -n ${preconddate} ]] ; then
268                         echo
269                         elog "The SmartTime functionality has been replaced with"
270                         elog "CondDate feature.  To mimic SmartTime, use this CondDate formatter:"
271                         elog "%<[12m?%<[7d?%<[12H?%[%H:%M ]&%[%a-%d]>&%[%d-%b]>&%[%b-%y]>"
272                         echo
273                 fi
274         fi
275 }