Blame SPECS/kmod-sata_sil.spec

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