Blame SPECS/kmod-mlx4.spec

82be66
%global pkg mlx4
82be66
7db234
%global driver_version 4.18.0-348.el8
82be66
7db234
%global kernel_version 4.18.0-348.el8
82be66
82be66
%global _use_internal_dependency_generator 0
1d3c6e
%global __find_requires /usr/lib/rpm/redhat/find-requires
1d3c6e
%global __find_provides /usr/lib/rpm/redhat/find-provides
82be66
82be66
%global debug_package %{nil}
82be66
82be66
%global __spec_install_post \
82be66
  %{?__debug_package:%{__debug_install_post}} \
82be66
  %{__arch_install_post} \
82be66
  %{__os_install_post} \
82be66
  %{__mod_compress_install_post}
82be66
82be66
%global __mod_compress_install_post find %{buildroot}/lib/modules -type f -name \*.ko -exec xz \{\} \\;
82be66
82be66
82be66
Name:             kmod-%{pkg}
7db234
Version:          4.18.0.348
1d3c6e
Release:          1%{?dist}
82be66
Summary:          Mellanox ConnectX HCA (%{pkg}) driver
82be66
82be66
License:          GPLv2 and (BSD or GPLv2)
82be66
URL:              https://www.kernel.org/
82be66
184af8
Source0:          %{pkg}-%{driver_version}.tar.xz
82be66
Patch1:           0001-disable-mlx4_en.patch
82be66
Patch2:           0002-enable-mlx4_core-gen2.patch
82be66
82be66
ExclusiveArch:    x86_64 aarch64
82be66
82be66
BuildRequires:    elfutils-libelf-devel
82be66
BuildRequires:    gcc
1d3c6e
BuildRequires:    kernel-rpm-macros
82be66
BuildRequires:    kmod
82be66
BuildRequires:    make
82be66
BuildRequires:    redhat-rpm-config
82be66
BuildRequires:    xz
82be66
1d3c6e
BuildRequires:    kernel-abi-stablelists = %{kernel_version}
82be66
BuildRequires:    kernel-devel = %{kernel_version}
82be66
BuildRequires:    kernel-devel-uname-r = %{kernel_version}.%{_arch}
82be66
1d3c6e
Requires:         kernel >= %{kernel_version}
1d3c6e
Requires:         kernel-uname-r >= %{kernel_version}.%{_arch}
1d3c6e
Requires:         kernel-modules >= %{kernel_version}
1d3c6e
Requires:         kernel-modules-uname-r >= %{kernel_version}.%{_arch}
82be66
82be66
Provides:         installonlypkg(kernel-module)
1d3c6e
Provides:         kernel-modules >= %{kernel_version}.%{_arch}
82be66
1d3c6e
Requires(post):   %{_sbindir}/depmod
1d3c6e
Requires(postun): %{_sbindir}/depmod
82be66
1d3c6e
Requires(post):   %{_sbindir}/weak-modules
1d3c6e
Requires(postun): %{_sbindir}/weak-modules
82be66
82be66
82be66
%description
82be66
This package provides the Mellanos ConnectX HCA (%{pkg}) driver. Compared to
82be66
the in-kernel driver this driver re-enables support for deprecated Mellanox
82be66
Gen2 and ConnectX-2 adapters:
82be66
82be66
- 0x15B3:0x1002: Mellanox ConnectX-2 MT25400
82be66
- 0x15B3:0x6340: Mellanox Hermon SDR
82be66
- 0x15B3:0x634A: Mellanox Hermon DDR
82be66
- 0x15B3:0x6354: Mellanox Hermon QDR
82be66
- 0x15B3:0x6368: Mellanox Hermon EN 10GigE
82be66
- 0x15B3:0x6372: Mellanox ConnectX EN 10GBASE-T
82be66
- 0x15B3:0x6732: Mellanox Hermon DDR Gen2
82be66
- 0x15B3:0x673C: Mellanox Hermon QDR Gen2
82be66
- 0x15B3:0x6746: Mellanox ConnectX EN 40GigE PCIe Gen2 5GT/s
82be66
- 0x15B3:0x6750: Mellanox Hermon EN 10GigE Gen2
82be66
- 0x15B3:0x675A: Mellanox ConnectX EN 10GBASE-T Gen2
82be66
- 0x15B3:0x6764: Mellanox ConnectX EN 10 GigE PCIe Gen2
82be66
- 0x15B3:0x676E: Mellanox ConnectX-2 40GigE PCIe Gen2
82be66
82be66
82be66
%prep
184af8
%autosetup -p1 -n %{pkg}-%{driver_version}
82be66
82be66
82be66
%build
82be66
pushd src
82be66
%{__make} -C /usr/src/kernels/%{kernel_version}.%{_arch} %{?_smp_mflags} M=$PWD modules
82be66
popd
82be66
82be66
82be66
%install
82be66
%{__install} -D -t %{buildroot}/lib/modules/%{kernel_version}.%{_arch}/extra/drivers/net/ethernet/mellanox/%{pkg} src/%{pkg}_core.ko
82be66
82be66
# Make .ko objects temporarily executable for automatic stripping
82be66
find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+
82be66
1d3c6e
# Generate depmod.conf
1d3c6e
%{__install} -d %{buildroot}/%{_sysconfdir}/depmod.d/
1d3c6e
for kmod in $(find %{buildroot}/lib/modules/%{kernel_version}.%{_arch}/extra -type f -name \*.ko -printf "%%P\n" | sort)
1d3c6e
do
1d3c6e
    echo "override $(basename $kmod .ko) * weak-updates/$(dirname $kmod)" >> %{buildroot}/%{_sysconfdir}/depmod.d/%{pkg}.conf
