summaryrefslogtreecommitdiff
blob: c5b98eddea638725500aba0f59d8741e62c5c4f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

VERIFY_SIG_METHOD="signify"
inherit pam systemd verify-sig

DESCRIPTION="Lightweight but featured SMTP daemon from OpenBSD"
HOMEPAGE="https://www.opensmtpd.org"
SRC_URI="
	https://www.opensmtpd.org/archives/${P/_}.tar.gz
	verify-sig? ( https://www.opensmtpd.org/archives/${P/_}.sum.sig )
"
S="${WORKDIR}/${P/_}"

LICENSE="ISC BSD BSD-1 BSD-2 BSD-4"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
IUSE="berkdb +mta pam split-usr"

DEPEND="
	dev-libs/libbsd
	dev-libs/libevent:=
	dev-libs/openssl:=
	sys-libs/zlib:=
	virtual/libcrypt:=
	berkdb? ( sys-libs/db:= )
	elibc_musl? ( sys-libs/fts-standalone )
	pam? ( sys-libs/pam )
"
RDEPEND="${DEPEND}
	acct-user/smtpd
	acct-user/smtpq
	app-misc/ca-certificates
	net-mail/mailbase
	!mail-client/mailx-support
	!mail-mta/courier
	!mail-mta/esmtp
	!mail-mta/exim
	!mail-mta/msmtp[mta]
	!mail-mta/netqmail
	!mail-mta/nullmailer
	!mail-mta/postfix
	!mail-mta/sendmail
	!mail-mta/ssmtp[mta]
"
BDEPEND="
	app-alternatives/yacc
	virtual/pkgconfig
	verify-sig? ( sec-keys/signify-keys-opensmtpd )
"

VERIFY_SIG_OPENPGP_KEY_PATH="/usr/share/signify-keys/${PN}.pub"

QA_CONFIG_IMPL_DECL_SKIP=( closefrom )

DOCS=( {CHANGES,README}.md )

src_unpack() {
	if use verify-sig; then
		# Too many levels of symbolic links
		cp "${DISTDIR}"/${P/_}.{sum.sig,tar.gz} "${WORKDIR}" || die
		verify-sig_verify_signed_checksums \
			${P/_}.sum.sig sha256 ${P/_}.tar.gz
	fi
	default
}

src_configure() {
	local myeconfargs=(
		--sysconfdir="${EPREFIX}"/etc/smtpd
		--with-path-CAfile="${EPREFIX}"/etc/ssl/certs/ca-certificates.crt
		--with-path-empty="${EPREFIX}"/var/empty
		--with-path-mbox="${EPREFIX}"/var/spool/mail
		--with-path-queue="${EPREFIX}"/var/spool/smtpd
		--with-path-pidfile=/run
		--with-path-socket=/run
		--with-user-smtpd=smtpd
		--with-user-queue=smtpq
		--with-group-queue=smtpq
		--with-libevent="${EPREFIX}"/usr/$(get_libdir)
		--with-libssl="${EPREFIX}"/usr/$(get_libdir)
		$(use_with berkdb table-db)
		$(use_with pam auth-pam)
	)

	econf "${myeconfargs[@]}"
}

src_install() {
	default

	newinitd "${FILESDIR}"/smtpd.initd smtpd
	systemd_newunit "${FILESDIR}"/smtpd-r1.service smtpd.service

	use pam && newpamd "${FILESDIR}"/smtpd.pam smtpd

	dosym smtpctl /usr/sbin/makemap
	dosym smtpctl /usr/sbin/newaliases

	if use mta; then
		dodir /usr/sbin
		dosym smtpctl /usr/sbin/sendmail
		# on USE="-split-usr" system sbin and bin are merged
		# so symlink made above will collide with one below
		use split-usr && dosym ../sbin/smtpctl /usr/bin/sendmail
		dodir /usr/$(get_libdir)
		dosym -r /usr/sbin/smtpctl /usr/$(get_libdir)/sendmail
	fi
}