Blame SPECS/kmod-pata_jmicron.spec

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