mythtv-0.27.6_p20160318-r1.ebuild 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. # git diff --relative=mythtv v0.27.6.. > ~/mythtv-0.27.6/patches/mythtv.patch
  6. BACKPORTS="b6ae90c071a9a8eac9873fae988d5eb2434f3160"
  7. MY_P=${P%_p*}
  8. MY_PV=${PV%_p*}
  9. inherit flag-o-matic multilib eutils python-single-r1 user systemd vcs-snapshot
  10. MYTHTV_BRANCH="fixes/0.27"
  11. DESCRIPTION="Homebrew PVR project"
  12. HOMEPAGE="http://www.mythtv.org"
  13. SRC_URI="https://github.com/MythTV/mythtv/archive/${BACKPORTS}.tar.gz -> ${P}.tar.gz"
  14. SLOT="0/${PV}"
  15. LICENSE="GPL-2"
  16. KEYWORDS="amd64 x86"
  17. IUSE_INPUT_DEVICES="input_devices_joystick"
  18. IUSE="alsa altivec libass autostart bluray cec crystalhd debug dvb dvd \
  19. egl fftw +hls ieee1394 jack lcd lirc perl pulseaudio python +theora \
  20. vaapi vdpau +vorbis +wrapper +xml xmltv +xvid zeroconf ${IUSE_INPUT_DEVICES}"
  21. REQUIRED_USE="
  22. bluray? ( xml )
  23. python? ( ${PYTHON_REQUIRED_USE} )
  24. theora? ( vorbis )"
  25. COMMON="
  26. >=media-libs/freetype-2.0:=
  27. >=media-sound/lame-3.93.1
  28. sys-libs/zlib:=
  29. x11-libs/libX11:=
  30. x11-libs/libXext:=
  31. x11-libs/libXinerama:=
  32. x11-libs/libXv:=
  33. x11-libs/libXrandr:=
  34. x11-libs/libXxf86vm:=
  35. >=dev-qt/qtcore-4.7.2:4=
  36. >=dev-qt/qtdbus-4.7.2:4=
  37. >=dev-qt/qtgui-4.7.2:4=
  38. >=dev-qt/qtscript-4.7.2:4=
  39. >=dev-qt/qtsql-4.7.2:4=[mysql]
  40. >=dev-qt/qtopengl-4.7.2:4=[egl?]
  41. >=dev-qt/qtwebkit-4.7.2:4=
  42. x11-misc/wmctrl:=
  43. virtual/mysql
  44. virtual/opengl:=
  45. alsa? ( >=media-libs/alsa-lib-1.0.24:= )
  46. zeroconf? (
  47. dev-libs/openssl:0=
  48. net-dns/avahi[mdnsresponder-compat]
  49. )
  50. bluray? (
  51. dev-libs/libcdio:=
  52. media-libs/libbluray:=
  53. sys-fs/udisks:0
  54. )
  55. cec? ( dev-libs/libcec:= )
  56. dvb? (
  57. media-libs/libdvb:=
  58. virtual/linuxtv-dvb-headers:=
  59. )
  60. dvd? (
  61. dev-libs/libcdio:=
  62. sys-fs/udisks:0
  63. )
  64. egl? ( media-libs/mesa:=[egl] )
  65. fftw? ( sci-libs/fftw:3.0= )
  66. hls? (
  67. media-libs/faac:=
  68. <media-libs/libvpx-1.6.0:=
  69. >=media-libs/x264-0.0.20111220:=
  70. )
  71. ieee1394? (
  72. >=sys-libs/libraw1394-1.2.0:=
  73. >=sys-libs/libavc1394-0.5.3:=
  74. >=media-libs/libiec61883-1.0.0:=
  75. )
  76. jack? ( media-sound/jack-audio-connection-kit )
  77. lcd? ( app-misc/lcdproc )
  78. libass? ( >=media-libs/libass-0.9.11:= )
  79. lirc? ( app-misc/lirc )
  80. perl? (
  81. dev-perl/DBD-mysql
  82. dev-perl/Net-UPnP
  83. dev-perl/LWP-Protocol-https
  84. dev-perl/HTTP-Message
  85. dev-perl/IO-Socket-INET6
  86. >=dev-perl/libwww-perl-5
  87. )
  88. pulseaudio? ( media-sound/pulseaudio )
  89. python? (
  90. ${PYTHON_DEPS}
  91. dev-python/mysql-python
  92. dev-python/lxml
  93. dev-python/urlgrabber
  94. )
  95. theora? ( media-libs/libtheora:= media-libs/libogg:= )
  96. vaapi? ( x11-libs/libva:=[opengl] )
  97. vdpau? ( x11-libs/libvdpau:= )
  98. vorbis? ( >=media-libs/libvorbis-1.0:= media-libs/libogg:= )
  99. xml? ( >=dev-libs/libxml2-2.6.0:= )
  100. xvid? ( >=media-libs/xvid-1.1.0:= )
  101. !media-tv/mythtv-bindings
  102. !x11-themes/mythtv-themes
  103. media-libs/taglib:=
  104. dev-libs/glib:=
  105. "
  106. RDEPEND="${COMMON}
  107. media-fonts/corefonts
  108. media-fonts/dejavu
  109. media-fonts/liberation-fonts
  110. x11-apps/xinit
  111. autostart? (
  112. net-dialup/mingetty
  113. x11-wm/evilwm
  114. x11-apps/xset
  115. )
  116. dvd? ( media-libs/libdvdcss:= )
  117. xmltv? ( >=media-tv/xmltv-0.5.43 )
  118. "
  119. DEPEND="${COMMON}
  120. dev-lang/yasm
  121. x11-proto/xineramaproto
  122. x11-proto/xf86vidmodeproto
  123. "
  124. S="${WORKDIR}/${P}/mythtv"
  125. MYTHTV_GROUPS="video,audio,tty,uucp"
  126. pkg_setup() {
  127. python-single-r1_pkg_setup
  128. enewuser mythtv -1 /bin/bash /home/mythtv ${MYTHTV_GROUPS}
  129. usermod -a -G ${MYTHTV_GROUPS} mythtv
  130. }
  131. src_prepare() {
  132. # Perl bits need to go into vender_perl and not site_perl
  133. sed -e "s:pure_install:pure_install INSTALLDIRS=vendor:" \
  134. -i "${S}"/bindings/perl/Makefile
  135. # Fix up the version info since we are using the fixes/${PV} branch
  136. echo "SOURCE_VERSION=\"v${MY_PV}\"" > "${S}"/VERSION
  137. echo "BRANCH=\"${MYTHTV_BRANCH}\"" >> "${S}"/VERSION
  138. echo "SOURCE_VERSION=\"${BACKPORTS}\"" > "${S}"/EXPORTED_VERSION
  139. echo "BRANCH=\"${MYTHTV_BRANCH}\"" >> "${S}"/EXPORTED_VERSION
  140. echo "setting.extra -= -ldconfig" >> "${S}"/programs/mythfrontend/mythfrontend.pro
  141. epatch "${FILESDIR}/libdir-27.patch"
  142. epatch "${FILESDIR}/${PN}-0.27.6-libvpx-1.5.0.patch"
  143. epatch_user
  144. }
  145. src_configure() {
  146. local myconf=
  147. # Setup paths
  148. myconf="${myconf} --prefix=${EPREFIX}/usr"
  149. myconf="${myconf} --libdir=${EPREFIX}/usr/$(get_libdir)"
  150. myconf="${myconf} --libdir-name=$(get_libdir)"
  151. myconf="${myconf} --mandir=${EPREFIX}/usr/share/man"
  152. # Audio
  153. myconf="${myconf} $(use_enable alsa audio-alsa)"
  154. myconf="${myconf} $(use_enable jack audio-jack)"
  155. use pulseaudio || myconf="${myconf} --disable-audio-pulseoutput"
  156. use altivec || myconf="${myconf} --disable-altivec"
  157. myconf="${myconf} $(use_enable dvb)"
  158. myconf="${myconf} $(use_enable ieee1394 firewire)"
  159. myconf="${myconf} $(use_enable lirc)"
  160. myconf="${myconf} $(use_enable xvid libxvid)"
  161. myconf="${myconf} --dvb-path=/usr/include"
  162. myconf="${myconf} --enable-xrandr"
  163. myconf="${myconf} --enable-xv"
  164. myconf="${myconf} --enable-x11"
  165. myconf="${myconf} --enable-nonfree"
  166. myconf="${myconf} --enable-libmp3lame"
  167. use cec || myconf="${myconf} --disable-libcec"
  168. use zeroconf || myconf="${myconf} --disable-libdns-sd"
  169. myconf="${myconf} $(use_enable theora libtheora)"
  170. myconf="${myconf} $(use_enable vorbis libvorbis)"
  171. if use hls; then
  172. myconf="${myconf} --enable-libx264"
  173. myconf="${myconf} --enable-libvpx"
  174. myconf="${myconf} --enable-libfaac"
  175. fi
  176. myconf="${myconf} $(use_enable libass)"
  177. if use perl && use python; then
  178. myconf="${myconf} --with-bindings=perl,python"
  179. elif use perl; then
  180. myconf="${myconf} --without-bindings=python"
  181. myconf="${myconf} --with-bindings=perl"
  182. elif use python; then
  183. myconf="${myconf} --without-bindings=perl"
  184. myconf="${myconf} --with-bindings=python"
  185. else
  186. myconf="${myconf} --without-bindings=perl,python"
  187. fi
  188. use python && myconf="${myconf} --python=${EPYTHON}"
  189. if use debug; then
  190. myconf="${myconf} --compile-type=debug"
  191. else
  192. myconf="${myconf} --compile-type=release"
  193. #myconf="${myconf} --enable-debug" does nothing per sphery
  194. #myconf="${myconf} --disable-stripping" does nothing per sphery
  195. fi
  196. # Video
  197. myconf="${myconf} $(use_enable vdpau)"
  198. myconf="${myconf} $(use_enable vaapi)"
  199. myconf="${myconf} $(use_enable crystalhd)"
  200. # Input
  201. use input_devices_joystick || myconf="${myconf} --disable-joystick-menu"
  202. # Clean up DSO load times and other compiler bits
  203. myconf="${myconf} --enable-symbol-visibility"
  204. myconf="${myconf} --enable-pic"
  205. # CPU settings
  206. for i in $(get-flag march) $(get-flag mcpu) $(get-flag mtune) ; do
  207. [ "${i}" = "native" ] && i="host"
  208. myconf="${myconf} --cpu=${i}"
  209. break
  210. done
  211. if tc-is-cross-compiler ; then
  212. myconf="${myconf} --enable-cross-compile --arch=$(tc-arch-kernel)"
  213. myconf="${myconf} --cross-prefix=${CHOST}-"
  214. fi
  215. # Build boosters
  216. has distcc ${FEATURES} || myconf="${myconf} --disable-distcc"
  217. has ccache ${FEATURES} || myconf="${myconf} --disable-ccache"
  218. chmod +x ./external/FFmpeg/version.sh
  219. einfo "Running ./configure ${myconf}"
  220. ./configure \
  221. --cc="$(tc-getCC)" \
  222. --cxx="$(tc-getCXX)" \
  223. --ar="$(tc-getAR)" \
  224. --extra-cflags="${CFLAGS}" \
  225. --extra-cxxflags="${CXXFLAGS}" \
  226. --extra-ldflags="${LDFLAGS}" \
  227. ${myconf} || die "configure died"
  228. }
  229. src_install() {
  230. emake INSTALL_ROOT="${D}" install || die "install failed"
  231. dodoc AUTHORS UPGRADING README
  232. insinto /usr/share/mythtv/database
  233. doins database/*
  234. newinitd "${FILESDIR}"/mythbackend.init-r2 mythbackend
  235. newconfd "${FILESDIR}"/mythbackend.conf-r1 mythbackend
  236. systemd_dounit "${FILESDIR}"/mythbackend.service
  237. dodoc keys.txt
  238. keepdir /etc/mythtv
  239. chown -R mythtv "${ED}"/etc/mythtv
  240. keepdir /var/log/mythtv
  241. chown -R mythtv "${ED}"/var/log/mythtv
  242. dodir /var/log/mythtv/old
  243. insinto /etc/logrotate.d
  244. newins "${FILESDIR}"/mythtv.logrotate.d-r4 mythtv
  245. insinto /usr/share/mythtv/contrib
  246. # Ensure we don't install scripts needing the perl bindings (bug #516968)
  247. use perl || find contrib/ -name '*.pl' -exec rm -f {} \;
  248. # Ensure we don't install scripts needing the python bindings (bug #516968)
  249. use python || find contrib/ -name '*.py' -exec rm -f {} \;
  250. doins -r contrib/*
  251. # Install our mythfrontend wrapper which is similar to Mythbuntu's
  252. if use wrapper; then
  253. mv "${ED}/usr/bin/mythfrontend" "${ED}/usr/bin/mythfrontend.real"
  254. newbin "${FILESDIR}"/mythfrontend.wrapper mythfrontend
  255. newconfd "${FILESDIR}"/mythfrontend.conf mythfrontend
  256. fi
  257. if use autostart; then
  258. dodir /etc/env.d/
  259. echo 'CONFIG_PROTECT="/home/mythtv/"' > "${ED}"/etc/env.d/95mythtv
  260. insinto /home/mythtv
  261. newins "${FILESDIR}"/bash_profile .bash_profile
  262. newins "${FILESDIR}"/xinitrc-r1 .xinitrc
  263. fi
  264. # Make Python files executable
  265. find "${ED}/usr/share/mythtv" -type f -name '*.py' | while read file; do
  266. if [[ ! "${file##*/}" = "__init__.py" ]]; then
  267. chmod a+x "${file}"
  268. fi
  269. done
  270. # Ensure that Python scripts are executed by Python 2
  271. python_fix_shebang "${ED}/usr/share/mythtv"
  272. # Make shell & perl scripts executable
  273. find "${ED}" -type f -name '*.sh' -o -type f -name '*.pl' | \
  274. while read file; do
  275. chmod a+x "${file}"
  276. done
  277. }
  278. pkg_preinst() {
  279. export CONFIG_PROTECT="${CONFIG_PROTECT} ${EROOT}/home/mythtv/"
  280. }
  281. pkg_postinst() {
  282. elog "To have this machine operate as recording host for MythTV, "
  283. elog "mythbackend must be running. Run the following:"
  284. elog "rc-update add mythbackend default"
  285. elog
  286. elog "Your recordings folder must be owned 'mythtv'. e.g."
  287. elog "chown -R mythtv /var/lib/mythtv"
  288. elog "Want mythfrontend to start automatically?"
  289. elog "Set USE=autostart. Details can be found at:"
  290. elog "https://dev.gentoo.org/~cardoe/mythtv/autostart.html"
  291. elog
  292. elog "Note that the systemd unit now restarts by default and logs"
  293. elog "to journald via the console at the notice verbosity."
  294. }
  295. pkg_info() {
  296. if [[ -f "${EROOT}"/usr/bin/mythfrontend ]]; then
  297. "${EROOT}"/usr/bin/mythfrontend --version
  298. fi
  299. }
  300. pkg_config() {
  301. echo "Creating mythtv MySQL user and mythconverg database if it does not"
  302. echo "already exist. You will be prompted for your MySQL root password."
  303. "${EROOT}"/usr/bin/mysql -u root -p < "${EROOT}"/usr/share/mythtv/database/mc.sql
  304. }