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

EAPI=6

inherit systemd user

MY_PV="${PV/_beta/-beta.}"
DESCRIPTION="UniFi Video Server"
HOMEPAGE="https://www.ubnt.com/download/unifi-video/"
SRC_URI="https://dl.ubnt.com/firmwares/ufv/v${MY_PV}/unifi-video.Ubuntu16.04_amd64.v${MY_PV}.deb"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS=""
IUSE=""
RESTRICT="mirror"

DEPEND=""
RDEPEND="dev-db/mongodb
	dev-java/commons-daemon
	sys-apps/lsb-release
	sys-libs/libcap
	virtual/jre:1.8"

S=${WORKDIR}
QA_PREBUILT="usr/lib*/${PN}/lib/*.so usr/lib*/${PN}/bin/*"

pkg_setup() {
	enewuser ${PN}
	enewgroup ${PN}
}

src_unpack() {
	default
	unpack "${WORKDIR}"/data.tar.gz
}

src_prepare() {
	eapply "${FILESDIR}"/commons-daemon-move.patch
	sed -i usr/sbin/${PN} \
		-e '/require_root$/d' \
		-e '/update_limits$/d' \
		-e '/ulimit/d' \
		-e '/coredump_filter/d' || die
	default
}

src_install() {
	static_dir="/usr/$(get_libdir)/${PN}"
	#install static data
	insinto ${static_dir}
	doins -r usr/lib/${PN}/*
	fperms -R +x ${static_dir}/bin
	fowners -R ${PN}:${PN} ${static_dir}/conf/evostream/

	#wrapper to work around mongodb-3.6 compat issue
	exeinto ${static_dir}/bin/
	newexe "${FILESDIR}"/mongod-wrapper mongod

	#prepare runtime-data dirs which live in /var but are symlinked from static
	#data dir, and are writable by non-root user
	dodir /var/log/${PN}
	fowners ${PN}:${PN} /var/log/${PN}
	dosym ../../../var/log/${PN} ${static_dir}/logs

	dodir /var/lib/${PN}/work
	fowners ${PN}:${PN} /var/lib/${PN}/work
	dosym ../../../var/lib/${PN}/work ${static_dir}/work

	keepdir /var/lib/${PN}/data
	fowners ${PN}:${PN} /var/lib/${PN}/data
	dosym ../../../var/lib/${PN}/data ${static_dir}/data

	echo "CONFIG_PROTECT=\"/var/lib/${PN}/data/system.properties\"" > "${T}"/99${PN}
	doenvd "${T}"/99${PN}

	into /usr
	dosbin usr/sbin/${PN}

	newinitd "${FILESDIR}"/${PN}.initd ${PN}
	systemd_dounit "${FILESDIR}"/${PN}.service
}