Blame SPECS/kmod-sata_sil.spec

4edac3
%global pkg sata_sil
4edac3
4edac3
%global kernel_version_min 4.18.0-80.el8
4edac3
4edac3
# To pick a specific kernel use `--define "kernel_version 4.18.0-315.el8"`
4edac3
# Otherwise the latest installed kernel-devel version later than
4edac3
# %%{kernel_version_min} will be used.
4edac3
4edac3
%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)
4edac3
4edac3
%if "%{kernel_version_latest}" != ""
4edac3
%{!?kernel_version:%{expand:%%global kernel_version %{kernel_version_latest}}}
4edac3
%endif
4edac3
4edac3
%global _use_internal_dependency_generator 0
4edac3
%global __find_requires %{nil}
4edac3
%global __find_provides /usr/lib/rpm/find-provides
4edac3
4edac3
%global debug_package %{nil}
4edac3
4edac3
%global __spec_install_post \
4edac3
  %{?__debug_package:%{__debug_install_post}} \
4edac3
  %{__arch_install_post} \
4edac3
  %{__os_install_post} \
4edac3
  %{__mod_compress_install_post}
4edac3
4edac3
%global __mod_compress_install_post find %{buildroot}/lib/modules -type f -name \*.ko -exec xz \{\} \\;
4edac3
4edac3
4edac3
Name:             kmod-%{pkg}
4edac3
Version:          5.4
4edac3
Release:          1%{?dist}
4edac3
Summary:          Silicon Image SATA Controller (%{pkg}) driver
4edac3
4edac3
License:          GPLv2
4edac3
URL:              https://www.kernel.org/
4edac3
4edac3
Source0:          %{pkg}-%{version}.tar.xz
4edac3
4edac3
ExclusiveArch:    x86_64
4edac3
4edac3
BuildRequires:    elfutils-libelf-devel
4edac3
BuildRequires:    gcc
4edac3
BuildRequires:    kmod
4edac3
BuildRequires:    make
4edac3
BuildRequires:    redhat-rpm-config
4edac3
BuildRequires:    xz
4edac3
4edac3
%{!?kernel_version:
4edac3
BuildRequires:    kernel-devel >= %{kernel_version_min}
4edac3
}
4edac3
4edac3
%{?kernel_version:
4edac3
BuildRequires:    kernel-devel = %{kernel_version}
4edac3
BuildRequires:    kernel-devel-uname-r = %{kernel_version}.%{_arch}
4edac3
4edac3
Requires:         kernel-core = %{kernel_version}
4edac3
Requires:         kernel-core-uname-r = %{kernel_version}.%{_arch}
4edac3
Requires:         kernel-modules = %{kernel_version}
4edac3
Requires:         kernel-modules-uname-r = %{kernel_version}.%{_arch}
4edac3
4edac3
Provides:         installonlypkg(kernel-module)
4edac3
Provides:         %{name}-%{kernel_version}.%{_arch} = %{?epoch:%{epoch}:}%{version}-%{release}
4edac3
}
4edac3
4edac3
Requires(post):   /usr/sbin/depmod
4edac3
Requires(postun): /usr/sbin/depmod
4edac3
4edac3
Requires(post):   /usr/bin/dracut
4edac3
Requires(postun): /usr/bin/dracut
4edac3
4edac3
4edac3
%description
4edac3
This driver supports Silicon Image SATA controllers.
4edac3
4edac3
4edac3
%prep
4edac3
%autosetup -p1 -n %{pkg}-%{version}
4edac3
4edac3
4edac3
%build
4edac3
pushd src
4edac3
%{__make} -C /usr/src/kernels/%{kernel_version}.%{_arch} %{?_smp_mflags} M=$PWD modules
4edac3
popd
4edac3
4edac3
4edac3
%install
4edac3
%{__install} -D -t %{buildroot}/lib/modules/%{kernel_version}.%{_arch}/extra/drivers/ata src/%{pkg}.ko
4edac3
%{__install} -d %{buildroot}/%{_sysconfdir}/dracut.conf.d/
4edac3
echo "add_drivers+=\" %{pkg} \"" > %{buildroot}/%{_sysconfdir}/dracut.conf.d/%{pkg}.conf
4edac3
4edac3
# Make .ko objects temporarily executable for automatic stripping
4edac3
find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+
4edac3
4edac3
4edac3
%clean
4edac3
%{__rm} -rf %{buildroot}
4edac3
4edac3
4edac3
%post
4edac3
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
4edac3
touch %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
4edac3
4edac3
4edac3
%preun
4edac3
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
4edac3
touch %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
4edac3
4edac3
4edac3
%postun
4edac3
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} ]
4edac3
then
4edac3
    if [ -f /lib/modules/%{kernel_version}.%{_arch}/System.map ]
4edac3
    then
4edac3
        /usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch}
4edac3
    fi
4edac3
4edac3
    if [ -f /boot/initramfs-%{kernel_version}.%{_arch}.img ]
4edac3
    then
4edac3
        if /usr/bin/dracut -f --rebuild /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew %{kernel_version}.%{_arch}
4edac3
        then
4edac3
            if ! cmp -s /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
4edac3
            then
4edac3
                mv /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew /boot/initramfs-%{kernel_version}.%{_arch}.img
4edac3
            else
4edac3
                rm -f /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
4edac3
            fi
4edac3
        fi
4edac3
    fi
4edac3
4edac3
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
4edac3
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
4edac3
fi
4edac3
4edac3
4edac3
%posttrans
4edac3
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} ]
4edac3
then
4edac3
    if [ -f /lib/modules/%{kernel_version}.%{_arch}/System.map ]
4edac3
    then
4edac3
        /usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch}
4edac3
    fi
4edac3
4edac3
    if [ -f /boot/initramfs-%{kernel_version}.%{_arch}.img ]
4edac3
    then
4edac3
        if /usr/bin/dracut -f --rebuild /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew %{kernel_version}.%{_arch}
4edac3
        then
4edac3
            if ! cmp -s /boot/initramfs-%{kernel_version}.%{_arch}.img /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
4edac3
            then
4edac3
                mv /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew /boot/initramfs-%{kernel_version}.%{_arch}.img
4edac3
            else
4edac3
                rm -f /boot/initramfs-%{kernel_version}.%{_arch}.img.rpmnew
4edac3
            fi
4edac3
        fi
4edac3
    fi
4edac3
4edac3
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch}
4edac3
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
4edac3
fi
4edac3
4edac3
4edac3
%files
4edac3
%defattr(644,root,root,755)
4edac3
/lib/modules/%{kernel_version}.%{_arch}
4edac3
%license COPYING
4edac3
%config(noreplace) %{_sysconfdir}/dracut.conf.d/%{pkg}.conf
4edac3
4edac3
4edac3
%changelog
4edac3
* Mon Aug  9 2021 Peter Georg <peter.georg@physik.uni-regensburg.de> - 5.4-1
4edac3
- Initial version