3 %bcond_without systemd # without systemd support
5 %define gitref c531383ca6654639dc112db67fd8dc893c1f5272
9 Summary: TV streaming server
11 # https://tvheadend.org/projects/tvheadend/wiki/Releases
13 Release: 0.%{snap}.%{rel}
15 Group: Applications/Multimedia
16 Source0: https://github.com/tvheadend/tvheadend/archive/%{gitref}/%{name}-%{snap}.tar.gz
17 # Source0-md5: 145d05de790f785f8f1d8f2166d4ce41
18 Source1: %{name}.service
19 Source2: %{name}.sysconfig
23 URL: https://tvheadend.org/projects/tvheadend
24 BuildRequires: avahi-devel
25 BuildRequires: dbus-devel
26 BuildRequires: ffmpeg-devel >= 3.0
27 BuildRequires: gettext-tools
28 BuildRequires: libdvbcsa-devel
29 BuildRequires: libx264-devel
30 BuildRequires: libx265-devel
31 BuildRequires: openssl-devel
32 BuildRequires: pcre2-8-devel
33 BuildRequires: pkgconfig
34 BuildRequires: python3-modules
35 BuildRequires: rpmbuild(macros) >= 1.647
36 %{?with_systemd:BuildRequires: systemd-devel}
37 BuildRequires: uriparser-devel
38 BuildRequires: zlib-devel
39 Requires(post): sed >= 4.0
40 Requires(post,preun): /sbin/chkconfig
41 %{?with_systemd:Requires(post,preun,postun): systemd-units >= 38}
42 Requires(postun): /usr/sbin/userdel
43 Requires(pre): /bin/id
44 Requires(pre): /usr/sbin/useradd
46 %{?with_systemd:Requires: systemd-units >= 0.38}
47 Provides: user(tvheadend)
48 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
51 Tvheadend is a TV streaming server for Linux supporting DVB-S, DVB-S2,
52 DVB-C, DVB-T, ATSC, IPTV, and Analog video (V4L) as input sources.
55 %setup -q -n %{name}-%{gitref}
61 %{__sed} -i -e '1s,/usr/bin/env python3$,%{__python3},' lib/py/tvh/tv_meta_{tm,tv}db.py support/tvhmeta
64 export CFLAGS="%{rpmcflags}"
65 export LDFLAGS="%{rpmldflags}"
67 # tvheadend uses a custom script, so %%configure cannot be used
68 # as not all options are supported
75 --python=%{__python3} \
77 --disable-ffmpeg_static \
78 --disable-hdhomerun_static \
79 %{!?with_systemd:--disable-libsystemd_daemon}
84 rm -rf $RPM_BUILD_ROOT
85 install -d $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name} \
86 $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/Videos \
87 %{?with_systemd:$RPM_BUILD_ROOT%{systemdunitdir}} \
88 $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
91 DESTDIR=$RPM_BUILD_ROOT \
94 %{?with_systemd:cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service}
95 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
96 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
98 chmod +x $RPM_BUILD_ROOT%{_bindir}/%{name}
101 rm -rf $RPM_BUILD_ROOT
104 %useradd -u 20 -d %{_localstatedir}/lib/%{name} -g video -G usb -c "tvheadend User" tvheadend
107 /sbin/chkconfig --add tvheadend
108 %service tvheadend reload "tvheadend"
109 %{?with_systemd:%systemd_post %{name}.service}
112 if [ "$1" = "0" ]; then
113 %service tvheadend stop
114 /sbin/chkconfig --del tvheadend
116 %{?with_systemd:%systemd_preun %{name}.service}
119 if [ "$1" = "0" ]; then
120 %userremove tvheadend
122 %{?with_systemd:%systemd_reload}
125 %defattr(644,root,root,755)
127 %attr(755,root,root) %{_bindir}/tvheadend
128 %attr(755,root,root) %{_bindir}/tvhmeta
129 %attr(755,root,root) %{_bindir}/tv_meta_tmdb.py
130 %attr(755,root,root) %{_bindir}/tv_meta_tvdb.py
131 %attr(754,root,root) /etc/rc.d/init.d/tvheadend
132 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
133 %{_mandir}/man1/%{name}.1*
135 %{?with_systemd:%{systemdunitdir}/%{name}.service}
137 # home directory and config file
138 %dir %attr(755,tvheadend,root) %{_localstatedir}/lib/%{name}
139 %dir %attr(755,tvheadend,video) %{_localstatedir}/lib/%{name}/Videos
140 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts
141 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts/%{name}