1d3c6e
done
1d3c6e
82be66
82be66
%clean
82be66
%{__rm} -rf %{buildroot}
82be66
82be66
82be66
%post
82be66
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
1d3c6e
printf '%s\n' "/lib/modules/%{kernel_version}.%{_arch}/extra/drivers/net/ethernet/mellanox/%{pkg}/%{pkg}_core.ko.xz" >> %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add
82be66
82be66
82be66
%preun
82be66
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
1d3c6e
rpm -ql kmod-%{pkg}-%{?epoch:%{epoch}:}%{version}-%{release}.%{_arch} | grep '/lib/modules/%{kernel_version}.%{_arch}/.*\.ko\.xz$' >> %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove
82be66
82be66
82be66
%postun
1d3c6e
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove ]
82be66
then
1d3c6e
    modules=( $(cat %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove) )
1d3c6e
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove
82be66
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
1d3c6e
    printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --remove-modules
82be66
fi
82be66
82be66
1d3c6e
%pretrans -p <lua>
1d3c6e
posix.unlink("%{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add")
1d3c6e
posix.unlink("%{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove")
1d3c6e
1d3c6e
82be66
%posttrans
1d3c6e
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add ]
82be66
then
1d3c6e
    modules=( $(cat %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add) )
1d3c6e
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add
82be66
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
1d3c6e
    printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --add-modules
82be66
fi
82be66
82be66
82be66
%files
82be66
%defattr(644,root,root,755)
82be66
/lib/modules/%{kernel_version}.%{_arch}
06e4ff
%license LICENSES
1d3c6e
%config(noreplace) %{_sysconfdir}/depmod.d/%{pkg}.conf
82be66
82be66
82be66
%changelog
7db234
* Tue Nov 09 2021 Peter Georg <peter.georg@physik.uni-regensburg.de> - 4.18.0.348-1
7db234
- Update to 4.18.0-348.el8
7db234
1d3c6e
* Thu Oct 28 2021 Peter Georg <peter.georg@physik.uni-regensburg.de> - 4.18.0.305-1
657162
- Convert to kABI tracking kmod package (kernel >= 4.18.0-305.7.1.el8)
657162
- Build 4.18.0-305.el8 for 4.18.0-305.7.1.el8_4
1d3c6e
- Use release number independent of kernel
1d3c6e
- Add driver release number to version