File dvb.spec of Package dvb

#
# spec file for package dvb
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%if !%{defined snapver}
%define snapver  20120410
%endif

Name:           dvb
BuildRequires:  libusb-devel
BuildRequires:  fdupes
%if 0%{?suse_version} >= 1210
BuildRequires:  libv4l-devel >= 0.8.4
%endif
%define firmwaredir /lib/firmware
License:        GPL-2.0+
Group:          Hardware/TV
Url:            http://linuxtv.org/
PreReq:         %fillup_prereq %insserv_prereq
Version:        1.1.1%{?snapver:_%snapver}
Release:        1
Summary:        Tools for Digital (DVB) TV Cards
Source:         dvb-apps-%{version}.tar.bz2
Source2:        rcdvb
Source3:        sysconfig.dvb
Source4:        http://linuxtv.org/downloads/firmware/dvb-ttpci-01.fw-2622
#Source4:      http://212.227.36.83/linuxtv/downloads/firmware/dvb-ttpci-01.fw-261d
Patch:          dvb-apps-dvbnet.diff
Patch1:         dvb-includes.diff
Patch2:         cz-kojal.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# This package provides the firmware for some cards supported by the
# dvb-ttpci.ko module. Add the modalias dependencies for this module:
# Modules: dvb-ttpci.ko
Supplements:    modalias(pci:v00001131d00007146sv0000110Asd00000000bc*sc*i*)
Supplements:    modalias(pci:v00001131d00007146sv000013C2sd0000000[0123468AE]bc*sc*i*)
Supplements:    modalias(pci:v00001131d00007146sv000013C2sd00001002bc*sc*i*)
# Generated with: extract-modaliases -i dvb-ttpci kernel-default.rpm

%description
DVB tools and transponder files useful for DVB TV Cards

%prep
%setup -q -n dvb-apps-%{version}
%patch
%patch1
%patch2 -p1
find -name .hg -type d | xargs rm -rfv
find -name .cvsignore -type f | xargs rm -fv
find -name '*.orig' -type f | xargs rm -fv

%build
rm -rf include/linux
make %{?_smp_mflags} CFLAGS="%{optflags} -fno-strict-aliasing -fPIC" \
	CC=gcc \
	bindir=%{_bindir} \
	libdir=%{_libdir} \
	V=1 \
	ttusb_dec_reset=1

%install
export DESTDIR=%{buildroot}
## directories
install -d -m 755 $DESTDIR/usr/{,s}bin $DESTDIR/etc/init.d $DESTDIR/usr/include \
	$DESTDIR/var/adm/fillup-templates
#
## docu
install -d -m 755 $DESTDIR%{_docdir}/dvb
install -m 644 README $DESTDIR%{_docdir}/dvb
#
##
make \
	bindir=%{_bindir} \
	libdir=%{_libdir} \
	prefix=%{_prefix} \
	includedir=%{_includedir} \
	DESTDIR=%{buildroot} \
	install
install -d -m 755 $DESTDIR/%{_docdir}/%{name}/szap
install -m 644 util/szap/README $DESTDIR/%{_docdir}/%{name}/szap
install -m 644 util/ttusb_dec_reset/README $DESTDIR/%{_docdir}/%{name}/README.ttusb_dec_reset
install -m 644 util/av7110_loadkeys/README $DESTDIR/%{_docdir}/%{name}/README.av7110_loadkeys
#
# dvbnet
install -m 644 util/dvbnet/net_start.* $DESTDIR/%{_docdir}/%{name}/
## sysconfig & init
install -m 644 %{SOURCE3} $DESTDIR/var/adm/fillup-templates
ln -sf /etc/init.d/dvb $DESTDIR/usr/sbin/rcdvb
install -m 755 %{SOURCE2} $DESTDIR/etc/init.d/dvb
#
## firmware
install -d -m 755 %{buildroot}%{firmwaredir}
install -m 644 %{SOURCE4} %{buildroot}%{firmwaredir}
cd %{buildroot}%{firmwaredir}
for i in dvb-ttpci-01.fw*; do
	ln -s $i dvb-ttpci-01.fw
	break
done
cd -
#
# noone really uses this so far AFAIK
rm -r %{buildroot}%{_includedir} %{buildroot}%{_libdir}/*.a
# dvbscan is incomplete and defunct
rm %{buildroot}%{_bindir}/dvbscan
#
%fdupes $RPM_BUILD_ROOT

%post
%{fillup_and_insserv dvb}

%postun
%insserv_cleanup

%files
%defattr(-, root, root)
%{_docdir}/dvb
%{_datadir}/dvb
/var/adm/fillup-templates/sysconfig.dvb
%config /etc/init.d/dvb
/usr/sbin/rcdvb
/usr/bin/*
%if %suse_version <= 1020
%dir %{firmwaredir}
%endif
%{_libdir}/*.so
%{firmwaredir}/*

%changelog
openSUSE Build Service is sponsored by