Gentoo Archives: gentoo-commits

From: Samuel Bernardo <samuelbernardo.mail@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/user/ssnb:master commit in: media-tv/plex-media-server/files/conf.d/, ...
Date: Sun, 17 Nov 2019 18:10:01
Message-Id: 1574014179.6c00ff512c00d323750bc540a1f566b1a4f17128.samuelbernardo@gentoo
1 commit: 6c00ff512c00d323750bc540a1f566b1a4f17128
2 Author: Samuel Bernardo <samuelbernardo.mail <AT> gmail <DOT> com>
3 AuthorDate: Sun Nov 17 18:09:39 2019 +0000
4 Commit: Samuel Bernardo <samuelbernardo.mail <AT> gmail <DOT> com>
5 CommitDate: Sun Nov 17 18:09:39 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/user/ssnb.git/commit/?id=6c00ff51
7
8 add plex media server
9
10 Signed-off-by: Samuel Bernardo <samuelbernardo.mail <AT> gmail.com>
11
12 media-tv/plex-media-server/Manifest | 8 +
13 .../files/conf.d/plex-media-server | 7 +
14 .../files/init.d/plex-media-server | 20 +++
15 .../files/systemd/plex-media-server.service | 11 ++
16 .../files/virtualenv_start_pms.patch | 23 +++
17 media-tv/plex-media-server/metadata.xml | 8 +
18 .../plex-media-server-1.18.2.ebuild | 162 +++++++++++++++++++++
19 7 files changed, 239 insertions(+)
20
21 diff --git a/media-tv/plex-media-server/Manifest b/media-tv/plex-media-server/Manifest
22 new file mode 100644
23 index 0000000..92b2555
24 --- /dev/null
25 +++ b/media-tv/plex-media-server/Manifest
26 @@ -0,0 +1,8 @@
27 +AUX conf.d/plex-media-server 216 BLAKE2B 094d0f6f7cdfa696ae47d7879c7459be5755dfe02a12c3ee986c1078ae0a46d974adc25dce252a49c3fd72e0dfe1ba65c49d575e12036fba44ce9b0390da64ec SHA512 d3d68fa58a1c1064803a9607708123302890571e823e5bc26de741bb15bd51db19234636672ff01757cbbcdb984c60663545689fa915761c78c3cf49e6da0f95
28 +AUX init.d/plex-media-server 413 BLAKE2B f60fe9f653c591cddaf77a0ebcb47218681a63235e82bc016c7d2ee9180df7f6ff24f3784216ea370bdc2d493531492f196200b6ec56ff8b303e69adaa0f108d SHA512 aeb873a00081f20abd27cc76d395908ae0643bd8aa665557adafef2ed97edbe93c18b55818b49227746f9c3ce4b7a81ceb9132f07d8d873bc7b5a932b944a402
29 +AUX systemd/plex-media-server.service 159 BLAKE2B d4988890f6424e0b9160e90df0125fbcb32e86443c5b869f66ac6e28c3701fdaa3dd819823edd0c8675792bf4e24e7fcf3bb8894e55539ad8fc5eb9ac9a550fc SHA512 9066840efa43b127dd0d4b26ea0552894db97bf48f89003258095986e7d4728e05bee2f49de856777ed3d0b5ec41654c14505bc9867b227b754aeecd0529abd6
30 +AUX virtualenv_start_pms.patch 839 BLAKE2B 20d6a53b40a2c714153bc7f04c2bbad568b75197cd450cb52129cc3718fad1db09f9fe2a92e8608e1e95b710e0b4af58a373650ab4017438b63fe61132f13d75 SHA512 55fb8f3234942d10c0d6d1820fbab48b8a9f26f069031946dae551cde8b7d18d61ef36ec994719d2519687dc75e5ec27205702395a8af112bda720b7a62072aa
31 +DIST plexmediaserver_1.18.2.2029-36236cc4c_amd64.deb 86133786 BLAKE2B b33a53e48b190b70cc3cc2b7aa0b311a7e0f18423473fb45805cfaf60417eacb59f4e46aaa66b63f1511e4eff4ebbf6d2f3a8e905a7c7487cfdcedb119ed9959 SHA512 e0f3c4fde6cdd010314843457ac89407361046ad2ff69d919f2ac6b22d92bf96f89c63152eaa04c6071baa32eff747d56c23fc4a678d5700f2f98793a2fd3dd3
32 +DIST plexmediaserver_1.18.2.2029-36236cc4c_i386.deb 72963886 BLAKE2B 28b09dbaedad1394627231ce7747c7b6b6af8d6f8a0b9eec6bc9728dd7206d0a2f733f69109133c16c5a776c06c51b3c9e511cb53c46eb2345d27c1f1b1de650 SHA512 ed091de6593cd7a9a8c5c1b2c776a405816276f8902d352ed4cf251857cce191ea00a2ada58ace525b97c9ffbd675f756384f420fba7edc4ab056aaafec5acb9
33 +EBUILD plex-media-server-1.18.2.ebuild 5214 BLAKE2B 0c5c770dade237ec662a536623af23ba69013a3d526b2816d5783f6fa0ab173c3efcd0f4ebbab881940fd948adf592c33b169bf75569b681acef7547a7255d51 SHA512 a64d2b254b02d6a62560f6686fdd34d614a51cc5028d98046b23f585f4d47376fccae1a1302c282d8655f92ffd39f377aef3dec745cf0f464b8ccf43c5959e3b
34 +MISC metadata.xml 245 BLAKE2B 94154a8bdd62b19999d65d599876471c8e44c02209c12a20d75667a21eb873ad59b42d27536d54ff1274d57bad9d73d81eaacea36b8b02e01b40b9eb5e6c82d4 SHA512 c3c7907e50537dd94fdcec1da306eee2f050e5a456d369cd3df8c9bf36c810d811fe547418a8025e533916eb52a742d9feafae647b2957820d99ed962dad302e
35
36 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
37 new file mode 100644
38 index 0000000..7fe754f
39 --- /dev/null
40 +++ b/media-tv/plex-media-server/files/conf.d/plex-media-server
41 @@ -0,0 +1,7 @@
42 +# Config file for /etc/init.d/plex-media-server
43 +
44 +PLEX_PIDFILE="/var/run/plex-media-server.pid"
45 +PLEX_OUTLOG="/var/log/pms/out.log"
46 +PLEX_ERRLOG="/var/log/pms/err.log"
47 +PLEX_USER="plex"
48 +PLEX_SCRIPT="/usr/sbin/start_pms"
49
50 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
51 new file mode 100755
52 index 0000000..102ac80
53 --- /dev/null
54 +++ b/media-tv/plex-media-server/files/init.d/plex-media-server
55 @@ -0,0 +1,20 @@
56 +#!/sbin/openrc-run
57 +
58 +depend() {
59 + need avahi-daemon
60 +}
61 +
62 +start() {
63 + ebegin "Starting Plex Media Server"
64 + start-stop-daemon -S -m -p ${PLEX_PIDFILE} -1 ${PLEX_OUTLOG} -2 ${PLEX_ERRLOG} --quiet -u ${PLEX_USER} -N -5 -b --exec ${PLEX_SCRIPT}
65 + eend $?
66 +}
67 +
68 +stop() {
69 + ebegin "Stopping Plex Media Server"
70 + kill -- -`cat ${PLEX_PIDFILE}`
71 +
72 + # Remove stale pid file since this is a dirty solution
73 + rm ${PLEX_PIDFILE}
74 + eend $?
75 +}
76
77 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
78 new file mode 100644
79 index 0000000..12412a8
80 --- /dev/null
81 +++ b/media-tv/plex-media-server/files/systemd/plex-media-server.service
82 @@ -0,0 +1,11 @@
83 +[Unit]
84 +Description=Plex Media Server
85 +After=network.target
86 +
87 +[Service]
88 +Type=simple
89 +User=plex
90 +ExecStart=/usr/sbin/start_pms
91 +
92 +[Install]
93 +WantedBy=multi-user.target
94
95 diff --git a/media-tv/plex-media-server/files/virtualenv_start_pms.patch b/media-tv/plex-media-server/files/virtualenv_start_pms.patch
96 new file mode 100644
97 index 0000000..bb4d575
98 --- /dev/null
99 +++ b/media-tv/plex-media-server/files/virtualenv_start_pms.patch
100 @@ -0,0 +1,23 @@
101 +--- a/usr/sbin/start_pms 2017-03-01 13:35:28.340489280 -0500
102 ++++ b/usr/sbin/start_pms 2017-03-01 13:36:05.574540305 -0500
103 +@@ -8,16 +8,20 @@
104 + export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support"
105 + if [ -f /etc/default/locale ]; then
106 + export LANG="`cat /etc/default/locale|awk -F '=' '/LANG=/{print $2}'|sed 's/"//g'`"
107 + export LC_ALL="$LANG"
108 + fi
109 +
110 + test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver
111 +
112 ++# Activate python virtualenv
113 ++. "${PLEX_MEDIA_SERVER_HOME}"/Resources/Python/bin/activate
114 ++
115 ++
116 + if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]
117 + then
118 + mkdir -p "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
119 + if [ ! $? -eq 0 ]
120 + then
121 + echo "WARNING COULDN'T CREATE $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, MAKE SURE I HAVE PERMISSON TO DO THAT!"
122 + exit 1
123 + fi
124
125 diff --git a/media-tv/plex-media-server/metadata.xml b/media-tv/plex-media-server/metadata.xml
126 new file mode 100644
127 index 0000000..1a06e96
128 --- /dev/null
129 +++ b/media-tv/plex-media-server/metadata.xml
130 @@ -0,0 +1,8 @@
131 +<?xml version="1.0" encoding="UTF-8"?>
132 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
133 +<pkgmetadata>
134 + <maintainer type="person">
135 + <email>chainsaw@g.o</email>
136 + <name>Tony Vroon</name>
137 + </maintainer>
138 +</pkgmetadata>
139
140 diff --git a/media-tv/plex-media-server/plex-media-server-1.18.2.ebuild b/media-tv/plex-media-server/plex-media-server-1.18.2.ebuild
141 new file mode 100644
142 index 0000000..ff689da
143 --- /dev/null
144 +++ b/media-tv/plex-media-server/plex-media-server-1.18.2.ebuild
145 @@ -0,0 +1,162 @@
146 +# Copyright 1999-2019 Gentoo Authors
147 +# Distributed under the terms of the GNU General Public License v2
148 +
149 +EAPI=7
150 +
151 +PYTHON_COMPAT=( python2_7 )
152 +inherit eutils user systemd unpacker pax-utils python-single-r1
153 +
154 +MINOR_VERSION="2029-36236cc4c"
155 +
156 +_APPNAME="plexmediaserver"
157 +_USERNAME="plex"
158 +_SHORTNAME="${_USERNAME}"
159 +_FULL_VERSION="${PV}.${MINOR_VERSION}"
160 +
161 +URI="https://downloads.plex.tv/plex-media-server-new"
162 +
163 +DESCRIPTION="A free media library that is intended for use with a plex client."
164 +HOMEPAGE="https://www.plex.tv/"
165 +SRC_URI="amd64? ( ${URI}/${_FULL_VERSION}/debian/plexmediaserver_${_FULL_VERSION}_amd64.deb )
166 + x86? ( ${URI}/${_FULL_VERSION}/debian/plexmediaserver_${_FULL_VERSION}_i386.deb )"
167 +SLOT="0"
168 +LICENSE="Plex"
169 +RESTRICT="bindist strip"
170 +KEYWORDS="-* ~x86 ~amd64"
171 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
172 +
173 +DEPEND="
174 + sys-apps/fix-gnustack
175 + dev-python/virtualenv[${PYTHON_USEDEP}]"
176 +
177 +RDEPEND="
178 + net-dns/avahi
179 + ${PYTHON_DEPS}"
180 +
181 +QA_DESKTOP_FILE="usr/share/applications/plexmediamanager.desktop"
182 +QA_PREBUILT="*"
183 +QA_MULTILIB_PATHS=(
184 + "usr/lib/${_APPNAME}/.*"
185 + "usr/lib/${_APPNAME}/Resources/Python/lib/python2.7/.*"
186 +)
187 +
188 +EXECSTACKED_BINS=( "${ED}/usr/lib/plexmediaserver/libgnsdk_dsp.so*" )
189 +BINS_TO_PAX_MARK=( "${ED}/usr/lib/plexmediaserver/Plex Script Host" )
190 +
191 +S="${WORKDIR}"
192 +PATCHES=( "${FILESDIR}/virtualenv_start_pms.patch" )
193 +
194 +pkg_setup() {
195 + enewgroup ${_USERNAME}
196 + enewuser ${_USERNAME} -1 /bin/bash /var/lib/${_APPNAME} "${_USERNAME},video"
197 + python-single-r1_pkg_setup
198 +}
199 +
200 +src_unpack() {
201 + unpack_deb ${A}
202 +}
203 +
204 +src_install() {
205 + # Move the config to the correct place
206 + local CONFIG_VANILLA="/etc/default/plexmediaserver"
207 + local CONFIG_PATH="/etc/${_SHORTNAME}"
208 + dodir "${CONFIG_PATH}"
209 + insinto "${CONFIG_PATH}"
210 + doins "${CONFIG_VANILLA#/}"
211 + sed -e "s#${CONFIG_VANILLA}#${CONFIG_PATH}/${_APPNAME}#g" -i "${S}"/usr/sbin/start_pms || die
212 +
213 + # Remove Debian specific files
214 + rm -rf "usr/share/doc" || die
215 +
216 + # Copy main files over to image and preserve permissions so it is portable
217 + cp -rp usr/ "${ED}"/ || die
218 +
219 + # Make sure the logging directory is created
220 + local LOGGING_DIR="/var/log/pms"
221 + dodir "${LOGGING_DIR}"
222 + chown "${_USERNAME}":"${_USERNAME}" "${ED}/${LOGGING_DIR}" || die
223 + keepdir "${LOGGING_DIR}"
224 +
225 + # Create default library folder with correct permissions
226 + local DEFAULT_LIBRARY_DIR="/var/lib/${_APPNAME}"
227 + dodir "${DEFAULT_LIBRARY_DIR}"
228 + chown "${_USERNAME}":"${_USERNAME}" "${ED}/${DEFAULT_LIBRARY_DIR}" || die
229 + keepdir "${DEFAULT_LIBRARY_DIR}"
230 +
231 + # Install the OpenRC init/conf files
232 + doinitd "${FILESDIR}/init.d/${PN}"
233 + doconfd "${FILESDIR}/conf.d/${PN}"
234 +
235 + # Disabling due to Bug 644694
236 + #_handle_multilib
237 +
238 + # Mask Plex libraries so that revdep-rebuild doesn't try to rebuild them.
239 + # Plex has its own precompiled libraries.
240 + _mask_plex_libraries_revdep
241 +
242 + # Install systemd service file
243 + local INIT_NAME="${PN}.service"
244 + local INIT="${FILESDIR}/systemd/${INIT_NAME}"
245 + systemd_newunit "${INIT}" "${INIT_NAME}"
246 +
247 + _remove_execstack_markings
248 + _add_pax_markings
249 +
250 + einfo "Configuring virtualenv"
251 + virtualenv -v --no-pip --no-setuptools --no-wheel "${ED}"/usr/lib/plexmediaserver/Resources/Python || die
252 + pushd "${ED}"/usr/lib/plexmediaserver/Resources/Python &>/dev/null || die
253 + find . -type f -exec sed -i -e "s#${D}##g" {} + || die
254 + popd &>/dev/null || die
255 +}
256 +
257 +pkg_postinst() {
258 + einfo ""
259 + elog "Plex Media Server is now installed. Please check the configuration file in /etc/${_SHORTNAME}/${_APPNAME} to verify the default settings."
260 + 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/"
261 +}
262 +
263 +# Disabling the follow function due to Bug 644694.
264 +# We shouldn't register plex libraries in global
265 +# library path since this will cause other packages
266 +# on the system to break.
267 +
268 +# Finds out where the library directory is for this system
269 +# and handles ldflags as to not break library dependencies
270 +# during rebuilds.
271 +_handle_multilib() {
272 + # Prevent revdep-rebuild, @preserved-rebuild breakage
273 + cat > "${T}"/66plex <<-EOF || die
274 + LDPATH="${EPREFIX}/usr/$(get_libdir)/plexmediaserver"
275 + EOF
276 +
277 + doenvd "${T}"/66plex
278 +}
279 +
280 +# Adds the precompiled plex libraries to the revdep-rebuild's mask list
281 +# so it doesn't try to rebuild libraries that can't be rebuilt.
282 +_mask_plex_libraries_revdep() {
283 + dodir /etc/revdep-rebuild/
284 +
285 + # Bug: 659702. The upstream plex binary installs its precompiled package to /usr/lib.
286 + # Due to profile 17.1 splitting /usr/lib and /usr/lib64, we can no longer rely
287 + # on the implicit symlink automatically satisfying our revdep requirement when we use $(get_libdir).
288 + # Thus we will match upstream's directory automatically. If upstream switches their location,
289 + # then so should we.
290 + echo "SEARCH_DIRS_MASK=\"${EPREFIX}/usr/lib/plexmediaserver\"" > "${ED}"/etc/revdep-rebuild/80plexmediaserver
291 +}
292 +
293 +# Remove execstack flags from some libraries/executables
294 +# so that it works in hardened setups.
295 +_remove_execstack_markings() {
296 + for f in "${EXECSTACKED_BINS[@]}"; do
297 + # Unquoting 'f' so that expansion works.
298 + fix-gnustack -f ${f} > /dev/null
299 + done
300 +}
301 +
302 +# Add pax markings to some binaries so that they work on hardened setup.
303 +_add_pax_markings() {
304 + for f in "${BINS_TO_PAX_MARK[@]}"; do
305 + pax-mark m "${f}"
306 + done
307 +}