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

EAPI=7

PYTHON_COMPAT=( python{3_6,3_7} )
EGIT_REPO_URI="https://github.com/trojan-gfw/trojan.git"

inherit cmake git-r3 python-any-r1 systemd

DESCRIPTION="An unidentifiable mechanism that helps you bypass GFW"
HOMEPAGE="https://github.com/trojan-gfw/trojan"

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS=""
IUSE="mysql test"

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

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

src_configure() {
	local mycmakeargs=(
		-DENABLE_MYSQL=$(usex mysql)
		-DSYSTEMD_SERVICE=ON
		-DSYSTEMD_SERVICE_PATH=$(systemd_get_systemunitdir)
	)
	cmake_src_configure
}

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

src_test() {
	cmake_src_test -j1
}

pkg_postinst() {
	elog "Running Trojan with multi instances"
	elog ""

	elog "Prepare /etc/trojan/\${blah}.json first"
	elog "Config with Openrc"
	elog "   ln -s /etc/init.d/trojan{,.\${blah}}"
	elog "   rc-update add trojan.\${blah} default"
	elog ""
	elog "Config with Systemd"
	elog "   systemctl enable trojan.\${blah}"
	elog ""
}