3 Summary: TV streaming server
5 # keep stable version announced on web page
6 %define vername 3.4patch1
10 Group: Applications/Multimedia
11 Source0: https://github.com/tvheadend/tvheadend/archive/%{vername}.tar.gz
12 # Source0-md5: 86d1be0ad6e02bd2aecd3d529a026797
14 Source2: %{name}.service
15 Source3: %{name}.sysconfig
17 URL: https://tvheadend.org/projects/tvheadend
18 BuildRequires: avahi-devel
19 BuildRequires: curl-devel
20 BuildRequires: python-modules
21 BuildRequires: rpmbuild(macros) >= 1.647
22 BuildRequires: zlib-devel
24 Requires(post): sed >= 4.0
25 Requires(post,preun): /sbin/chkconfig
26 Requires(post,preun,postun): systemd-units >= 38
27 Requires(postun): /usr/sbin/userdel
28 Requires(pre): /bin/id
29 Requires(pre): /usr/sbin/useradd
30 Requires: group(video)
31 Requires: systemd-units >= 0.38
32 Provides: user(tvheadend)
33 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
36 Tvheadend is a TV streaming server for Linux supporting DVB-S, DVB-S2,
37 DVB-C, DVB-T, ATSC, IPTV, and Analog video (V4L) as input sources.
40 %setup -q -n %{name}-%{vername}
43 export CFLAGS="%{rpmcflags}"
46 # tvheadend uses a custom script, so %%configure cannot be used
47 # as not all options are supported
52 --mandir=%{_mandir}/man1
57 rm -rf $RPM_BUILD_ROOT
58 install -d $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol \
59 $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/Videos \
60 $RPM_BUILD_ROOT%{systemdunitdir} \
61 $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
64 DESTDIR=$RPM_BUILD_ROOT
66 cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol/1
67 cp -p %{SOURCE2} $RPM_BUILD_ROOT%{systemdunitdir}/%{name}.service
68 cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
69 install -p %{SOURCE4} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
71 chmod +x $RPM_BUILD_ROOT%{_bindir}/%{name}
74 rm -rf $RPM_BUILD_ROOT
77 # FIXME: use registered uid!
78 %useradd -u 20 -d %{_localstatedir}/lib/%{name} -g video -G usb -c "tvheadend User" tvheadend
81 /sbin/chkconfig --add tvheadend
82 %service tvheadend reload "tvheadend"
83 %systemd_post %{name}.service
85 # check if the access control file still has the initial dummy password, and
86 # replace the dummy password by a random, 12-character pwgen-generated password
87 if grep -q '"password": "dummypassword"' %{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol/1; then
88 sed -i "s,\"password\": \"dummypassword\",\"password\": \"$(pwgen -s 12 1)\"," %{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol/1
92 if [ "$1" = "0" ]; then
93 %service tvheadend stop
94 /sbin/chkconfig --del tvheadend
96 %systemd_preun %{name}.service
99 if [ "$1" = "0" ]; then
100 %userremove tvheadend
105 %defattr(644,root,root,755)
107 %attr(755,root,root) %{_bindir}/%{name}
108 %attr(754,root,root) /etc/rc.d/init.d/tvheadend
109 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
110 %{_mandir}/man1/%{name}.1*
112 %{systemdunitdir}/%{name}.service
114 # home directory and config file
115 %dir %attr(755,tvheadend,root) %{_localstatedir}/lib/%{name}
116 %dir %attr(755,tvheadend,video) %{_localstatedir}/lib/%{name}/Videos
117 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts
118 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts/%{name}
119 %dir %attr(750,tvheadend,video) %{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol
120 %attr(600,tvheadend,video) %config(noreplace) %verify(not md5 mtime size) %{_localstatedir}/lib/%{name}/.hts/%{name}/accesscontrol/1