File v4l-dvb-saa716x.spec of Package v4l-dvb-saa716x

#
# spec file for package v4l-dvb-saa716x on openSuse
#

Name:           v4l-dvb-saa716x
Version:        20210830
Release:        1
Summary:        Kernel modules for SAA716x (TT DVB-S2 6400)
License:        GPL-2.0-or-later and FTL
Group:          System/Kernel
#Url:            https://bitbucket.org/powARman/v4l-dvb-saa716x
# aus srpm extrahiert: http://firefly.vdr-developer.org/patches/v4l-dvb-saa716x-20210830-lp154.1.src.rpm
Url:            https://github.com/s-moch/linux-saa716x

%if 0%{?suse_version} > 1500
Distribution:   openSUSE Tumbleweed (%{_arch})
%else
%if !0%{?is_backports}
%if 0%{?sle_version} >= 150200
Distribution:   openSUSE Leap %(echo "%{sle_version}" | sed -e 's/\(..\).\(.\)../\1.\2/')  (%{_arch})
%endif
%else
%error SLE is not supported
%endif
%endif

Source:         saa716x_s-moch_20210830_stv090x.tgz
Source10:       saa716x-preamble
# firmware downloaded from http://www.aregel.de/downloads/
Source20:       dvb-ttpremium-fpga-01_v1_10.zip
Source21:       dvb-ttpremium-loader-01_v1_03.zip
Source22:       dvb-ttpremium-st7109-01_v0_5_1.zip
Source23:       udev_99-tt6400-ir.rules
Patch0:         saa716x_osd_raw_cmd.diff
Patch1:         stv090x_02_dBmV5.patch

BuildRequires:  %kernel_module_package_buildreqs
BuildRequires:  kernel-source
BuildRequires:  dracut
BuildRequires:  kernel-devel
BuildRequires:  kernel-macros
BuildRequires:  kernel-syms
BuildRequires:  unzip
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       %{name}-firmware = %{version}

%kernel_module_package -p %{_sourcedir}/saa716x-preamble

%description
Kernel modules for the TechnoTrend DVB-S2 6400 DVB card with openSUSE Leap. The original driver source can be found at https://bitbucket.org/powARman/v4l-dvb-saa716x, for newer kernels (e.g. 5.x) at https://github.com/s-moch/linux-saa716x.
The respective firmware files are also required.

%package udev
Summary:        udev rule for IR receiver of SAA716x (TT DVB-S2 6400)
License:        GPL-2.0-or-later
Group:          System/Kernel
BuildArch:      noarch
Requires:       %{name}-kmp = %{version}

%description udev
This package contains an udev rule to create a device for the IR recevier of the SAA716x as used on the TT DVB-S2 6400 card.
To make sure the driver is loaded completly you can depend further systemd actions on the existence of the IR device dev-tt6400ir.device.

%package firmware
Summary:        firmware files for SAA716x (TT DVB-S2 6400)
Group:          System/Kernel
BuildArch:      noarch
Requires:       %{name}-kmp = %{version}

%description firmware
This package contains the firmware files for SAA716x (TT DVB-S2 6400) kernel modules


%prep
%setup -q -c
%patch0 -p0
%patch1 -p3

set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
for flavor in %{flavors_to_build}
do
    rm -rf obj/$flavor
    cp -r source obj/$flavor
    make V=1 %{?_smp_mflags} -C %{kernel_source $flavor} %{?linux_make_arch} M=$PWD/obj/$flavor modules
done

%install
# Kernel modules
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR='%{kernel_module_package_moddir}'
for flavor in %{flavors_to_build}
do
     make V=1 -C %{kernel_source $flavor} M=$PWD/obj/$flavor modules_install
done

# Firmware
unzip -o %{S:20} -d %buildroot/lib/firmware
unzip -o %{S:21} -d %buildroot/lib/firmware
unzip -o %{S:22} -d %buildroot/lib/firmware

# udev rule
mkdir -p %buildroot/etc/udev/rules.d/
cp %{S:23} %buildroot/etc/udev/rules.d/99-tt6400-ir.rules

%post
/sbin/depmod -a

%postun
/sbin/depmod -a

%files udev
%defattr(-,root,root)
#%config(noreplace) /etc/udev/rules.d/99-tt6400-ir.rules
%config /etc/udev/rules.d/99-tt6400-ir.rules

%files firmware
%defattr(-,root,root)
/lib/firmware/dvb-ttpremium-*.fw
%doc /lib/firmware/Changelog
%license /lib/firmware/Licenses


%changelog
openSUSE Build Service is sponsored by