COMMIT ?= $(shell git rev-parse HEAD)
COMMIT1 = $(shell git rev-parse $(COMMIT))
-VERSION = $(shell cd .. && git describe --match "v*" $(COMMIT1) | sed 's/-/./g' )
+VERSION = $(shell cd .. && git describe --match "v*" $(COMMIT1) | sed -e 's/-/./g' -e 's/^v//g' )
tvheadend.spec: tvheadend.spec.in
@sed -e 's/@VERSION@/$(VERSION)/g' \
#%patch999 -p1 -b .test
%build
+echo %{version} > %{_builddir}/%{buildsubdir}/rpm/version
%configure --disable-lockowner --enable-bundle --enable-libffmpeg_static
%{__make}
install -p -m 755 build.linux/tvheadend %{buildroot}%{_bindir}
# systemd
mkdir -p -m755 %{buildroot}%{_sysconfdir}/sysconfig
-install -p -m 644 rpm/tvheadend.sysconfig %{buildroot}%{_sysconfdir}/sysconfig
+install -p -m 644 rpm/tvheadend.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/tvheadend
mkdir -p -m755 %{buildroot}%{_unitdir}
install -p -m 644 rpm/tvheadend.service %{buildroot}%{_unitdir}
+%pre
+getent group tvheadend >/dev/null || groupadd -f -g 283 -r tvheadend
+if ! getent passwd tvheadend > /dev/null ; then
+ if ! getent passwd 283 > /dev/null ; then
+ useradd -r -l -u 283 -g tvheadend -d /home/tvheadend -s /sbin/nologin -c "Tvheadend TV server" tvheadend
+ else
+ useradd -r -l -g tvheadend -d /home/tvheadend -s /sbin/nologin -c "Tvheadend TV server" tvheadend
+ fi
+fi
+if ! test -d /home/tvheadend ; then
+ mkdir -m 0755 /home/tvheadend || exit 1
+ chown tvheadend.tvheadend /home/tvheadend || exit 1
+fi
+exit 0
+
+%post
+%systemd_post tvheadend.service
+
+%postun
+%systemd_postun_with_restart tvheadend.service
+
%files
%{_bindir}/*
%{_sysconfdir}/sysconfig/*
# Configuration file for the tvheadend service.
-OPTIONS="-u tvheadend -g tvheadend -6 --http_port=9981 --htsp_port=9982"
+OPTIONS="-c /home/tvheadend/config -u tvheadend -g tvheadend -6 --http_port 9981 --htsp_port 9982"
VER=$(echo $VER | sed "s/^v//" | sed "s/-\([0-9]*\)-\(g[0-9a-f]*\)/.\1~\2/")
elif [ -f "$(dirname "$0")/../debian/changelog" ]; then
VER=$(head -1 "$(dirname "$0")/../debian/changelog" | awk '{ print $2 }' | tr -d '()' | cut -d '-' -f 1)
+elif [ -r "$(dirname "$0")/rpm/version" ]; then
+ VER=$(cat "$(dirname "$0")/rpm/version")
else
VER="0.0.0~unknown"
fi