1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
7 inherit eutils systemd unpacker pax-utils
9 MINOR_VERSION="3608-f7262c352"
10 _APPNAME="plexmediaserver"
12 _SHORTNAME="${_USERNAME}"
13 _FULL_VERSION="${PV}.${MINOR_VERSION}"
15 URI="https://downloads.plex.tv/plex-media-server-new"
17 DESCRIPTION="A free media library that is intended for use with a plex client"
18 HOMEPAGE="https://www.plex.tv/"
20 amd64? ( ${URI}/${_FULL_VERSION}/debian/plexmediaserver_${_FULL_VERSION}_amd64.deb )
21 x86? ( ${URI}/${_FULL_VERSION}/debian/plexmediaserver_${_FULL_VERSION}_i386.deb )
25 RESTRICT="bindist strip mirror"
26 KEYWORDS="-* ~amd64 ~x86"
28 BDEPEND="dev-util/patchelf"
35 QA_DESKTOP_FILE="usr/share/applications/plexmediamanager.desktop"
38 "usr/lib/${_APPNAME}/.*"
39 "usr/lib/${_APPNAME}/Resources/Python/lib/python2.7/.*"
43 "${ED}/usr/lib/plexmediaserver/Plex Script Host"
44 "${ED}/usr/lib/plexmediaserver/Plex Media Scanner"
49 "${FILESDIR}/plexmediamanager.desktop.new.patch"
50 "${FILESDIR}/plexmediaserver.service.patch"
58 # Remove Debian apt repo files
59 rm -r "etc/apt" || die
61 # Remove Debian specific files
62 rm -r "usr/share/doc" || die
64 # Copy main files over to image and preserve permissions so it is portable
65 cp -rp usr/ "${ED}"/ || die
67 # Make sure the logging directory is created
68 local logging_dir="/var/log/pms"
69 dodir "${logging_dir}"
70 fowners "${_USERNAME}":"${_USERNAME}" "${logging_dir}"
71 keepdir "${logging_dir}"
73 # Create default library folder with correct permissions
74 local default_library_dir="/var/lib/${_APPNAME}"
75 dodir "${default_library_dir}"
76 fowners "${_USERNAME}":"${_USERNAME}" "${default_library_dir}"
77 keepdir "${default_library_dir}"
79 # Install the OpenRC init/conf files
80 doinitd "${FILESDIR}/init.d/${PN}"
81 doconfd "${FILESDIR}/conf.d/${PN}"
83 # Mask Plex libraries so that revdep-rebuild doesn't try to rebuild them.
84 # Plex has its own precompiled libraries.
85 _mask_plex_libraries_revdep
88 patchelf --force-rpath --set-rpath '$ORIGIN:$ORIGIN/../../../../../../lib' "${ED}"/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/lib-dynload/_codecs_kr.so || die
90 # Install systemd service file
91 systemd_newunit "${ED}"/usr/lib/plexmediaserver/lib/plexmediaserver.service "${PN}.service"
93 # Add pax markings to some binaries so that they work on hardened setup
94 for f in "${BINS_TO_PAX_MARK[@]}"; do
100 elog "Plex Media Server is now installed. Please check the configuration"
101 elog "file in /etc/${_SHORTNAME}/${_APPNAME}"
102 elog "to verify the default settings."
103 elog "To start the Plex Server, run 'rc-config start plex-media-server',"
104 elog "you will then be able to access your library at"
105 elog "http://<ip>:32400/web/"
108 # Adds the precompiled plex libraries to the revdep-rebuild's mask list
109 # so it doesn't try to rebuild libraries that can't be rebuilt.
110 _mask_plex_libraries_revdep() {
111 dodir /etc/revdep-rebuild/
113 # Bug: 659702. The upstream plex binary installs its precompiled package to /usr/lib.
114 # Due to profile 17.1 splitting /usr/lib and /usr/lib64, we can no longer rely
115 # on the implicit symlink automatically satisfying our revdep requirement when we use $(get_libdir).
116 # Thus we will match upstream's directory automatically. If upstream switches their location,
118 echo "SEARCH_DIRS_MASK=\"${EPREFIX}/usr/lib/plexmediaserver\"" > "${ED}"/etc/revdep-rebuild/80plexmediaserver