add media-tv/plex-media-server
authorJustin Wind <justin.wind+git@gmail.com>
Tue, 14 Apr 2020 16:05:11 +0000 (09:05 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Tue, 14 Apr 2020 16:05:11 +0000 (09:05 -0700)
media-tv/plex-media-server/Manifest [new file with mode: 0644]
media-tv/plex-media-server/files/20200129_add_gentoo_profile_as_platform_version.patch [new file with mode: 0644]
media-tv/plex-media-server/files/add_gentoo_profile_as_platform_version.patch [new file with mode: 0644]
media-tv/plex-media-server/files/conf.d/plex-media-server [new file with mode: 0644]
media-tv/plex-media-server/files/init.d/plex-media-server [new file with mode: 0755]
media-tv/plex-media-server/files/plexmediamanager.desktop.new.patch [new file with mode: 0644]
media-tv/plex-media-server/files/plexmediamanager.desktop.patch [new file with mode: 0644]
media-tv/plex-media-server/files/systemd/plex-media-server.service [new file with mode: 0644]
media-tv/plex-media-server/files/virtualenv_start_pms.patch [new file with mode: 0644]
media-tv/plex-media-server/metadata.xml [new file with mode: 0644]
media-tv/plex-media-server/plex-media-server-1.18.6.2348.ebuild [new file with mode: 0644]

diff --git a/media-tv/plex-media-server/Manifest b/media-tv/plex-media-server/Manifest
new file mode 100644 (file)
index 0000000..d2af839
--- /dev/null
@@ -0,0 +1,12 @@
+AUX 20200129_add_gentoo_profile_as_platform_version.patch 818 BLAKE2B aa86ab75f500fbfc50cf607f75511664675e3180ef23c78690f982e9a284c2ae21420e95e91befd74c12d81eee6c65994323c59def3f56672bc42e1a5cb503d9 SHA512 18930ad1f610c63ede0df0c53beb39d21d762a09e6427493aa47293c595b96660ace9c780891ce1f49fcbece2324ddec6b0b431c4f82ac32be85fae8e7cd1600
+AUX add_gentoo_profile_as_platform_version.patch 616 BLAKE2B 5331ad91139aa69944aa5c263609985c87315a67f3d5633e8f3976aa010f39f50e563d0b3b5259ebd1ce3437560ba8d95a71e304712a35bb8150ac0684a56107 SHA512 53e99d8a24a23f0c530ab955f5a4a9938c4e06056d3107f899883094690dd9426d0951ea695628351afa3e971a4f59827b6c8dcae323718d24450c74bd78769a
+AUX conf.d/plex-media-server 216 BLAKE2B 094d0f6f7cdfa696ae47d7879c7459be5755dfe02a12c3ee986c1078ae0a46d974adc25dce252a49c3fd72e0dfe1ba65c49d575e12036fba44ce9b0390da64ec SHA512 d3d68fa58a1c1064803a9607708123302890571e823e5bc26de741bb15bd51db19234636672ff01757cbbcdb984c60663545689fa915761c78c3cf49e6da0f95
+AUX init.d/plex-media-server 413 BLAKE2B f60fe9f653c591cddaf77a0ebcb47218681a63235e82bc016c7d2ee9180df7f6ff24f3784216ea370bdc2d493531492f196200b6ec56ff8b303e69adaa0f108d SHA512 aeb873a00081f20abd27cc76d395908ae0643bd8aa665557adafef2ed97edbe93c18b55818b49227746f9c3ce4b7a81ceb9132f07d8d873bc7b5a932b944a402
+AUX plexmediamanager.desktop.new.patch 350 BLAKE2B f52186623be0ee3e4e1414639c69a39cd83f4a45af4854a6bf2c4f6e3d51dab3d16539d554f80dbb432dcb97f6171097677ae9e24486167802d2cf93fe4c2f63 SHA512 e7e97ef8d39ff0e9220026d282febaa2613f8cc96253a9f801f1f2af5c60c3780391cdada98f921cf0226156a2347db982cf814e6aa446b07e9ae6b1b96c9525
+AUX plexmediamanager.desktop.patch 346 BLAKE2B 5f1af6247a24d4f8687c0f841417602d72f8d835fe7d3e9021f01c2204ca1fff6a9fe1c6b16b641f77bb3483f2ccf02eed5d3de8f06e149e55c4e6a605a85863 SHA512 dac6f9382309d266e73db98e41deffe6f562b1c06447428e5e6223030d0325369072b4234e6137a06c017efe9af6c0af4b956d390160628b84a161f51901f6a9
+AUX systemd/plex-media-server.service 265 BLAKE2B 7634b0fe15052eac8c40f390157588940ce3f91350cd0b7548a333755a6dcc42888d154dfb1f0e922ad968e548b88d84f83ae5e137693d134316271a55ed8085 SHA512 672db99884aed20b83b5b198c33237cbb398c1084b1412c692b7386cc15f87a5095f33f50ca9da6115afb2c6479bc88d95f674c4446131dc071f5df58b8ed141
+AUX virtualenv_start_pms.patch 430 BLAKE2B bfb4839491d8887959cbbc8e5d83fa5c5f7b6d73c293960af06b559ef6c51242b1717abdccf371cd5c81ec45ee07df18fac713381370b218a2f9d0376dd70f53 SHA512 df9ad1e3a3627325ad6b96015b2dfd1e0f92dd4252b788f6eccc5445f7016785b72f34572b7a60011300394b3a3668116929ebb2c9a5525e37d7c211e198d0e7
+DIST plexmediaserver_1.18.6.2348-fd90a1389_amd64.deb 87558254 BLAKE2B 6563285a628b829e63f7857e893ea5fb970ea2fe86e95538d73a37860ff232da996fc448460776ae5d989bacbcd32cd4ed3c22a2a9fc3637ae422b5a6f2b5276 SHA512 e3c76b7a82dc7a94ea990ae852f040938f2cb03c9aa615ab8cd3d48d594548bad958ca52bfa54bdd26f4c43301c7e11494f04f7287977eede839aec788eb4bec
+DIST plexmediaserver_1.18.6.2348-fd90a1389_i386.deb 73792686 BLAKE2B 8125dd94d4cf07d2a750dbac339cd28e874ab3d2e669c61e972d26ffe5dc0dbe188c00dd884f09d4629b3e725101514cb37a27c22dc9854caf05397e956b34ab SHA512 926a320dcbc994c1db95a69e85c83ac0407f9572fa719ec70ddcc539c0fdd347c042b6500326f3afeb29210905ce85a96cec31fcc454465d43cd5c5ada2df3bb
+EBUILD plex-media-server-1.18.6.2348.ebuild 5563 BLAKE2B d60947e4ac19ad5e91ad60a401975124759f480d8a778065bc8ce84fecd0924aa76bf32af764f6ca7c0fe24003e837b855b6ef28885fb43cfe0f9869a8e90319 SHA512 351884cf562cdfd52411e240173a402b3658f58cb69010d6ece62753ddbbc62435df22f9f3f0c31a51205fe65d736b6a9eb94e1c4dde1c4394496289449ffd22
+MISC metadata.xml 887 BLAKE2B 19b816e57f087e91a25e6c7605280d447342a6978fd7c804fcb2eed79bbe806e9318493c061521f74834fc89d44ce4f78c56de99e2ad35cea39c63cfa123d0f6 SHA512 e174f3cf2c7f28fbd97cf86441e2de227d2b79749b5416dfd9b670c2ff000e882e3b40b4e1613a37fdc2d86377144c9b06f72ae55e76262ffae1ad11b8a87bc0
diff --git a/media-tv/plex-media-server/files/20200129_add_gentoo_profile_as_platform_version.patch b/media-tv/plex-media-server/files/20200129_add_gentoo_profile_as_platform_version.patch
new file mode 100644 (file)
index 0000000..c451240
--- /dev/null
@@ -0,0 +1,12 @@
+--- ./usr/lib/plexmediaserver/lib/plexmediaserver.service.old  2020-01-29 08:50:39.856491924 +0100
++++ ./usr/lib/plexmediaserver/lib/plexmediaserver.service      2020-01-29 08:51:49.068249688 +0100
+@@ -12,7 +12,8 @@
+ 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/}"; \
+ export LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib; \
+ exec "/usr/lib/plexmediaserver/Plex Media Server"'
+ Type=simple
diff --git a/media-tv/plex-media-server/files/add_gentoo_profile_as_platform_version.patch b/media-tv/plex-media-server/files/add_gentoo_profile_as_platform_version.patch
new file mode 100644 (file)
index 0000000..eaf4906
--- /dev/null
@@ -0,0 +1,12 @@
+--- a/usr/sbin/start_pms
++++ b/usr/sbin/start_pms
+@@ -4,7 +4,8 @@
+ 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 \" )"
++GENTOO_PROFILE="`readlink /etc/portage/make.profile`"
++export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="${GENTOO_PROFILE#.*/profiles/}"
+ # change these parameters in /etc/plex/plexmediaserver
+ export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
diff --git a/media-tv/plex-media-server/files/conf.d/plex-media-server b/media-tv/plex-media-server/files/conf.d/plex-media-server
new file mode 100644 (file)
index 0000000..7fe754f
--- /dev/null
@@ -0,0 +1,7 @@
+# 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"
diff --git a/media-tv/plex-media-server/files/init.d/plex-media-server b/media-tv/plex-media-server/files/init.d/plex-media-server
new file mode 100755 (executable)
index 0000000..102ac80
--- /dev/null
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+
+depend() {
+       need avahi-daemon
+}
+
+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/plexmediamanager.desktop.new.patch b/media-tv/plex-media-server/files/plexmediamanager.desktop.new.patch
new file mode 100644 (file)
index 0000000..a7f86de
--- /dev/null
@@ -0,0 +1,8 @@
+--- ./usr/share/applications/plexmediaserver.desktop   2019-01-02 13:53:51.000000000 +0100
++++ ./usr/share/applications/plexmediaserver.desktop   2019-01-04 07:52:25.910331212 +0100
+@@ -6,4 +6,4 @@
+ Icon=plexmediaserver
+ Terminal=false
+ Type=Application
+-Categories=Audio;Music;Video;Player;Media;
++Categories=Audio;Music;Video;Player;AudioVideo;X-Media
diff --git a/media-tv/plex-media-server/files/plexmediamanager.desktop.patch b/media-tv/plex-media-server/files/plexmediamanager.desktop.patch
new file mode 100644 (file)
index 0000000..49aaab2
--- /dev/null
@@ -0,0 +1,8 @@
+--- ./usr/share/applications/plexmediamanager.desktop  2016-09-13 09:35:36.795386571 +0200
++++ ./usr/share/applications/plexmediamanager.desktop  2016-09-13 09:35:49.607281179 +0200
+@@ -6,4 +6,4 @@
+ Icon=plexmediamanager
+ Terminal=false
+ Type=Application
+-Categories=Audio;Music;Video;Player;Media;
++Categories=Audio;Music;Video;Player;AudioVideo;
diff --git a/media-tv/plex-media-server/files/systemd/plex-media-server.service b/media-tv/plex-media-server/files/systemd/plex-media-server.service
new file mode 100644 (file)
index 0000000..304d563
--- /dev/null
@@ -0,0 +1,16 @@
+[Unit]
+Description=Plex Media Server
+After=network.target network-online.target
+
+[Service]
+ExecStart=/usr/sbin/start_pms
+Type=simple
+User=plex
+Group=plex
+Restart=on-failure
+RestartSec=5
+StartLimitInterval=60s
+StartLimitBurst=3
+
+[Install]
+WantedBy=multi-user.target
diff --git a/media-tv/plex-media-server/files/virtualenv_start_pms.patch b/media-tv/plex-media-server/files/virtualenv_start_pms.patch
new file mode 100644 (file)
index 0000000..c47f2fd
--- /dev/null
@@ -0,0 +1,12 @@
+--- a/usr/sbin/start_pms       2019-01-04 14:57:17.158769341 +0100
++++ b/usr/sbin/start_pms       2019-01-04 15:09:54.555128630 +0100
+@@ -20,6 +20,9 @@
+ test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver
++# Activate python virtualenv
++. "${PLEX_MEDIA_SERVER_HOME}"/Resources/Python/bin/activate
++
+ if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]
+ then
+   mkdir -p "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
diff --git a/media-tv/plex-media-server/metadata.xml b/media-tv/plex-media-server/metadata.xml
new file mode 100644 (file)
index 0000000..4f1b026
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+       <maintainer type="person">
+               <email>fearedbliss@gentoo.org</email>
+               <name>Jonathan Vasquez</name>
+       </maintainer>
+       <maintainer type="person">
+               <email>luigi.mantellini@gmail.com</email>
+               <name>Luigi 'Comio' Mantellini</name>
+       </maintainer>
+       <maintainer type="person">
+               <email>fkmclane@gmail.com</email>
+               <name>Foster McLane</name>
+       </maintainer>
+       <upstream>
+               <changelog>http://forums.plex.tv/discussion/62832/plex-media-server#latest</changelog>
+               <doc>https://support.plex.tv/hc/en-us/categories/200007268-Getting-Started</doc>
+       </upstream>
+       <use>
+               <flag name="pax_kernel">Add PaX markings to executables</flag>
+               <flag name="system-openssl">Use system openssl library</flag>
+               <flag name="avahi">Add net-dns/avahi dependency</flag>
+       </use>
+</pkgmetadata>
diff --git a/media-tv/plex-media-server/plex-media-server-1.18.6.2348.ebuild b/media-tv/plex-media-server/plex-media-server-1.18.6.2348.ebuild
new file mode 100644 (file)
index 0000000..b1a0ed7
--- /dev/null
@@ -0,0 +1,186 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit eutils systemd unpacker pax-utils
+
+COMMIT="fd90a1389"
+
+_APPNAME="plexmediaserver"
+_USERNAME="plex"
+_SHORTNAME="${_USERNAME}"
+_FULL_VERSION="${PV}-${COMMIT}"
+
+URI="https://downloads.plex.tv/plex-media-server-new"
+
+DESCRIPTION="A free media library that is intended for use with a plex client."
+HOMEPAGE="http://www.plex.tv/"
+SRC_URI="
+       amd64? ( ${URI}/${_FULL_VERSION}/debian/plexmediaserver_${_FULL_VERSION}_amd64.deb )
+       x86? ( ${URI}/${_FULL_VERSION}/debian/plexmediaserver_${_FULL_VERSION}_i386.deb )
+"
+
+SLOT="0"
+LICENSE="Plex"
+RESTRICT="mirror bindist strip"
+KEYWORDS="-* amd64 x86"
+
+IUSE="pax_kernel avahi"
+
+DEPEND="
+       pax_kernel? ( sys-apps/fix-gnustack )
+       dev-util/patchelf"
+
+RDEPEND="
+       acct-user/plex
+       acct-group/plex
+       avahi? ( net-dns/avahi )"
+
+QA_DESKTOP_FILE="usr/share/applications/plexmediamanager.desktop"
+QA_PREBUILT="*"
+QA_MULTILIB_PATHS=(
+       "usr/lib/${_APPNAME}/.*"
+       "usr/lib/${_APPNAME}/Resources/Python/lib/python2.7/.*"
+)
+
+EXECSTACKED_BINS=( )
+
+BINS_TO_PAX_MARK=(
+       "${ED%/}/usr/lib/plexmediaserver/Plex Script Host"
+       "${ED%/}/usr/lib/plexmediaserver/Plex Media Scanner"
+)
+BINS_TO_PAX_CREATE_FLAGS=( "${ED%/}/usr/lib/plexmediaserver/Resources/Python/bin/python" )
+
+S="${WORKDIR}"
+PATCHES=(
+       "${FILESDIR}/plexmediamanager.desktop.new.patch"
+       "${FILESDIR}/add_gentoo_profile_as_platform_version.patch"
+       "${FILESDIR}/20200129_add_gentoo_profile_as_platform_version.patch"
+)
+
+src_unpack() {
+       unpack_deb ${A}
+}
+
+src_install() {
+       # Move the config to the correct place
+       local CONFIG_VANILLA="/etc/default/plexmediaserver"
+       local CONFIG_PATH="/etc/${_SHORTNAME}"
+       dodir "${CONFIG_PATH}"
+       insinto "${CONFIG_PATH}"
+       if [[ -d "${S}/${CONFIG_VANILLA#/}" ]]; then
+               doins "${CONFIG_VANILLA#/}"
+       fi
+       sed -e "s#${CONFIG_VANILLA}#${CONFIG_PATH}/${_APPNAME}#g" -i "${S}"/usr/sbin/start_pms || die
+
+       # Remove Debian specific files
+       rm -rf "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
+       local LOGGING_DIR="/var/log/pms"
+       dodir "${LOGGING_DIR}"
+       chown "${_USERNAME}":"${_USERNAME}" "${ED%/}/${LOGGING_DIR}" || die
+       keepdir "${LOGGING_DIR}"
+
+       # Create default library folder with correct permissions
+       local DEFAULT_LIBRARY_DIR="/var/lib/${_APPNAME}"
+       dodir "${DEFAULT_LIBRARY_DIR}"
+       chown "${_USERNAME}":"${_USERNAME}" "${ED%/}/${DEFAULT_LIBRARY_DIR}" || die
+       keepdir "${DEFAULT_LIBRARY_DIR}"
+
+       # Install the OpenRC init/conf files depending on avahi.
+       if use avahi; then
+               doinitd "${FILESDIR}/init.d/${PN}"
+       else
+               cp "${FILESDIR}/init.d/${PN}" "${S}/${PN}";
+               sed -e '/depend/ s/^#*/#/' -i "${S}/${PN}"
+               sed -e '/need/ s/^#*/#/' -i "${S}/${PN}"
+               sed -e '1,/^}/s/^}/#}/' -i "${S}/${PN}"
+               doinitd "${S}/${PN}"
+       fi
+
+       doconfd "${FILESDIR}/conf.d/${PN}"
+
+       # Disabling due to Bug 644694
+       #_handle_multilib
+
+       # Mask Plex libraries so that revdep-rebuild doesn't try to rebuild them.
+       # Plex has its own precompiled libraries.
+       _mask_plex_libraries_revdep
+
+       # Install systemd service file
+       local UNIT_NAME="${PN}.service"
+       local UNIT="${S}/usr/lib/plexmediaserver/lib/plexmediaserver.service"
+       systemd_newunit "${UNIT}" "${UNIT_NAME}"
+
+       # Fix RPATH
+       patchelf --force-rpath --set-rpath '$ORIGIN:$ORIGIN/../../../../../../lib' "${ED%/}"/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/lib-dynload/_codecs_kr.so || die
+
+       # Add PaX marking for hardened systems
+       if use pax_kernel; then
+               _remove_execstack_markings
+               _add_pax_markings
+               _add_pax_flags
+       fi
+}
+
+pkg_postinst() {
+       einfo ""
+       elog "Plex Media Server is now installed. Please check the configuration file in /etc/${_SHORTNAME}/${_APPNAME} to verify the default settings."
+       elog "To start the Plex Server, run 'rc-config start plex-media-server', you will then be able to access your library at http://<ip>:32400/web/"
+       einfo ""
+       einfo "The fkmclane/overlay/${CATEGORY}-${PN} will not be supported and updated in the next future. Please migrate to comio/plex-overlay or"
+       einfo "another overlay if you prefer in order to have future updates."
+
+}
+
+# Disabling the follow function due to Bug 644694.
+# We shouldn't register plex libraries in global
+# library path since this will cause other packages
+# on the system to break.
+
+# Finds out where the library directory is for this system
+# and handles ldflags as to not break library dependencies
+# during rebuilds.
+_handle_multilib() {
+       # Prevent revdep-rebuild, @preserved-rebuild breakage
+       cat > "${T}"/66plex <<-EOF || die
+               LDPATH="${EPREFIX}/usr/$(get_libdir)/plexmediaserver"
+       EOF
+
+       doenvd "${T}"/66plex
+}
+
+# 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.
+_mask_plex_libraries_revdep() {
+       dodir /etc/revdep-rebuild/
+       echo "SEARCH_DIRS_MASK=\"${EPREFIX}/usr/$(get_libdir)/plexmediaserver\"" > "${ED%/}"/etc/revdep-rebuild/80plexmediaserver
+}
+
+# Remove execstack flags from some libraries/executables
+# so that it works in hardened setups.
+_remove_execstack_markings() {
+       for f in "${EXECSTACKED_BINS[@]}"; do
+               # Unquoting 'f' so that expansion works.
+               fix-gnustack -f ${f} > /dev/null
+       done
+}
+
+# Add pax markings to some binaries so that they work on hardened setup.
+_add_pax_markings() {
+       for f in "${BINS_TO_PAX_MARK[@]}"; do
+               pax-mark m "${f}"
+       done
+}
+
+# Create default PaX markings on virtualenvironment's pythin
+_add_pax_flags() {
+       for f in "${BINS_TO_PAX_CREATE_FLAGS[@]}"; do
+               pax-mark c "${F}"
+       done
+}