Blame SPECS/kmod-jme.spec

a463fa
%global pkg jme
a463fa
a463fa
%global kernel_version_min 4.18.0-240.el8
a463fa
a463fa
# To pick a specific kernel use `--define "kernel_version 4.18.0-315.el8"`
a463fa
# Otherwise the latest installed kernel-devel version later than
a463fa
# %%{kernel_version_min} will be used.
a463fa
a463fa
%global kernel_version_latest %({ echo %{kernel_version_min}; rpm --query kernel-devel --queryformat '%%{VERSION}-%%{RELEASE}\\\n' | grep -v "package kernel-devel is not installed"; } | sort -V | sed -e '0,/^%{kernel_version_min}$/d' | tail -n 1)
a463fa
a463fa
%if "%{kernel_version_latest}" != ""
a463fa
%{!?kernel_version:%{expand:%%global kernel_version %{kernel_version_latest}}}
a463fa
%endif
a463fa
a463fa
%global _use_internal_dependency_generator 0
a463fa
%global __find_requires %{nil}
a463fa
%global __find_provides /usr/lib/rpm/find-provides
a463fa
a463fa
%global debug_package %{nil}
a463fa
a463fa
%global __spec_install_post \
a463fa
  %{?__debug_package:%{__debug_install_post}} \
a463fa
  %{__arch_install_post} \
a463fa
  %{__os_install_post} \
a463fa
  %{__mod_compress_install_post}
a463fa
a463fa
%global __mod_compress_install_post find %{buildroot}/lib/modules -type f -name \*.ko -exec xz \{\} \\;
a463fa
a463fa
a463fa
Name:             kmod-%{pkg}
a463fa
Version:          5.2
751bac
Release:          2%{?dist}
a463fa
Summary:          JMicron JMC2x0 PCI-E Gigabit Ethernet (%{pkg}) driver
a463fa
a463fa
License:          GPLv2
a463fa
URL:              https://www.kernel.org/
a463fa
a463fa
Source0:          %{pkg}-%{version}.tar.xz
a463fa
a463fa
ExclusiveArch:    x86_64 aarch64
a463fa
a463fa
BuildRequires:    elfutils-libelf-devel
a463fa
BuildRequires:    gcc
a463fa
BuildRequires:    kmod
a463fa
BuildRequires:    make
a463fa
BuildRequires:    redhat-rpm-config
a463fa
BuildRequires:    xz
a463fa
a463fa
%{!?kernel_version:
a463fa
BuildRequires:    kernel-devel >= %{kernel_version_min}
a463fa
}
a463fa
a463fa
%{?kernel_version:
a463fa
BuildRequires:    kernel-devel = %{kernel_version}
a463fa
BuildRequires:    kernel-devel-uname-r = %{kernel_version}.%{_arch}
a463fa
a463fa
Requires:         kernel-core = %{kernel_version}
a463fa
Requires:         kernel-core-uname-r = %{kernel_version}.%{_arch}
a463fa
Requires:         kernel-modules = %{kernel_version}
a463fa
Requires:         kernel-modules-uname-r = %{kernel_version}.%{_arch}
a463fa
a463fa
Provides:         installonlypkg(kernel-module)
a463fa
Provides:         %{name}-%{kernel_version}.%{_arch} = %{?epoch:%{epoch}:}%{version}-%{release}
a463fa
}
a463fa
a463fa
Requires(post):   /usr/sbin/depmod
a463fa
Requires(postun): /usr/sbin/depmod
a463fa
a463fa
Requires(post):   /usr/bin/dracut
a463fa
Requires(postun): /usr/bin/dracut
a463fa
a463fa
a463fa
%description
a463fa
This driver supports Gigabit Ethernet adapters based on the JMC2x0 chipsets.
a463fa
a463fa
a463fa
%prep
a463fa
%autosetup -p1 -n %{pkg}-%{version}
a463fa
a463fa
a463fa
%build
a463fa
pushd src
a463fa
%{__make} -C /usr/src/kernels/%{kernel_version}.%{_arch} %{?_smp_mflags} M=$PWD modules
a463fa
popd
a463fa
a463fa
a463fa
%install
a463fa
%{__install} -D -t %{buildroot}/lib/modules/%{kernel_version}.%{_arch}/extra/drivers/net/ethernet src/%{pkg}.ko
a463fa
a463fa
# Make .ko objects temporarily executable for automatic stripping
a463fa
find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+
a463fa
a463fa
a463fa
%clean
a463fa
%{__rm} -rf %{buildroot}
a463fa
a463fa
a463fa
%post
a463fa
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
a463fa
touch %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
a463fa
a463fa
a463fa
%preun
a463fa
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
a463fa
touch %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
a463fa
a463fa
a463fa
%postun
a463fa
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} ]
a463fa
then
a463fa
    if [ -f /lib/modules/%{kernel_version}.%{_arch}/System.map ]
a463fa
    then
a463fa
        /usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch}
a463fa
    fi
a463fa
a463fa
    if [ -f /boot/initramfs-%{kernel_version}.%{_arch}.img ]
a463fa
    then
a463fa
        if /usr/bin/dracut -f --rebuild /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew %{kernel_version}.%{_arch}
a463fa
        then
a463fa
            if ! cmp -s /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
a463fa
            then
a463fa
                mv /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew /boot/initramfs-%{kernel_version}.%{_arch}.img
a463fa
            else
a463fa
                rm -f /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
a463fa
            fi
a463fa
        fi
a463fa
    fi
a463fa
a463fa
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
a463fa
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
a463fa
fi
a463fa
a463fa
a463fa
%posttrans
a463fa
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} ]
a463fa
then
a463fa
    if [ -f /lib/modules/%{kernel_version}.%{_arch}/System.map ]
a463fa
    then
a463fa
        /usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch}
a463fa
    fi
a463fa
a463fa
    if [ -f /boot/initramfs-%{kernel_version}.%{_arch}.img ]
a463fa
    then
a463fa
        if /usr/bin/dracut -f --rebuild /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew %{kernel_version}.%{_arch}
a463fa
        then
a463fa
            if ! cmp -s /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
a463fa
            then
a463fa
                mv /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew /boot/initramfs-%{kernel_version}.%{_arch}.img
a463fa
            else
a463fa
                rm -f /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
a463fa
            fi
a463fa
        fi
a463fa
    fi
a463fa
a463fa
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
a463fa
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
a463fa
fi
a463fa
a463fa
a463fa
%files
a463fa
%defattr(644,root,root,755)
a463fa
/lib/modules/%{kernel_version}.%{_arch}
a463fa
%license COPYING
a463fa
a463fa
a463fa
%changelog
751bac
* Wed Aug 11 2021 Peter Georg <peter.georg@physik.uni-regensburg.de> - 5.2-2
751bac
- Rebuild for 4.18.0-326.el8
751bac
a463fa
* Tue Aug 10 2021 Peter Georg <peter.georg@physik.uni-regensburg.de> - 5.2-1
a463fa
- Initial version