*/*: [QA] Use consistent function definition formatting
[gentoo.git] / mail-mta / sendmail / sendmail-8.15.2-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 inherit multilib systemd toolchain-funcs user
6
7 DESCRIPTION="Widely-used Mail Transport Agent (MTA)"
8 HOMEPAGE="http://www.sendmail.org/"
9 SRC_URI="ftp://ftp.sendmail.org/pub/${PN}/${PN}.${PV}.tar.gz"
10
11 LICENSE="Sendmail GPL-2" # GPL-2 is here for initscript
12 SLOT="0"
13 KEYWORDS="~alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86"
14 IUSE="ssl ldap libressl sasl tcpd mbox ipv6 nis sockets"
15
16 DEPEND="net-mail/mailbase
17         sys-devel/m4
18         sasl? ( >=dev-libs/cyrus-sasl-2.1.10 )
19         tcpd? ( sys-apps/tcp-wrappers )
20         ssl? (
21                 !libressl? ( dev-libs/openssl:0= )
22                 libressl? ( dev-libs/libressl:= )
23         )
24         ldap? ( net-nds/openldap )
25         >=sys-libs/db-3.2
26         !net-mail/vacation
27         "
28 RDEPEND="${DEPEND}
29         >=net-mail/mailbase-0.00
30         !mail-mta/courier
31         !mail-mta/esmtp
32         !mail-mta/exim
33         !mail-mta/mini-qmail
34         !mail-mta/msmtp[mta]
35         !mail-mta/netqmail
36         !mail-mta/nullmailer
37         !mail-mta/postfix
38         !mail-mta/opensmtpd
39         !mail-mta/qmail-ldap
40         !<mail-mta/ssmtp-2.64-r2
41         !>=mail-mta/ssmtp-2.64-r2[mta]"
42
43 PDEPEND="!mbox? ( mail-filter/procmail )"
44
45 # libmilter library is part of sendmail, but it does not share the version number with it.
46 # In order to find the right libmilter version number, check SMFI_VERSION definition
47 # that can be found in ${S}/include/libmilter/mfapi.h (see also SM_LM_VRS_* defines).
48 # For example, version 1.0.1 has a SMFI_VERSION of 0x01000001.
49 LIBMILTER_VER=1.0.2
50
51 pkg_setup() {
52         enewgroup smmsp 209
53         enewuser smmsp 209 -1 /var/spool/mqueue smmsp
54 }
55
56 src_prepare() {
57         eapply "${FILESDIR}"/"${PN}"-8.14.6-build-system.patch
58         eapply -p0 "${FILESDIR}"/sendmail-delivered_hdr.patch
59         eapply "${FILESDIR}"/libmilter-sharedlib.patch
60         eapply -p0 "${FILESDIR}"/sendmail-starttls-multi-crl.patch
61         eapply "${FILESDIR}"/${P}-openssl-1.1.0-fix.patch
62
63         local confCC="$(tc-getCC)"
64         local confCCOPTS="${CFLAGS}"
65         local confLDOPTS="${LDFLAGS}"
66         local confMAPDEF="-DMAP_REGEX"
67         local conf_sendmail_LIBS=""
68         use sasl && confLIBS="${confLIBS} -lsasl2"  \
69                 && confENVDEF="${confENVDEF} -DSASL=2" \
70                 && confCCOPTS="${confCCOPTS} -I/usr/include/sasl" \
71                 && conf_sendmail_LIBS="${conf_sendmail_LIBS} -lsasl2"
72         use tcpd && confENVDEF="${confENVDEF} -DTCPWRAPPERS" \
73                 && confLIBS="${confLIBS} -lwrap"
74         use ssl && confENVDEF="${confENVDEF} -DSTARTTLS -D_FFR_DEAL_WITH_ERROR_SSL" \
75                 && confENVDEF="${confENVDEF} -D_FFR_TLS_1" \
76                 && confLIBS="${confLIBS} -lssl -lcrypto" \
77                 && conf_sendmail_LIBS="${conf_sendmail_LIBS} -lssl -lcrypto"
78         use ldap && confMAPDEF="${confMAPDEF} -DLDAPMAP" \
79                 && confLIBS="${confLIBS} -lldap -llber"
80         use ipv6 && confENVDEF="${confENVDEF} -DNETINET6"
81         use nis && confENVDEF="${confENVDEF} -DNIS"
82         use sockets && confENVDEF="${confENVDEF} -DSOCKETMAP"
83         sed -e "s:@@confCCOPTS@@:${confCCOPTS}:" \
84                 -e "s/@@confLDOPTS@@/${confLDOPTS}/" \
85                 -e "s/@@confCC@@/${confCC}/" \
86                 -e "s/@@confMAPDEF@@/${confMAPDEF}/" \
87                 -e "s/@@confENVDEF@@/${confENVDEF}/" \
88                 -e "s/@@confLIBS@@/${confLIBS}/" \
89                 -e "s/@@conf_sendmail_LIBS@@/${conf_sendmail_LIBS}/" \
90                 "${FILESDIR}"/site.config.m4 > devtools/Site/site.config.m4
91         echo "APPENDDEF(\`confLIBDIRS', \`-L${EROOT}usr/$(get_libdir)')" >> devtools/Site/site.config.m4 || die
92
93         eapply_user
94 }
95
96 src_compile() {
97         sh Build AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" || die "compilation failed in main Build script"
98         pushd libmilter
99         sh Build AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" MILTER_SOVER=${LIBMILTER_VER} || die "libmilter compilation failed"
100         popd
101 }
102
103 src_install() {
104         local MY_LIBDIR=/usr/$(get_libdir)
105         local MY_OBJDIR="obj.`uname -s`.`uname -r`.`uname -m`"
106         dodir /usr/bin ${MY_LIBDIR} /usr/include/libmilter
107         dodir /usr/share/man/man{1,5,8} /usr/sbin /var/log /usr/share/sendmail-cf
108         dodir /var/spool/{mqueue,clientmqueue} /etc/conf.d
109         keepdir /var/spool/{clientmqueue,mqueue}
110         for dir in libsmutil sendmail mailstats praliases smrsh makemap vacation editmap
111         do
112                 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
113                         SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
114                         MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
115                         LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
116                         MSPQOWN=root CFOWN=root CFGRP=root \
117                         install -C "${MY_OBJDIR}/${dir}" \
118                         || die "install failed"
119         done
120         for dir in rmail mail.local
121         do
122                 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
123                         SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
124                         MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
125                         LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
126                         MSPQOWN=root CFOWN=root CFGRP=root \
127                         force-install -C "${MY_OBJDIR}/${dir}" \
128                         || die "install failed"
129         done
130
131         make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
132                 SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
133                 MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
134                 LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
135                 MSPQOWN=root CFOWN=root CFGRP=root \
136                 MILTER_SOVER=${LIBMILTER_VER} \
137                 install -C "${MY_OBJDIR}/libmilter" \
138                 || die "install failed"
139
140         fowners root:smmsp /usr/sbin/sendmail
141         fperms 2555 /usr/sbin/sendmail
142         fowners smmsp:smmsp /var/spool/clientmqueue
143         fperms 770 /var/spool/clientmqueue
144         fperms 700 /var/spool/mqueue
145         dosym /usr/sbin/makemap /usr/bin/makemap
146         dodoc FAQ KNOWNBUGS README RELEASE_NOTES doc/op/op.ps
147         newdoc sendmail/README README.sendmail
148         newdoc sendmail/SECURITY SECURITY
149         newdoc sendmail/TUNING TUNING
150         newdoc smrsh/README README.smrsh
151         newdoc libmilter/README README.libmilter
152
153         newdoc cf/README README.cf
154         newdoc cf/cf/README README.install-cf
155         cp -pPR cf/* "${D}"/usr/share/sendmail-cf
156
157         docinto contrib
158         dodoc contrib/*
159
160         insinto /etc/mail
161         if use mbox
162         then
163                 newins "${FILESDIR}"/sendmail.mc-r1 sendmail.mc
164         else
165                 newins "${FILESDIR}"/sendmail-procmail.mc sendmail.mc
166         fi
167         m4 "${D}"/usr/share/sendmail-cf/m4/cf.m4 "${D}"/etc/mail/sendmail.mc \
168                 > "${D}"/etc/mail/sendmail.cf
169         echo "include(\`/usr/share/sendmail-cf/m4/cf.m4')dnl" \
170                 > "${D}"/etc/mail/submit.mc
171         cat "${D}"/usr/share/sendmail-cf/cf/submit.mc >> "${D}"/etc/mail/submit.mc
172         echo "# local-host-names - include all aliases for your machine here" \
173                 > "${D}"/etc/mail/local-host-names
174         cat <<- EOF > "${D}"/etc/mail/trusted-users
175                 # trusted-users - users that can send mail as others without a warning
176                 # apache, mailman, majordomo, uucp are good candidates
177         EOF
178         cat <<- EOF > "${D}"/etc/mail/access
179                 # Check the /usr/share/doc/sendmail/README.cf file for a description
180                 # of the format of this file. (search for access_db in that file)
181                 # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
182                 # package.
183                 #
184
185         EOF
186         cat <<- EOF > "${D}"/etc/conf.d/sendmail
187                 # Config file for /etc/init.d/sendmail
188                 # add start-up options here
189                 SENDMAIL_OPTS="-bd -q30m -L sm-mta" # default daemon mode
190                 CLIENTMQUEUE_OPTS="-Ac -q30m -L sm-cm" # clientmqueue
191                 KILL_OPTS="" # add -9/-15/your favorite evil SIG level here
192
193         EOF
194         if use sasl; then
195                 dodir /etc/sasl2
196                 cat <<- EOF > "${D}"/etc/sasl2/Sendmail.conf
197                 pwcheck_method: saslauthd
198                 mech_list: PLAIN LOGIN
199
200                 EOF
201         fi
202
203         doinitd "${FILESDIR}"/sendmail
204         systemd_dounit "${FILESDIR}"/sendmail.service
205         systemd_dounit "${FILESDIR}"/sm-client.service
206
207         keepdir /usr/adm/sm.bin
208 }