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

EAPI=8

DISABLE_AUTOFORMATTING=1
FORCE_PRINT_ELOG=1
PYTHON_COMPAT=( python3_{10..12} )

inherit cmake python-any-r1 systemd readme.gentoo-r1
DESCRIPTION="An unidentifiable mechanism that helps you bypass GFW"
HOMEPAGE="https://github.com/trojan-gfw/trojan"
if [[ "${PV}" == 9999 ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/trojan-gfw/trojan.git"
else
	SRC_URI="https://github.com/trojan-gfw/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~amd64 ~arm ~arm64 ~riscv ~x86"
fi

LICENSE="GPL-3+"
SLOT="0"
IUSE="mysql +nat +reuseport tcpfastopen test"

# Some hiccups setting up local network server.
RESTRICT="test"

RDEPEND="
	dev-libs/boost:=
	dev-libs/openssl:0=
	mysql? ( dev-db/mysql-connector-c:= )
"
DEPEND="${RDEPEND}
	acct-group/trojan
	acct-user/trojan
	test? ( net-misc/curl ${PYTHON_DEPS} )
"

pkg_setup() {
	use test && python-any-r1_pkg_setup
}

src_prepare() {
	default
	cmake_src_prepare
	sed -i -e "/User/s/nobody/trojan/g" \
		"${S}"/examples/trojan.service-example || die
}

src_configure() {
	local mycmakeargs=(
		-DENABLE_MYSQL=$(usex mysql)
		-DENABLE_NAT=$(usex nat)
		-DENABLE_REUSE_PORT=$(usex reuseport)
		-DFORCE_TCP_FASTOPEN=$(usex tcpfastopen)
		-DSYSTEMD_SERVICE=ON
		-DSYSTEMD_SERVICE_PATH=$(systemd_get_systemunitdir)
	)
	cmake_src_configure
}

src_install() {
	cmake_src_install
	newinitd "${FILESDIR}/trojan.initd" trojan

	readme.gentoo_create_doc
}

src_test() {
	cmake_src_test -j1
}

pkg_postinst() {
	readme.gentoo_print_elog
}