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

EAPI=8

inherit toolchain-funcs systemd tmpfiles

DESCRIPTION="coturn TURN server project"
HOMEPAGE="https://github.com/coturn/coturn"

if [[ ${PV} == *9999 ]]; then
	EGIT_REPO_URI="https://github.com/coturn/coturn.git"
	inherit git-r3
else
	SRC_URI="https://github.com/coturn/coturn/archive/${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~amd64 ~arm64 ~x86"
fi

LICENSE="BSD"
SLOT="0"
IUSE="mongodb mysql postgres redis sqlite"

DEPEND="
	>dev-libs/libevent-2.1.8:=[ssl]
	dev-libs/openssl:=
	mongodb? (
		dev-libs/libbson
		dev-libs/mongo-c-driver
	)
	mysql? ( dev-db/mysql-connector-c:= )
	postgres? ( dev-db/postgresql:* )
	redis? ( dev-libs/hiredis:= )
	sqlite? ( dev-db/sqlite:3 )
"
RDEPEND="
	${DEPEND}
	acct-group/turnserver
	acct-user/turnserver
"
BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}"/${PN}-4.5.2-respect-TMPDIR.patch
)

src_configure() {
	sed -e '/MANPREFIX/s:/man/:/:' \
		-e '/INSTALL_DIR} examples\/script/a \	\${INSTALL_DIR} examples\/ca \${DESTDIR}${EXAMPLESDIR}' \
		-e '/INSTALL_STATIC_LIB/d' \
		-i "Makefile.in" || die "sed for Makefile.in failed"

	sed -e 's:#log-file=/var/tmp/turn.log:log-file=/var/log/turnserver.log:' \
		-e 's:#simple-log:simple-log:' \
		-i "examples/etc/turnserver.conf"  || die "sed for turnserve.conf failed"

	if ! use mongodb; then
		export TURN_NO_MONGO=yes
	fi
	if ! use mysql; then
		export TURN_NO_MYSQL=yes
	fi
	if ! use postgres; then
		export TURN_NO_PQ=yes
	fi
	if ! use redis; then
		export TURN_NO_HIREDIS=yes
	fi
	if ! use sqlite; then
		export TURN_NO_SQLITE=yes
	fi

	tc-export CC

	export ARCHIVERCMD="$(tc-getAR) -r"
	export PKGCONFIG="$(tc-getPKG_CONFIG)"
	export DOCSDIR="/usr/share/doc/${PF}"

	econf $(use_with sqlite)
}

src_install() {
	default

	keepdir /var/lib/db

	newinitd "${FILESDIR}/turnserver.init" turnserver

	insinto /etc/logrotate.d
	newins "${FILESDIR}/logrotate.${PN}" "${PN}"

	systemd_dounit "${FILESDIR}/${PN}.service"
	dotmpfiles "${FILESDIR}/${PN}.conf"
}

pkg_postinst() {
	tmpfiles_process ${PN}.conf

	elog "You need to copy ${EROOT}/etc/turnserver.conf.default to"
	elog "${EROOT}/etc/turnserver.conf and do your settings there."
}