Blame SPECS/kmod-sata_uli.spec

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