1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 DISABLE_AUTOFORMATTING="yes"
7 PYTHON_COMPAT=( python3_{10..12} )
9 inherit edo flag-o-matic java-pkg-opt-2 python-any-r1
10 inherit qmake-utils readme.gentoo-r1 systemd toolchain-funcs user-info
12 DESCRIPTION="Open Source DVR and media center hub"
13 HOMEPAGE="https://www.mythtv.org https://github.com/MythTV/mythtv"
14 if [[ ${PV} == *_p* ]] ; then
15 MY_COMMIT="5824c588db24b4e71a7d94e829e6419f71089297"
16 SRC_URI="https://github.com/MythTV/mythtv/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz"
17 # mythtv and mythplugins are separate builds in the github MythTV project
18 S="${WORKDIR}/mythtv-${MY_COMMIT}/mythtv"
20 SRC_URI="https://github.com/MythTV/mythtv/archive/v${PV}.tar.gz -> ${P}.tar.gz"
21 # mythtv and mythplugins are separate builds in the github mythtv project
22 S="${WORKDIR}/${P}/mythtv"
27 KEYWORDS="~amd64 ~x86"
29 IUSE_INPUT_DEVICES="input_devices_joystick"
30 IUSE_VIDEO_CAPTURE_DEVICES="v4l ieee1394 hdhomerun vbox ceton"
31 IUSE="alsa asi autostart cdda cdr cec cpu_flags_ppc_altivec debug dvd dvb exif fftw jack java"
32 IUSE+=" +lame lcd libass lirc nvdec +opengl oss perl pulseaudio python raw systemd vaapi vdpau vpx"
33 IUSE+=" +wrapper x264 x265 +xml xmltv +xvid +X zeroconf"
34 IUSE+=" ${IUSE_INPUT_DEVICES} ${IUSE_VIDEO_CAPTURE_DEVICES}"
54 media-fonts/liberation-fonts
58 media-libs/libbluray:=[java?]
59 media-libs/libsamplerate
60 media-libs/libsoundtouch
63 alsa? ( media-libs/alsa-lib )
69 cec? ( dev-libs/libcec )
75 fftw? ( sci-libs/fftw:3.0=[threads] )
76 hdhomerun? ( media-libs/libhdhomerun )
78 media-libs/libiec61883
82 jack? ( virtual/jack )
83 lame? ( media-sound/lame )
84 lcd? ( app-misc/lcdproc )
85 libass? ( media-libs/libass:= )
86 lirc? ( app-misc/lirc )
87 nvdec? ( x11-drivers/nvidia-drivers )
88 opengl? ( dev-qt/qtopengl:5 )
89 pulseaudio? ( media-libs/libpulse )
90 systemd? ( sys-apps/systemd:= )
91 vaapi? ( media-libs/libva:= )
92 vdpau? ( x11-libs/libvdpau )
93 vpx? ( media-libs/libvpx:= )
94 x264? ( media-libs/x264:= )
99 x11-libs/libXinerama:=
102 x11-libs/libXxf86vm:=
105 x265? ( media-libs/x265 )
106 xml? ( dev-libs/libxml2:2 )
111 xvid? ( media-libs/xvid )
114 net-dns/avahi[mdnsresponder-compat]
120 sys-kernel/linux-headers
125 dev-perl/HTTP-Message
126 dev-perl/IO-Socket-INET6
127 dev-perl/LWP-Protocol-https
134 java? ( >=dev-java/ant-1.10.14-r3 )
135 opengl? ( virtual/opengl )
138 $(python_gen_any_dep '
139 dev-python/python-dateutil[${PYTHON_USEDEP}]
140 dev-python/lxml[${PYTHON_USEDEP}]
141 dev-python/mysqlclient[${PYTHON_USEDEP}]
142 dev-python/requests-cache[${PYTHON_USEDEP}]
148 "${FILESDIR}"/${PN}-33.1-libva.patch
149 "${FILESDIR}"/${PN}-33.1-ffmpeg-binutils-2.41.patch
150 "${FILESDIR}"/${PN}-33.1-linux-headers-6.5.patch
153 python_check_deps() {
154 use python || return 0
155 python_has_version "dev-python/python-dateutil[${PYTHON_USEDEP}]" &&
156 python_has_version "dev-python/lxml[${PYTHON_USEDEP}]" &&
157 python_has_version "dev-python/mysqlclient[${PYTHON_USEDEP}]" &&
158 python_has_version "dev-python/requests-cache[${PYTHON_USEDEP}]"
162 use python && python-any-r1_pkg_setup
167 cat > external/libmythbluray/src/libbluray/bdj/build.properties <<-EOF
171 # https://github.com/MythTV/mythtv/pull/824
172 # https://github.com/MythTV/mythtv/pull/838
173 # https://bugs.gentoo.org/888291
174 eapply -p2 "${FILESDIR}"/${PN}-33.1-python3.12.patch
176 # Perl bits need to go into vendor_perl and not site_perl
177 sed -e "s:pure_install:pure_install INSTALLDIRS=vendor:" \
178 -i "${S}"/bindings/perl/Makefile || die "Cannot convert site_perl to vendor_perl!"
186 myconf+=( --prefix="${EPREFIX}"/usr )
187 myconf+=( --libdir="${EPREFIX}"/usr/$(get_libdir) )
188 myconf+=( --libdir-name=$(get_libdir) )
189 myconf+=( --mandir="${EPREFIX}"/usr/share/man )
192 myconf+=( --compile-type=debug )
193 myconf+=( --disable-stripping ) # FIXME: does not disable for all files, only for some
194 myconf+=( --enable-valgrind ) # disables timeouts for valgrind memory debugging
196 myconf+=( --compile-type=release )
200 has ccache "${FEATURES}" || myconf+=( --disable-ccache )
201 has distcc "${FEATURES}" || myconf+=( --disable-distcc )
204 # Mythtv's configure is borrowed from ffmpeg,
206 # Try to get cpu type based on CFLAGS.
207 # We need to do this so that features of that CPU will be better used
208 # If they contain an unknown CPU it will not hurt since ffmpeg's configure
209 # will just ignore it.
211 for i in $(get-flag march) $(get-flag mcpu) $(get-flag mtune) ; do
212 [[ "${i}" == "native" ]] && i="host" # bug #273421
213 myconf+=( --cpu="${i}" )
216 myconf+=( $(use_enable cpu_flags_ppc_altivec altivec) )
218 # Sound Output Support
220 $(use_enable oss audio-oss)
222 $(use_enable alsa audio-alsa)
223 $(use_enable jack audio-jack)
224 $(use_enable pulseaudio audio-pulseoutput)
230 $(use_enable input_devices_joystick joystick-menu)
231 $(use_enable cec libcec)
232 $(use_enable ieee1394 firewire)
233 $(use_enable hdhomerun)
236 $(use_enable v4l v4l2)
241 # Video Output Support
246 # Hardware accelerators
252 $(use_enable opengl egl)
258 $(use_enable systemd systemd_notify)
259 $(use_enable systemd systemd_journal)
260 $(use_enable xml libxml2)
261 $(use_enable zeroconf libdns-sd)
265 if use perl && use python; then
266 myconf+=( --with-bindings=perl,python )
268 myconf+=( --without-bindings=python )
269 myconf+=( --with-bindings=perl )
270 elif use python; then
271 myconf+=( --without-bindings=perl )
272 myconf+=( --with-bindings=python )
274 myconf+=( --without-bindings=perl,python )
276 use python && myconf+=( --python="${EPYTHON}" )
277 myconf+=( $(use_enable java bdjava) )
279 # External codec library options (used for mythffmpeg and streaming transcode)
280 # lame is required for some broadcasts for silence detection of commercials
281 # default enable in IUSE with +lame
283 $(use_enable lame libmp3lame)
284 $(use_enable xvid libxvid)
285 $(use_enable x264 libx264)
286 $(use_enable x265 libx265)
287 $(use_enable vpx libvpx)
290 # Clean up DSO load times and other compiler bits
291 myconf+=( --enable-symbol-visibility )
292 myconf+=( --enable-pic )
294 if tc-is-cross-compiler ; then
295 myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) )
296 myconf+=( --cross-prefix="${CHOST}"- )
299 # econf sets these options that are not handled by configure:
300 # --build --host --infodir --localstatedir --sysconfdir
303 --prefix="${EPREFIX}/usr" \
305 --cxx="$(tc-getCXX)" \
307 --optflags="${CFLAGS}" \
308 --extra-cflags="${CFLAGS}" \
309 --extra-cxxflags="${CXXFLAGS}" \
310 --extra-ldflags="${LDFLAGS}" \
311 --qmake="$(qt5_get_bindir)"/qmake \
316 emake STRIP="true" INSTALL_ROOT="${D}" install
317 use python && python_optimize # does all packages by default
319 readme.gentoo_create_doc
321 insinto /usr/share/mythtv/database
324 newinitd "${FILESDIR}"/mythbackend.init-r3 mythbackend
325 newconfd "${FILESDIR}"/mythbackend.conf-r1 mythbackend
327 systemd_newunit "${FILESDIR}"/mythbackend.service-28 mythbackend.service
330 # The acct-user/mythtv package creates/manages the user 'mythtv'
332 fowners -R mythtv /etc/mythtv
333 keepdir /var/log/mythtv
334 fowners -R mythtv /var/log/mythtv
336 insinto /etc/logrotate.d
337 newins "${FILESDIR}"/mythtv.logrotate.d-r4 mythtv
339 insinto /usr/share/mythtv/contrib
340 # Ensure we don't install scripts needing the perl bindings (bug #516968) Finding none is OK.
342 find contrib/ -name '*.pl' -exec rm {} \;
344 # Ensure we don't install scripts needing the python bindings (bug #516968) Finding none is OK.
345 if ! use python; then
346 find contrib/ -name '*.py' -exec rm {} \;
350 # Install our mythfrontend wrapper which is similar to Mythbuntu's
352 mv "${ED}/usr/bin/mythfrontend" "${ED}/usr/bin/mythfrontend.real" || die "Failed to install mythfrontend.real"
353 newbin "${FILESDIR}"/mythfrontend.wrapper mythfrontend
354 newconfd "${FILESDIR}"/mythfrontend.conf mythfrontend
357 if use autostart; then
358 newenvd - 95mythtv <<- _EOF_
359 CONFIG_PROTECT=\"$(egethome mythtv)\"
361 insinto $(egethome mythtv)
362 newins "${FILESDIR}"/bash_profile .bash_profile
363 newins "${FILESDIR}"/xinitrc-r1 .xinitrc
366 # Make Python files executable but not files named "__init__.py"
367 find "${ED}/usr/share/mythtv" -type f -name '*.py' -exec expr \( {} : '.*__init__.py' \) = 0 \; \
368 -exec chmod a+x {} \; || die "Failed to make python file $(basename ${file}) executable"
370 # Ensure that Python scripts are executed by Python 2
371 use python && python_fix_shebang "${ED}/usr/share/mythtv"
373 # Make shell & perl scripts executable
374 find "${ED}" -type f \( -name '*.sh' -o -name '*.pl' \) -exec chmod a+x {} \; \
375 || die "Failed to make script executable"
379 readme.gentoo_print_elog
383 if [[ -e "${EROOT}"/usr/bin/mysql ]]; then
384 "${EROOT}"/usr/bin/mysql -u root -p < "${EROOT}"/usr/share/mythtv/database/mc.sql