86c5a843c02f7672ba1b2d404a2effc89047e7f4
[gentoo.git] / mail-mta / msmtp / msmtp-1.8.3.ebuild
1 # Copyright 2004-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit fcaps multilib user
7
8 DESCRIPTION="An SMTP client and SMTP plugin for mail user agents such as Mutt"
9 HOMEPAGE="https://marlam.de/msmtp/"
10 SRC_URI="https://marlam.de/msmtp/releases/${P}.tar.xz"
11
12 LICENSE="GPL-3"
13 SLOT="0"
14 KEYWORDS="~alpha amd64 ~arm ~arm64 ia64 ppc ppc64 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
15 IUSE="daemon doc gnome-keyring idn +mta nls sasl ssl vim-syntax"
16
17 # fcaps.eclass unconditionally defines "filecaps" USE flag which we need for
18 # USE="daemon" in order to set the caps we need.
19 REQUIRED_USE="daemon? ( filecaps )"
20
21 # Upstream discourages usage of openssl. See also
22 # https://marlam.de/msmtp/news/openssl-discouraged/
23 DEPEND="
24         gnome-keyring? ( app-crypt/libsecret )
25         nls? ( virtual/libintl )
26         sasl? ( virtual/gsasl )
27         ssl? ( net-libs/gnutls[idn?] )
28         !ssl? ( idn? ( net-dns/libidn2:= ) )
29 "
30
31 RDEPEND="${DEPEND}
32         net-mail/mailbase
33         mta? (
34                 !mail-mta/courier
35                 !mail-mta/esmtp
36                 !mail-mta/exim
37                 !mail-mta/mini-qmail
38                 !mail-mta/netqmail
39                 !mail-mta/nullmailer
40                 !mail-mta/postfix
41                 !mail-mta/qmail-ldap
42                 !mail-mta/sendmail
43                 !mail-mta/opensmtpd
44                 !<mail-mta/ssmtp-2.64-r2
45                 !>=mail-mta/ssmtp-2.64-r2[mta]
46         )
47 "
48
49 BDEPEND="${DEPEND}
50         doc? ( virtual/texi2dvi )
51         nls? ( sys-devel/gettext )
52         virtual/pkgconfig
53 "
54
55 DOCS="AUTHORS ChangeLog NEWS README THANKS doc/msmtprc*"
56
57 src_prepare() {
58         # Use default Gentoo location for mail aliases
59         sed -i 's:/etc/aliases:/etc/mail/aliases:' scripts/find_alias/find_alias_for_msmtp.sh || die
60
61         default
62 }
63
64 src_configure() {
65         local myeconfargs=(
66                 --disable-gai-idn
67                 $(use_enable nls)
68                 $(use_with daemon msmtpd)
69                 $(use_with gnome-keyring libsecret)
70                 $(use_with idn libidn)
71                 $(use_with sasl libgsasl)
72                 $(use_with ssl tls gnutls)
73         )
74         econf "${myeconfargs[@]}"
75 }
76
77 src_compile() {
78         default
79
80         if use doc ; then
81                 cd doc || die
82                 emake html pdf
83         fi
84 }
85
86 src_install() {
87         default
88
89         if use daemon ; then
90                 fcaps CAP_NET_BIND_SERVICE usr/bin/msmtpd
91                 newinitd "${FILESDIR}"/msmtpd.init msmtpd
92                 newconfd "${FILESDIR}"/msmtpd.confd msmtpd
93         fi
94
95         if use doc ; then
96                 dodoc doc/msmtp.{html,pdf}
97         fi
98
99         if use mta ; then
100                 dosym msmtp /usr/bin/sendmail
101                 dosym ../bin/msmtp /usr/$(get_libdir)/sendmail
102         fi
103
104         if use vim-syntax ; then
105                 insinto /usr/share/vim/vimfiles/syntax
106                 doins scripts/vim/msmtp.vim
107         fi
108
109         insinto /etc
110         newins doc/msmtprc-system.example msmtprc
111
112         src_install_contrib find_alias find_alias_for_msmtp.sh
113         src_install_contrib msmtpqueue "*.sh" "README ChangeLog"
114         src_install_contrib msmtpq "msmtpq msmtp-queue" README.msmtpq
115         src_install_contrib set_sendmail set_sendmail.sh set_sendmail.conf
116 }
117
118 pkg_preinst() {
119         if use daemon ; then
120                 enewuser msmtpd
121         fi
122 }
123
124 pkg_postinst() {
125         if [[ -z ${REPLACING_VERSIONS} ]]; then
126                 einfo "Please edit ${EROOT}/etc/msmtprc before first use."
127                 einfo "In addition, per user configuration files can be placed"
128                 einfo "as '~/.msmtprc'.  See the msmtprc-user.example file under"
129                 einfo "/usr/share/doc/${PF}/ for an example."
130         fi
131 }
132
133 src_install_contrib() {
134         subdir="$1"
135         bins="$2"
136         docs="$3"
137         local dir=/usr/share/${PN}/${subdir}
138         insinto ${dir}
139         exeinto ${dir}
140         for i in ${bins} ; do
141                 doexe scripts/${subdir}/${i}
142         done
143         for i in ${docs} ; do
144                 newdoc scripts/${subdir}/${i} ${subdir}.${i}
145         done
146 }