Blame SPECS/kmod-pata_via.spec

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