app-metrics/prometheus: add 3.1.0
[gentoo/gentoo.git] / media-tv / mythtv / mythtv-33.1-r3.ebuild
blob629b7169ab5978480dc4882347ebfd58b8186e1c
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
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"
19 else
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"
25 LICENSE="GPL-2+"
26 SLOT="0"
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}"
35 REQUIRED_USE="
36         cdr? ( cdda )
39 RDEPEND="
40         acct-user/mythtv
41         dev-libs/glib:2
42         dev-libs/lzo
43         dev-libs/libzip:=
44         dev-qt/qtcore:5
45         dev-qt/qtdbus:5
46         dev-qt/qtgui:5[jpeg]
47         dev-qt/qtnetwork:5
48         dev-qt/qtscript:5
49         dev-qt/qtsql:5[mysql]
50         dev-qt/qtwidgets:5
51         dev-qt/qtxml:5
52         media-fonts/corefonts
53         media-fonts/dejavu
54         media-fonts/liberation-fonts
55         media-fonts/tex-gyre
56         media-gfx/exiv2:=
57         media-libs/freetype:2
58         media-libs/libbluray:=[java?]
59         media-libs/libsamplerate
60         media-libs/libsoundtouch
61         media-libs/taglib:=
62         sys-libs/zlib
63         alsa? ( media-libs/alsa-lib )
64         autostart? (
65                 net-dialup/mingetty
66                 x11-apps/xset
67                 x11-wm/evilwm
68         )
69         cec? ( dev-libs/libcec )
70         dvd? (
71                 dev-libs/libcdio:=
72                 media-libs/libdvdcss
73                 sys-fs/udisks:2
74         )
75         fftw? ( sci-libs/fftw:3.0=[threads] )
76         hdhomerun? ( media-libs/libhdhomerun )
77         ieee1394? (
78                 media-libs/libiec61883
79                 sys-libs/libavc1394
80                 sys-libs/libraw1394
81         )
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:= )
95         X? (
96                 x11-apps/xinit
97                 x11-libs/libX11:=
98                 x11-libs/libXext:=
99                 x11-libs/libXinerama:=
100                 x11-libs/libXrandr:=
101                 x11-libs/libXv:=
102                 x11-libs/libXxf86vm:=
103                 x11-misc/wmctrl:=
104         )
105         x265? ( media-libs/x265 )
106         xml? ( dev-libs/libxml2:2 )
107         xmltv? (
108                 dev-perl/XML-LibXML
109                 media-tv/xmltv
110         )
111         xvid? ( media-libs/xvid )
112         zeroconf? (
113                 dev-libs/openssl:=
114                 net-dns/avahi[mdnsresponder-compat]
115         )
117 DEPEND="
118         ${RDEPEND}
119         dev-lang/yasm
120         sys-kernel/linux-headers
121         x11-base/xorg-proto
122         perl? (
123                 dev-perl/DBD-mysql
124                 dev-perl/DBI
125                 dev-perl/HTTP-Message
126                 dev-perl/IO-Socket-INET6
127                 dev-perl/LWP-Protocol-https
128                 dev-perl/Net-UPnP
129                 dev-perl/XML-Simple
130         )
132 BDEPEND="
133         virtual/pkgconfig
134         java? ( >=dev-java/ant-1.10.14-r3 )
135         opengl? ( virtual/opengl )
136         python? (
137                 ${PYTHON_DEPS}
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}]
143                 ')
144         )
147 PATCHES=(
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}]"
161 pkg_setup() {
162         use python && python-any-r1_pkg_setup
165 src_prepare() {
166         default
167         cat > external/libmythbluray/src/libbluray/bdj/build.properties <<-EOF
168                 java_version_asm=1.8
169                 java_version_bdj=1.8
170         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!"
182 src_configure() {
183         local -a myconf=()
185         # Setup paths
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 )
191         if use debug; then
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
195         else
196                 myconf+=( --compile-type=release )
197         fi
199         # Build boosters
200         has ccache "${FEATURES}" || myconf+=( --disable-ccache )
201         has distcc "${FEATURES}" || myconf+=( --disable-distcc )
203         # CPU settings
204         # Mythtv's configure is borrowed from ffmpeg,
205         # Bug #172723
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.
210         local i
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}" )
214                 break
215         done
216         myconf+=( $(use_enable cpu_flags_ppc_altivec altivec) )
218         # Sound Output Support
219         myconf+=(
220                 $(use_enable oss audio-oss)
222                 $(use_enable alsa audio-alsa)
223                 $(use_enable jack audio-jack)
224                 $(use_enable pulseaudio audio-pulseoutput)
225         )
227         # Input Support
228         myconf+=(
229                 $(use_enable lirc)
230                 $(use_enable input_devices_joystick joystick-menu)
231                 $(use_enable cec libcec)
232                 $(use_enable ieee1394 firewire)
233                 $(use_enable hdhomerun)
234                 $(use_enable vbox)
235                 $(use_enable ceton)
236                 $(use_enable v4l v4l2)
237                 $(use_enable dvb)
238                 $(use_enable asi)
239         )
241         # Video Output Support
242         myconf+=(
243                 $(use_enable X x11)
244         )
246         # Hardware accelerators
247         myconf+=(
248                 $(use_enable nvdec)
249                 $(use_enable vaapi)
250                 $(use_enable vdpau)
251                 $(use_enable opengl)
252                 $(use_enable opengl egl)
253                 $(use_enable libass)
254         )
256         # System tools
257         myconf+=(
258                 $(use_enable systemd systemd_notify)
259                 $(use_enable systemd systemd_journal)
260                 $(use_enable xml libxml2)
261                 $(use_enable zeroconf libdns-sd)
262         )
264         # Bindings
265         if use perl && use python; then
266                 myconf+=( --with-bindings=perl,python )
267         elif use perl; then
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 )
273         else
274                 myconf+=( --without-bindings=perl,python )
275         fi
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
282         myconf+=(
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)
288         )
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}"- )
297         fi
299         # econf sets these options that are not handled by configure:
300         # --build --host --infodir --localstatedir --sysconfdir
302         edo ./configure \
303                 --prefix="${EPREFIX}/usr" \
304                 --cc="$(tc-getCC)" \
305                 --cxx="$(tc-getCXX)" \
306                 --ar="$(tc-getAR)" \
307                 --optflags="${CFLAGS}" \
308                 --extra-cflags="${CFLAGS}" \
309                 --extra-cxxflags="${CXXFLAGS}" \
310                 --extra-ldflags="${LDFLAGS}" \
311                 --qmake="$(qt5_get_bindir)"/qmake \
312                 "${myconf[@]}"
315 src_install() {
316         emake STRIP="true" INSTALL_ROOT="${D}" install
317         use python && python_optimize  # does all packages by default
318         dodoc AUTHORS README
319         readme.gentoo_create_doc
321         insinto /usr/share/mythtv/database
322         doins database/*
324         newinitd "${FILESDIR}"/mythbackend.init-r3 mythbackend
325         newconfd "${FILESDIR}"/mythbackend.conf-r1 mythbackend
326         if use systemd; then
327                 systemd_newunit "${FILESDIR}"/mythbackend.service-28 mythbackend.service
328         fi
330         # The acct-user/mythtv package creates/manages the user 'mythtv'
331         keepdir /etc/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.
341         if ! use perl; then
342                 find contrib/ -name '*.pl' -exec rm {} \;
343         fi
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 {} \;
347         fi
348         doins -r contrib/*
350         # Install our mythfrontend wrapper which is similar to Mythbuntu's
351         if use wrapper; then
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
355         fi
357         if use autostart; then
358                 newenvd - 95mythtv <<- _EOF_
359                         CONFIG_PROTECT=\"$(egethome mythtv)\"
360                 _EOF_
361                 insinto $(egethome mythtv)
362                 newins "${FILESDIR}"/bash_profile .bash_profile
363                 newins "${FILESDIR}"/xinitrc-r1 .xinitrc
364         fi
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"
378 pkg_postinst() {
379         readme.gentoo_print_elog
382 pkg_config() {
383         if [[ -e "${EROOT}"/usr/bin/mysql ]]; then
384                 "${EROOT}"/usr/bin/mysql -u root -p < "${EROOT}"/usr/share/mythtv/database/mc.sql
385         fi