Blame SPECS/kmod-sata_sil.spec

e9b154
%global pkg sata_sil
e9b154
358e60
%global kernel_version 4.18.0-305.7.1.el8_4
e9b154
e9b154
%global _use_internal_dependency_generator 0
358e60
%global __find_requires /usr/lib/rpm/redhat/find-requires
358e60
%global __find_provides /usr/lib/rpm/redhat/find-provides
e9b154
e9b154
%global debug_package %{nil}
e9b154
e9b154
%global __spec_install_post \
e9b154
  %{?__debug_package:%{__debug_install_post}} \
e9b154
  %{__arch_install_post} \
e9b154
  %{__os_install_post} \
e9b154
  %{__mod_compress_install_post}
e9b154
e9b154
%global __mod_compress_install_post find %{buildroot}/lib/modules -type f -name \*.ko -exec xz \{\} \\;
e9b154
e9b154
e9b154
Name:             kmod-%{pkg}
e9b154
Version:          5.4
358e60
Release:          5%{?dist}
e9b154
Summary:          Silicon Image SATA Controller (%{pkg}) driver
e9b154
e9b154
License:          GPLv2
e9b154
URL:              https://www.kernel.org/
e9b154
e9b154
Source0:          %{pkg}-%{version}.tar.xz
e9b154
e9b154
ExclusiveArch:    x86_64
e9b154
e9b154
BuildRequires:    elfutils-libelf-devel
e9b154
BuildRequires:    gcc
358e60
BuildRequires:    kernel-rpm-macros
e9b154
BuildRequires:    kmod
e9b154
BuildRequires:    make
e9b154
BuildRequires:    redhat-rpm-config
e9b154
BuildRequires:    xz
e9b154
358e60
BuildRequires:    kernel-abi-stablelists = %{kernel_version}
e9b154
BuildRequires:    kernel-devel = %{kernel_version}
e9b154
BuildRequires:    kernel-devel-uname-r = %{kernel_version}.%{_arch}
e9b154
358e60
Requires:         kernel >= %{kernel_version}
358e60
Requires:         kernel-uname-r >= %{kernel_version}.%{_arch}
358e60
Requires:         kernel-modules >= %{kernel_version}
358e60
Requires:         kernel-modules-uname-r >= %{kernel_version}.%{_arch}
e9b154
e9b154
Provides:         installonlypkg(kernel-module)
358e60
Provides:         kernel-modules >= %{kernel_version}.%{_arch}
e9b154
358e60
Requires(post):   %{_sbindir}/depmod
358e60
Requires(postun): %{_sbindir}/depmod
e9b154
358e60
Requires(post):   %{_sbindir}/weak-modules
358e60
Requires(postun): %{_sbindir}/weak-modules
e9b154
e9b154
e9b154
%description
e9b154
This driver supports Silicon Image SATA controllers.
e9b154
e9b154
e9b154
%prep
e9b154
%autosetup -p1 -n %{pkg}-%{version}
e9b154
e9b154
e9b154
%build
e9b154
pushd src
e9b154
%{__make} -C /usr/src/kernels/%{kernel_version}.%{_arch} %{?_smp_mflags} M=$PWD modules
e9b154
popd
e9b154
e9b154
e9b154
%install
e9b154
%{__install} -D -t %{buildroot}/lib/modules/%{kernel_version}.%{_arch}/extra/drivers/ata src/%{pkg}.ko
e9b154
%{__install} -d %{buildroot}/%{_sysconfdir}/dracut.conf.d/
e9b154
echo "add_drivers+=\" %{pkg} \"" > %{buildroot}/%{_sysconfdir}/dracut.conf.d/%{pkg}.conf
e9b154
e9b154
# Make .ko objects temporarily executable for automatic stripping
e9b154
find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+
e9b154
e9b154
e9b154
%clean
e9b154
%{__rm} -rf %{buildroot}
e9b154
e9b154
e9b154
%post
e9b154
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
358e60
printf '%s\n' "/lib/modules/%{kernel_version}.%{_arch}/extra/drivers/ata/%{pkg}.ko.xz" >> %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add
e9b154
e9b154
e9b154
%preun
e9b154
mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods
358e60
rpm -ql kmod-%{pkg}-%{?epoch:%{epoch}:}%{version}-%{release}.%{_arch} | grep '/lib/modules/%{kernel_version}.%{_arch}/.*\.ko\.xz$' >> %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove
e9b154
e9b154
e9b154
%postun
358e60
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove ]
e9b154
then
358e60
    modules=( $(cat %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove) )
358e60
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove
e9b154
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
358e60
    printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --remove-modules
e9b154
fi
e9b154
e9b154
358e60
%pretrans -p <lua>
358e60
posix.unlink("%{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add")
358e60
posix.unlink("%{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-remove")
358e60
358e60
e9b154
%posttrans
358e60
if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add ]
e9b154
then
358e60
    modules=( $(cat %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add) )
358e60
    rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/weak-modules-add
e9b154
    rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods
358e60
    printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --add-modules
e9b154
fi
e9b154
e9b154
e9b154
%files
e9b154
%defattr(644,root,root,755)
e9b154
/lib/modules/%{kernel_version}.%{_arch}
e9b154
%license COPYING
e9b154
%config(noreplace) %{_sysconfdir}/dracut.conf.d/%{pkg}.conf
e9b154
e9b154
e9b154
%changelog
358e60
* Tue Sep 28 2021 Peter Georg <peter.georg@physik.uni-regensburg.de> - 5.4-5
358e60
- Convert to kABI tracking kmod package (kernel >= 4.18.0-305.7.1.el8_4)