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