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
22 URL: https://tvheadend.org/projects/tvheadend
23 BuildRequires: avahi-devel
24 BuildRequires: dbus-devel
25 BuildRequires: ffmpeg-devel >= 3.0
26 BuildRequires: gettext-tools
27 BuildRequires: libdvbcsa-devel
28 BuildRequires: libx264-devel
29 BuildRequires: libx265-devel
30 BuildRequires: openssl-devel
31 BuildRequires: pcre2-8-devel
32 BuildRequires: pkgconfig
33 BuildRequires: python3-modules
34 BuildRequires: rpmbuild(macros) >= 1.647
35 %{?with_systemd:BuildRequires: systemd-devel}
36 BuildRequires: uriparser-devel
37 BuildRequires: zlib-devel
38 Requires(post): sed >= 4.0
39 Requires(post,preun): /sbin/chkconfig
40 %{?with_systemd:Requires(post,preun,postun): systemd-units >= 38}
41 Requires(postun): /usr/sbin/userdel
42 Requires(pre): /bin/id
43 Requires(pre): /usr/sbin/useradd
45 %{?with_systemd:Requires: systemd-units >= 0.38}
46 Provides: user(tvheadend)
47 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
50 Tvheadend is a TV streaming server for Linux supporting DVB-S, DVB-S2,
51 DVB-C, DVB-T, ATSC, IPTV, and Analog video (V4L) as input sources.
54 %setup -q -n %{name}-%{gitref}
59 %{__sed} -i -e '1s,/usr/bin/env python3$,%{__python3},' lib/py/tvh/tv_meta_{tm,tv}db.py support/tvhmeta
62 export CFLAGS="%{rpmcflags}"
63 export LDFLAGS="%{rpmldflags}"
65 # tvheadend uses a custom script, so %%configure cannot be used
66 # as not all options are supported
73 --python=%{__python3} \
75 --disable-ffmpeg_static \
76 --disable-hdhomerun_static \
77 %{!?with_systemd:--disable-libsystemd_daemon}
82 rm -rf $RPM_BUILD_ROOT
83 install -d $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name} \
84 $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/Videos \
85 %{?with_systemd:$RPM_BUILD_ROOT%{systemdunitdir}} \
86 $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
89 DESTDIR=$RPM_BUILD_ROOT \
92 %{?with_systemd:cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service}
93 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
94 install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
96 chmod +x $RPM_BUILD_ROOT%{_bindir}/%{name}
99 rm -rf $RPM_BUILD_ROOT
102 %useradd -u 20 -d %{_localstatedir}/lib/%{name} -g video -G usb -c "tvheadend User" tvheadend
105 /sbin/chkconfig --add tvheadend
106 %service tvheadend reload "tvheadend"
107 %{?with_systemd:%systemd_post %{name}.service}
110 if [ "$1" = "0" ]; then
111 %service tvheadend stop
112 /sbin/chkconfig --del tvheadend
114 %{?with_systemd:%systemd_preun %{name}.service}
117 if [ "$1" = "0" ]; then
118 %userremove tvheadend
120 %{?with_systemd:%systemd_reload}
123 %defattr(644,root,root,755)
125 %attr(755,root,root) %{_bindir}/%{name}
126 %attr(754,root,root) /etc/rc.d/init.d/tvheadend
127 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
128 %{_mandir}/man1/%{name}.1*
130 %{?with_systemd:%{systemdunitdir}/%{name}.service}
132 # home directory and config file
133 %dir %attr(755,tvheadend,root) %{_localstatedir}/lib/%{name}
134 %dir %attr(755,tvheadend,video) %{_localstatedir}/lib/%{name}/Videos
135 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts
136 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts/%{name}