summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Kappus <joe@wt.gd>2023-02-05 04:57:10 -0500
committerSam James <sam@gentoo.org>2023-02-17 06:22:24 +0000
commit71de81b880d7349ce048fa3e11ba0da762f70bb7 (patch)
tree193905ea5828f354f365cfda0ea2251bf869227d /media-tv
parentmedia-gfx/graphite2: enable py3.11 (diff)
downloadgentoo-71de81b880d7349ce048fa3e11ba0da762f70bb7.tar.gz
gentoo-71de81b880d7349ce048fa3e11ba0da762f70bb7.tar.bz2
gentoo-71de81b880d7349ce048fa3e11ba0da762f70bb7.zip
media-tv/plex-media-server: readd hardened support, initscript, fix version reporting
These changes will bring us in line with plex-overlay. - start_pms is hacky and removed, we shouldn't ship it. - the service - we had pax marking, someone removed it, but it was requested before so readding. - openrc and systemd support - Lift mirror restriction (again): https://bugs.gentoo.org/600696 Co-authored-by: Sam James <sam@cmpct.info> Signed-off-by: Joe Kappus <joe@wt.gd> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'media-tv')
-rw-r--r--media-tv/plex-media-server/files/plex-media-server.conf.d8
-rw-r--r--media-tv/plex-media-server/files/plex-media-server.init.d16
-rw-r--r--media-tv/plex-media-server/files/plex-media-server.service.patch10
-rw-r--r--media-tv/plex-media-server/plex-media-server-1.30.2.6563-r1.ebuild84
4 files changed, 118 insertions, 0 deletions
diff --git a/media-tv/plex-media-server/files/plex-media-server.conf.d b/media-tv/plex-media-server/files/plex-media-server.conf.d
new file mode 100644
index 000000000000..bd683b0063b9
--- /dev/null
+++ b/media-tv/plex-media-server/files/plex-media-server.conf.d
@@ -0,0 +1,8 @@
+# Config file for /etc/init.d/plex-media-server
+
+PLEX_PIDFILE="/var/run/plex-media-server.pid"
+PLEX_OUTLOG="/var/log/pms/out.log"
+PLEX_ERRLOG="/var/log/pms/err.log"
+PLEX_USER="plex"
+# PLEX_SCRIPT="/usr/sbin/start_pms"
+PLEX_SCRIPT="/usr/lib/plexmediaserver/Plex Media Server"
diff --git a/media-tv/plex-media-server/files/plex-media-server.init.d b/media-tv/plex-media-server/files/plex-media-server.init.d
new file mode 100644
index 000000000000..26f3941a3b0e
--- /dev/null
+++ b/media-tv/plex-media-server/files/plex-media-server.init.d
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+
+start() {
+ ebegin "Starting Plex Media Server"
+ start-stop-daemon -S -m -p ${PLEX_PIDFILE} -1 ${PLEX_OUTLOG} -2 ${PLEX_ERRLOG} --quiet -u ${PLEX_USER} -N -5 -b --exec "${PLEX_SCRIPT}"
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping Plex Media Server"
+ kill -- -`cat ${PLEX_PIDFILE}`
+
+ # Remove stale pid file since this is a dirty solution
+ rm ${PLEX_PIDFILE}
+ eend $?
+}
diff --git a/media-tv/plex-media-server/files/plex-media-server.service.patch b/media-tv/plex-media-server/files/plex-media-server.service.patch
new file mode 100644
index 000000000000..a2bf14ed30cd
--- /dev/null
+++ b/media-tv/plex-media-server/files/plex-media-server.service.patch
@@ -0,0 +1,10 @@
+--- ./usr/lib/plexmediaserver/lib/plexmediaserver.service.old 2020-11-22 18:18:21.258165393 +0100
++++ ./usr/lib/plexmediaserver/lib/plexmediaserver.service 2020-11-22 18:18:35.864602444 +0100
+@@ -27,5 +27,6 @@
+ export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )"; \
+ export PLEX_MEDIA_SERVER_INFO_DEVICE="PC"; \
+ export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"; \
+-export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )"; \
++export GENTOO_PROFILE="`readlink /etc/portage/make.profile`"; \
++export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$${GENTOO_PROFILE#.*/profiles/}"; \
+ exec "/usr/lib/plexmediaserver/Plex Media Server"'
diff --git a/media-tv/plex-media-server/plex-media-server-1.30.2.6563-r1.ebuild b/media-tv/plex-media-server/plex-media-server-1.30.2.6563-r1.ebuild
new file mode 100644
index 000000000000..e95da8c48f94
--- /dev/null
+++ b/media-tv/plex-media-server/plex-media-server-1.30.2.6563-r1.ebuild
@@ -0,0 +1,84 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit readme.gentoo-r1 systemd unpacker pax-utils
+
+MY_PV="${PV}-3d4dc0cce"
+MY_URI="https://downloads.plex.tv/plex-media-server-new"
+
+DESCRIPTION="Free media library that is intended for use with a plex client"
+HOMEPAGE="https://www.plex.tv/"
+SRC_URI="
+ amd64? ( ${MY_URI}/${MY_PV}/debian/plexmediaserver_${MY_PV}_amd64.deb )
+ arm64? ( ${MY_URI}/${MY_PV}/debian/plexmediaserver_${MY_PV}_arm64.deb )
+ x86? ( ${MY_URI}/${MY_PV}/debian/plexmediaserver_${MY_PV}_i386.deb )
+"
+S="${WORKDIR}"
+
+LICENSE="Plex"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~arm64 ~x86"
+RESTRICT="bindist"
+
+DEPEND="
+ acct-group/plex
+ acct-user/plex"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+ "${FILESDIR}/${PN}.service.patch"
+)
+
+QA_DESKTOP_FILE="usr/share/applications/plexmediamanager.desktop"
+QA_PREBUILT="*"
+QA_MULTILIB_PATHS=(
+ "usr/lib/plexmediaserver/lib/.*"
+ "usr/lib/plexmediaserver/Resources/Python/lib/python2.7/.*"
+ "usr/lib/plexmediaserver/Resources/Python/lib/python2.7/lib-dynload/_hashlib.so"
+)
+
+BINS_TO_PAX_MARK=(
+ "${ED}/usr/lib/plexmediaserver/Plex Script Host"
+ "${ED}/usr/lib/plexmediaserver/Plex Media Scanner"
+)
+
+src_install() {
+ # Remove Debian specific files
+ rm -r "usr/share/doc" || die
+
+ # Copy main files over to image and preserve permissions so it is portable
+ cp -rp usr/ "${ED}" || die
+
+ # Make sure the logging directory is created
+ keepdir /var/log/pms
+ fowners plex:plex /var/log/pms
+
+ keepdir /var/lib/plexmediaserver
+ fowners plex:plex /var/lib/plexmediaserver
+
+ # Install the OpenRC init/conf files
+ newinitd "${FILESDIR}/${PN}.init.d" ${PN}
+ newconfd "${FILESDIR}/${PN}.conf.d" ${PN}
+
+ # Install systemd service file
+ systemd_newunit "${ED}"/usr/lib/plexmediaserver/lib/plexmediaserver.service "${PN}.service"
+
+ # Add pax markings to some binaries so that they work on hardened setup
+ local f
+ for f in "${BINS_TO_PAX_MARK[@]}"; do
+ pax-mark m "${f}"
+ done
+
+ # Adds the precompiled plex libraries to the revdep-rebuild's mask list
+ # so it doesn't try to rebuild libraries that can't be rebuilt.
+ insinto /etc/revdep-rebuild
+ doins "${FILESDIR}"/80plexmediaserver
+
+ readme.gentoo_create_doc
+}
+
+pkg_postinst() {
+ readme.gentoo_print_elog
+}