summaryrefslogtreecommitdiff
blob: 54d062e02d68255d9c9dccac1b00c89ee3711bd5 (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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="7"

inherit systemd toolchain-funcs

DESCRIPTION="Port of the OpenBSD TFTP server"
HOMEPAGE="https://www.kernel.org/pub/software/network/tftp/"
SRC_URI="https://www.kernel.org/pub/software/network/tftp/${PN}/${P}.tar.xz"

LICENSE="BSD-4"
SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 sparc x86 ~ppc-macos"
IUSE="ipv6 readline selinux tcpd +client +server"

DEPEND="
	readline? ( sys-libs/readline:0= )
	tcpd? ( sys-apps/tcp-wrappers )
"

RDEPEND="${DEPEND}
	selinux? ( sec-policy/selinux-tftp )
	!net-ftp/atftp
	server? (
		!net-misc/iputils[tftpd(-)]
		!net-ftp/uftpd
	)
"

PATCHES=(
	"${FILESDIR}"/tftp-hpa-5.2-gcc-10.patch
)

src_prepare() {
	default
	sed -i "/^AR/s:ar:$(tc-getAR):" MCONFIG.in || die
}

src_configure() {
	local myconf=(
		ac_cv_search_bsd_signal=no
		$(use_with ipv6)
		$(use_with tcpd tcpwrappers)
		$(use_with readline)
	)
	econf "${myconf[@]}"
}

src_compile() {
	emake version.h
	emake -C lib
	emake -C common
	if use client; then
		emake -C tftp
	fi
	if use server; then
		emake -C tftpd
	fi
}

src_install() {
	dodoc README* CHANGES tftpd/sample.rules

	if use client; then
		emake INSTALLROOT="${D}" -C tftp install
	fi
	if use server; then
		emake INSTALLROOT="${D}" -C tftpd install

		newconfd "${FILESDIR}"/in.tftpd.confd-0.44 in.tftpd
		newinitd "${FILESDIR}"/in.tftpd.rc6 in.tftpd

		systemd_dounit "${FILESDIR}"/tftp.service
		systemd_dounit "${FILESDIR}"/tftp.socket

		insinto /etc/xinetd.d
		newins "${FILESDIR}"/tftp.xinetd tftp
	fi
}