Blame SPECS/kmod-xt_time.spec

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