%define debug_package %{nil}

Name:           dpdk-igb_uio
Version:        19.08
Release:        1%{?dist}
Summary:        DPDK IGB UIO kernel module
License:        GPLv2+
URL:            http://dpdk.org
Source0:        %{name}-%{version}.tar.xz
Source1:        dpdk-igb_uio.conf

%description
The IGB UIO module for userspace RDMA built from DPDK source code.

%package -n dkms-%{name}
Summary:        DKMS IGB UIO kernel module
Requires:       dkms
BuildArch:      noarch

%description -n dkms-%{name}
The IGB UIO module for userspace RDMA built from DPDK source code.

%prep
%setup -q

%build

%install
# Install the sources of the module
mkdir -p %{buildroot}%{_usrsrc}/%{name}-%{version}-%{release}
install -D -p -m 0644 kernel/linux/igb_uio/* %{buildroot}%{_usrsrc}/%{name}-%{version}-%{release}
install -D -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/modules-load.d/dpdk-igb_uio.conf

cat > %{buildroot}%{_usrsrc}/%{name}-%{version}-%{release}/dkms.conf <<EOF
PACKAGE_NAME="igb_uio"
PACKAGE_VERSION="%{version}-%{release}"
BUILT_MODULE_NAME[0]="igb_uio"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net"
AUTOINSTALL="yes"
NO_WEAK_MODULES="yes"
MAKE[0]="make module"
CLEAN="make clean"
STRIP[0]=no
EOF

%post -n dkms-%{name}
dkms add -m %{name} -v %{version}-%{release} --rpm_safe_upgrade
dkms build -m %{name} -v %{version}-%{release} --rpm_safe_upgrade
dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade

%preun -n dkms-%{name}
dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all || :

%files -n dkms-%{name}
%{_sysconfdir}/modules-load.d/dpdk-igb_uio.conf
%{_usrsrc}/%{name}-%{version}-%{release}/