summaryrefslogtreecommitdiff
path: root/net-misc/tinyssh/tinyssh-99999999.ebuild
blob: 4b288ff014ec1a5118a1e878e46a303142b16ac4 (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
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit systemd toolchain-funcs

DESCRIPTION="A small SSH server with state-of-the-art cryptography"
HOMEPAGE="https://tinyssh.org"
if [[ "${PV}" == "99999999" ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/janmojzis/tinyssh.git"
else
	SRC_URI="https://github.com/janmojzis/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~amd64 ~x86"
fi

LICENSE="CC0-1.0"
SLOT="0"

IUSE="+sodium"

DEPEND="
	sodium? ( dev-libs/libsodium:= )
"
RDEPEND="
	${DEPEND}
	sys-apps/ucspi-tcp
"

src_prepare() {
	# Leave optimization level to user CFLAGS
	sed -i 's/-Os -fomit-frame-pointer -funroll-loops//g' ./conf-cc || die

	# Use make-tinysshcc.sh script, which has no tests and doesn't execute
	# binaries. See https://github.com/janmojzis/tinyssh/issues/2
	sed -i 's/make-tinyssh\.sh/make-tinysshcc.sh/g' ./Makefile || die

	default
}

src_compile() {
	tc-export PKG_CONFIG

	if use sodium
	then
		emake \
			CC="$(tc-getCC)" \
			LIBS="$("${PKG_CONFIG}" --libs libsodium)" \
			CFLAGS="${CFLAGS} $("${PKG_CONFIG}" --cflags libsodium)" \
			LDFLAGS="${LDFLAGS}"
	else
		emake CC="$(tc-getCC)"
	fi
}

src_install() {
	dosbin build/bin/tinysshd{,-makekey}
	dobin build/bin/tinysshd-printkey
	doman man/*

	newinitd "${FILESDIR}/${PN}.initd" "${PN}"
	newconfd "${FILESDIR}/${PN}.confd" "${PN}"

	systemd_newunit "${FILESDIR}/${PN}.service" "${PN}@.service"
	systemd_newunit "${FILESDIR}/${PN}.socket" "${PN}@.socket"
	systemd_dounit "${FILESDIR}/${PN}-makekey.service"
}

pkg_postinst() {
	einfo "TinySSH is in beta stage, and ready for production use."
	einfo "See https://tinyssh.org for more information."
}