Blame SPECS/kmod-sata_via.spec

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