logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

mpv-0.34.1-r2.ebuild (9819B)


  1. # Copyright 1999-2022 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=7
  4. LUA_COMPAT=( lua5-{1..2} luajit )
  5. PYTHON_COMPAT=( python3_{8..10} )
  6. PYTHON_REQ_USE='threads(+)'
  7. WAF_PV=2.0.22
  8. inherit bash-completion-r1 flag-o-matic lua-single optfeature pax-utils python-r1 toolchain-funcs waf-utils xdg-utils
  9. DESCRIPTION="Media player based on MPlayer and mplayer2"
  10. HOMEPAGE="https://mpv.io/ https://github.com/mpv-player/mpv"
  11. if [[ ${PV} != *9999* ]]; then
  12. SRC_URI="https://github.com/mpv-player/mpv/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  13. KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux"
  14. DOCS=( RELEASE_NOTES )
  15. else
  16. EGIT_REPO_URI="https://github.com/mpv-player/mpv.git"
  17. inherit git-r3
  18. DOCS=(); SRC_URI=""
  19. fi
  20. SRC_URI+=" https://waf.io/waf-${WAF_PV}"
  21. DOCS+=( README.md DOCS/{client-api,interface}-changes.rst )
  22. # See Copyright in sources and Gentoo bug 506946. Waf is BSD, libmpv is ISC.
  23. LICENSE="LGPL-2.1+ GPL-2+ BSD ISC"
  24. SLOT="0"
  25. IUSE="+alsa aqua archive bluray cdda +cli coreaudio cplugins debug doc drm dvb
  26. dvd +egl gamepad gbm +iconv jack javascript jpeg lcms libcaca libmpv +lua
  27. nvenc openal +opengl pulseaudio raspberry-pi rubberband sdl
  28. selinux sndio test tools +uchardet vaapi vdpau vulkan wayland +X +xv zlib zimg"
  29. REQUIRED_USE="
  30. || ( cli libmpv )
  31. aqua? ( opengl )
  32. egl? ( || ( gbm X wayland ) )
  33. gamepad? ( sdl )
  34. gbm? ( drm egl opengl )
  35. lcms? ( opengl )
  36. lua? ( ${LUA_REQUIRED_USE} )
  37. nvenc? ( opengl )
  38. opengl? ( || ( aqua egl X raspberry-pi !cli ) )
  39. raspberry-pi? ( opengl )
  40. test? ( opengl )
  41. tools? ( cli )
  42. uchardet? ( iconv )
  43. vaapi? ( || ( gbm X wayland ) )
  44. vdpau? ( X )
  45. vulkan? ( || ( X wayland ) )
  46. wayland? ( egl )
  47. X? ( egl? ( opengl ) )
  48. xv? ( X )
  49. ${PYTHON_REQUIRED_USE}
  50. "
  51. RESTRICT="!test? ( test )"
  52. COMMON_DEPEND="
  53. >=media-video/ffmpeg-4.0:0=[encode,threads,vaapi?,vdpau?]
  54. alsa? ( >=media-libs/alsa-lib-1.0.18 )
  55. archive? ( >=app-arch/libarchive-3.4.0:= )
  56. bluray? ( >=media-libs/libbluray-0.3.0:= )
  57. cdda? ( dev-libs/libcdio-paranoia
  58. dev-libs/libcdio:= )
  59. drm? ( x11-libs/libdrm )
  60. dvd? (
  61. >=media-libs/libdvdnav-4.2.0:=
  62. >=media-libs/libdvdread-4.1.0:=
  63. )
  64. egl? ( media-libs/mesa[egl(+),gbm(+)?,wayland(-)?] )
  65. gamepad? ( media-libs/libsdl2 )
  66. iconv? (
  67. virtual/libiconv
  68. uchardet? ( app-i18n/uchardet )
  69. )
  70. jack? ( virtual/jack )
  71. javascript? ( >=dev-lang/mujs-1.0.0 )
  72. jpeg? ( virtual/jpeg:0 )
  73. lcms? ( >=media-libs/lcms-2.6:2 )
  74. >=media-libs/libass-0.12.1:=[fontconfig,harfbuzz(+)]
  75. virtual/ttf-fonts
  76. libcaca? ( >=media-libs/libcaca-0.99_beta18 )
  77. lua? ( ${LUA_DEPS} )
  78. openal? ( >=media-libs/openal-1.13 )
  79. pulseaudio? ( media-sound/pulseaudio )
  80. raspberry-pi? ( >=media-libs/raspberrypi-userland-0_pre20160305-r1 )
  81. rubberband? ( >=media-libs/rubberband-1.8.0 )
  82. sdl? ( media-libs/libsdl2[sound,threads,video] )
  83. sndio? ( media-sound/sndio:= )
  84. vaapi? ( x11-libs/libva:=[drm(+)?,X?,wayland?] )
  85. vdpau? ( x11-libs/libvdpau )
  86. vulkan? (
  87. >=media-libs/libplacebo-3.104.0:=[vulkan]
  88. media-libs/shaderc
  89. )
  90. wayland? (
  91. >=dev-libs/wayland-1.6.0
  92. >=dev-libs/wayland-protocols-1.14
  93. >=x11-libs/libxkbcommon-0.3.0
  94. )
  95. X? (
  96. x11-libs/libX11
  97. x11-libs/libXScrnSaver
  98. x11-libs/libXext
  99. x11-libs/libXinerama
  100. x11-libs/libXrandr
  101. opengl? (
  102. x11-libs/libXdamage
  103. virtual/opengl
  104. )
  105. xv? ( x11-libs/libXv )
  106. )
  107. zlib? ( sys-libs/zlib )
  108. zimg? ( >=media-libs/zimg-2.9.2 )
  109. "
  110. DEPEND="${COMMON_DEPEND}
  111. ${PYTHON_DEPS}
  112. dvb? ( virtual/linuxtv-dvb-headers )
  113. nvenc? ( >=media-libs/nv-codec-headers-8.2.15.7 )
  114. "
  115. RDEPEND="${COMMON_DEPEND}
  116. nvenc? ( x11-drivers/nvidia-drivers[X] )
  117. selinux? ( sec-policy/selinux-mplayer )
  118. tools? ( ${PYTHON_DEPS} )
  119. "
  120. BDEPEND="dev-python/docutils
  121. virtual/pkgconfig
  122. test? ( >=dev-util/cmocka-1.0.0 )
  123. "
  124. PATCHES=(
  125. "${FILESDIR}/mpv-0.33.1-sndio_pr9298.patch"
  126. )
  127. pkg_setup() {
  128. use lua && lua-single_pkg_setup
  129. }
  130. src_prepare() {
  131. cp "${DISTDIR}/waf-${WAF_PV}" "${S}"/waf || die
  132. chmod +x "${S}"/waf || die
  133. default
  134. }
  135. src_configure() {
  136. python_setup
  137. tc-export CC PKG_CONFIG AR
  138. if use raspberry-pi; then
  139. append-cflags -I"${ESYSROOT}/opt/vc/include"
  140. append-ldflags -L"${ESYSROOT}/opt/vc/lib"
  141. fi
  142. local mywafargs=(
  143. --confdir="${EPREFIX}/etc/${PN}"
  144. $(usex cli '' '--disable-cplayer')
  145. $(use_enable libmpv libmpv-shared)
  146. --disable-libmpv-static
  147. --disable-static-build
  148. # See deep down below for build-date.
  149. --disable-optimize # Don't add '-O2' to CFLAGS.
  150. $(usex debug '' '--disable-debug-build')
  151. $(use_enable doc html-build)
  152. --disable-pdf-build
  153. --enable-manpage-build
  154. $(use_enable cplugins)
  155. $(use_enable test)
  156. $(use_enable iconv)
  157. $(use_enable lua)
  158. $(use_enable javascript)
  159. $(use_enable zlib)
  160. $(use_enable bluray libbluray)
  161. $(use_enable dvd dvdnav)
  162. $(use_enable cdda)
  163. $(use_enable uchardet)
  164. $(use_enable rubberband)
  165. $(use_enable lcms lcms2)
  166. --disable-vapoursynth # Only available in overlays.
  167. $(use_enable archive libarchive)
  168. --enable-libavdevice
  169. # Audio outputs:
  170. $(use_enable sdl sdl2) # Listed under audio, but also includes video.
  171. $(use_enable pulseaudio pulse)
  172. $(use_enable sndio)
  173. $(use_enable jack)
  174. $(use_enable openal)
  175. --disable-opensles
  176. $(use_enable alsa)
  177. $(use_enable coreaudio)
  178. # Video outputs:
  179. $(use_enable aqua cocoa)
  180. $(use_enable drm)
  181. $(use_enable gbm)
  182. $(use_enable wayland wayland-scanner)
  183. $(use_enable wayland wayland-protocols)
  184. $(use_enable wayland)
  185. $(use_enable X x11)
  186. $(use_enable xv)
  187. $(usex opengl "$(use_enable aqua gl-cocoa)" '--disable-gl-cocoa')
  188. $(usex opengl "$(use_enable X gl-x11)" '--disable-gl-x11')
  189. $(usex egl "$(use_enable X egl-x11)" '--disable-egl-x11')
  190. $(usex egl "$(use_enable gbm egl-drm)" '--disable-egl-drm')
  191. $(usex opengl "$(use_enable wayland gl-wayland)" '--disable-gl-wayland')
  192. $(use_enable vdpau)
  193. $(usex vdpau "$(use_enable opengl vdpau-gl-x11)" '--disable-vdpau-gl-x11')
  194. $(use_enable vaapi) # See below for vaapi-glx, vaapi-x-egl.
  195. $(usex vaapi "$(use_enable X vaapi-x11)" '--disable-vaapi-x11')
  196. $(usex vaapi "$(use_enable wayland vaapi-wayland)" '--disable-vaapi-wayland')
  197. $(usex vaapi "$(use_enable gbm vaapi-drm)" '--disable-vaapi-drm')
  198. $(use_enable libcaca caca)
  199. $(use_enable jpeg)
  200. $(use_enable vulkan shaderc)
  201. $(use_enable vulkan libplacebo)
  202. $(use_enable raspberry-pi rpi)
  203. $(usex libmpv "$(use_enable opengl plain-gl)" '--disable-plain-gl')
  204. $(usex opengl '' '--disable-gl')
  205. $(use_enable vulkan)
  206. $(use_enable gamepad sdl2-gamepad)
  207. # HWaccels:
  208. # Automagic Video Toolbox HW acceleration. See Gentoo bug 577332.
  209. $(use_enable nvenc cuda-hwaccel)
  210. $(use_enable nvenc cuda-interop)
  211. # TV features:
  212. $(use_enable dvb dvbin)
  213. # Miscellaneous features:
  214. $(use_enable zimg)
  215. )
  216. if use lua; then
  217. if use lua_single_target_luajit; then
  218. mywafargs+=( --lua="luajit" )
  219. else
  220. # Because it would be too simple to just let the user directly
  221. # specify the package name to check, wouldn't it.
  222. mywafargs+=( --lua="$(ver_rs 1 '' $(ver_cut 1-2 $(lua_get_version)))" )
  223. fi
  224. fi
  225. if use vaapi && use X; then
  226. mywafargs+=(
  227. $(use_enable egl vaapi-x-egl)
  228. )
  229. fi
  230. # Not for us
  231. mywafargs+=(
  232. --disable-android
  233. --disable-egl-android
  234. --disable-uwp
  235. --disable-audiounit
  236. --disable-macos-media-player
  237. --disable-wasapi
  238. --disable-ios-gl
  239. --disable-macos-touchbar
  240. --disable-macos-cocoa-cb
  241. --disable-tvos
  242. --disable-egl-angle-win32
  243. )
  244. mywafargs+=(
  245. --bashdir="$(get_bashcompdir)"
  246. --zshdir="${EPREFIX}"/usr/share/zsh/site-functions
  247. )
  248. # Create reproducible non-live builds.
  249. [[ ${PV} != *9999* ]] && mywafargs+=(--disable-build-date)
  250. waf-utils_src_configure "${mywafargs[@]}"
  251. }
  252. src_install() {
  253. waf-utils_src_install
  254. if use lua; then
  255. insinto /usr/share/${PN}
  256. doins -r TOOLS/lua
  257. fi
  258. if use cli && use lua_single_target_luajit; then
  259. pax-mark -m "${ED}"/usr/bin/${PN}
  260. fi
  261. if use tools; then
  262. dobin TOOLS/{mpv_identify.sh,umpv}
  263. newbin TOOLS/idet.sh mpv_idet.sh
  264. python_replicate_script "${ED}"/usr/bin/umpv
  265. fi
  266. }
  267. pkg_postinst() {
  268. local rv softvol_0_18_1=0 osc_0_21_0=0 txtsubs_0_24_0=0 opengl_0_25_0=0
  269. for rv in ${REPLACING_VERSIONS}; do
  270. ver_test ${rv} -lt 0.18.1 && softvol_0_18_1=1
  271. ver_test ${rv} -lt 0.21.0 && osc_0_21_0=1
  272. ver_test ${rv} -lt 0.24.0 && txtsubs_0_24_0=1
  273. ver_test ${rv} -lt 0.25.0 && ! use opengl && opengl_0_25_0=1
  274. done
  275. if [[ ${softvol_0_18_1} -eq 1 ]]; then
  276. elog "Since version 0.18.1 the software volume control is always enabled."
  277. elog "This means that volume controls don't change the system volume,"
  278. elog "e.g. per-application volume with PulseAudio."
  279. elog "If you want to restore the previous behaviour, please refer to"
  280. elog
  281. elog "https://wiki.gentoo.org/wiki/Mpv#Volume_in_0.18.1"
  282. elog
  283. fi
  284. if [[ ${osc_0_21_0} -eq 1 ]]; then
  285. elog "In version 0.21.0 the default OSC layout was changed."
  286. elog "If you want to restore the previous layout, please refer to"
  287. elog
  288. elog "https://wiki.gentoo.org/wiki/Mpv#OSC_in_0.21.0"
  289. elog
  290. fi
  291. if [[ ${txtsubs_0_24_0} -eq 1 ]]; then
  292. elog "Since version 0.24.0 subtitles with .txt extension aren't autoloaded."
  293. elog "If you want to restore the previous behaviour, please refer to"
  294. elog
  295. elog "https://wiki.gentoo.org/wiki/Mpv#Subtitles_with_.txt_extension_in_0.24.0"
  296. elog
  297. fi
  298. if [[ ${opengl_0_25_0} -eq 1 ]]; then
  299. elog "Since version 0.25.0 the 'opengl' USE flag is mapped to"
  300. elog "the 'opengl' video output and no longer explicitly requires"
  301. elog "X11 or Mac OS Aqua. Consider enabling the 'opengl' USE flag."
  302. fi
  303. optfeature "URL support" net-misc/yt-dlp
  304. xdg_icon_cache_update
  305. xdg_desktop_database_update
  306. }
  307. pkg_postrm() {
  308. xdg_icon_cache_update
  309. xdg_desktop_database_update
  310. }
  311. src_test() {
  312. cd "${S}"/build/test || die
  313. local test
  314. for test in *; do
  315. if [[ -x ${test} ]]; then
  316. ./"${test}" || die "Test suite failed"
  317. fi
  318. done
  319. }