commit:     0c5276e4940f2bbd352653c2e3efdeeb9b6cfc81
Author:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 26 00:49:41 2018 +0000
Commit:     Ben Kohler <bkohler <AT> gentoo <DOT> org>
CommitDate: Tue Jun 26 00:49:41 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0c5276e4

media-video/unifi-video: new package

Package-Manager: Portage-2.3.40, Repoman-2.3.9

 media-video/unifi-video/Manifest                   |  1 +
 .../unifi-video/files/commons-daemon-move.patch    | 12 ++++
 media-video/unifi-video/files/mongod-wrapper       |  3 +
 media-video/unifi-video/files/unifi-video.confd    |  0
 media-video/unifi-video/files/unifi-video.initd    | 20 ++++++
 media-video/unifi-video/files/unifi-video.service  | 11 +++
 media-video/unifi-video/metadata.xml               |  9 +++
 media-video/unifi-video/unifi-video-3.9.7.ebuild   | 83 ++++++++++++++++++++++
 8 files changed, 139 insertions(+)

diff --git a/media-video/unifi-video/Manifest b/media-video/unifi-video/Manifest
new file mode 100644
index 00000000000..db2ca191aa8
--- /dev/null
+++ b/media-video/unifi-video/Manifest
@@ -0,0 +1 @@
+DIST unifi-video.Ubuntu16.04_amd64.v3.9.7.deb 117374890 BLAKE2B 
b0f274da3052471472cd2405ec0a5d79fd97cbc30f014ede42a004dcffc4d27b9b5ecc36f32b4f60f8c47ba73b85795d2851345f5472b85192cf836bfb929173
 SHA512 
9a0f48d81f3935baad4004681cabe2ff46f4f86f8770c260c98fbd724de2949427de8ec706d86d612a9ccbcda69ca227aa4a123c3208e0a4ab7c0a51540c06f8

diff --git a/media-video/unifi-video/files/commons-daemon-move.patch 
b/media-video/unifi-video/files/commons-daemon-move.patch
new file mode 100644
index 00000000000..448f77249e8
--- /dev/null
+++ b/media-video/unifi-video/files/commons-daemon-move.patch
@@ -0,0 +1,12 @@
+--- a/usr/sbin/unifi-video
++++ b/usr/sbin/unifi-video
+@@ -271,7 +271,7 @@
+ JSVC_OPTS="${JSVC_OPTS} \
+  -user ${PKGUSER} \
+  -home ${JAVA_HOME} \
+- -cp /usr/share/java/commons-daemon.jar:${MAINJAR} \
++ -cp /usr/share/commons-daemon/lib/commons-daemon.jar:${MAINJAR} \
+  -pidfile ${PIDFILE} \
+  -procname ${NAME} \
+  ${JSVC_EXTRA_OPTS} \
+

diff --git a/media-video/unifi-video/files/mongod-wrapper 
b/media-video/unifi-video/files/mongod-wrapper
new file mode 100755
index 00000000000..f2eb2a43752
--- /dev/null
+++ b/media-video/unifi-video/files/mongod-wrapper
@@ -0,0 +1,3 @@
+#!/bin/bash
+cleaned_args=$(echo $* | sed -e 's/--nohttpinterface//')
+/usr/bin/mongod ${cleaned_args}

diff --git a/media-video/unifi-video/files/unifi-video.confd 
b/media-video/unifi-video/files/unifi-video.confd
new file mode 100644
index 00000000000..e69de29bb2d

diff --git a/media-video/unifi-video/files/unifi-video.initd 
b/media-video/unifi-video/files/unifi-video.initd
new file mode 100644
index 00000000000..55d6e805453
--- /dev/null
+++ b/media-video/unifi-video/files/unifi-video.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+PID_FILE="/run/unifi-video.pid"
+
+start() {
+       ebegin "Starting unifi-video"
+       start-stop-daemon --start --quiet -b \
+       --pidfile "${PID_FILE}" -m \
+       --exec /usr/sbin/unifi-video start
+       eend $?
+       #--user nobody --group nobody \
+}
+
+stop() {
+       ebegin "Stopping unifi-video"
+       start-stop-daemon --quiet --stop -R 20 --pidfile "${PID_FILE}"
+       eend $?
+}

diff --git a/media-video/unifi-video/files/unifi-video.service 
b/media-video/unifi-video/files/unifi-video.service
new file mode 100644
index 00000000000..6587be4f1ca
--- /dev/null
+++ b/media-video/unifi-video/files/unifi-video.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=UniFi Video Server
+Requires=network.target
+After=network.target
+
+[Service]
+ExecStart=/usr/sbin/unifi-video -D start
+ExecStop=/usr/sbin/unifi-video -D stop
+
+[Install]
+WantedBy=network.target

diff --git a/media-video/unifi-video/metadata.xml 
b/media-video/unifi-video/metadata.xml
new file mode 100644
index 00000000000..ee9a82ac417
--- /dev/null
+++ b/media-video/unifi-video/metadata.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <maintainer type="person">
+               <email>bkoh...@gentoo.org</email>
+               <name>Ben Kohler</name>
+       </maintainer>
+</pkgmetadata>
+

diff --git a/media-video/unifi-video/unifi-video-3.9.7.ebuild 
b/media-video/unifi-video/unifi-video-3.9.7.ebuild
new file mode 100644
index 00000000000..be829f6a0a9
--- /dev/null
+++ b/media-video/unifi-video/unifi-video-3.9.7.ebuild
@@ -0,0 +1,83 @@
+# Copyright 1999-2018 Gentoo Foundation
+# 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="~amd64"
+IUSE=""
+RESTRICT="mirror"
+
+DEPEND=""
+RDEPEND="dev-db/mongodb
+       dev-java/commons-daemon
+       sys-apps/lsb-release
+       sys-libs/libcap
+       virtual/jre"
+
+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
+
+       #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}
+       newconfd "${FILESDIR}"/${PN}.confd ${PN}
+       systemd_dounit "${FILESDIR}"/${PN}.service
+}

Reply via email to