Blame SPECS/kmod-pata_sis.spec

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