From fcd78c4db3f145226a1f7d1ab07182b07211e723 Mon Sep 17 00:00:00 2001 From: Peter Georg Date: Jul 26 2021 19:54:47 +0000 Subject: Improve handling kernel version --- diff --git a/SPECS/kmod-isci.spec b/SPECS/kmod-isci.spec index 6ffa17a..052f21a 100644 --- a/SPECS/kmod-isci.spec +++ b/SPECS/kmod-isci.spec @@ -1,6 +1,16 @@ %global pkg isci -%global kernel_version 4.18.0-315.el8 +%global kernel_version_min 4.18.0-80.el8 + +# To pick a specific kernel use `--define "kernel_version 4.18.0-315.el8"` +# Otherwise the latest installed kernel-devel version later than +# %%{kernel_version_min} will be used. + +%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) + +%if "%{kernel_version_latest}" != "" +%{!?kernel_version:%{expand:%%global kernel_version %{kernel_version_latest}}} +%endif %global _use_internal_dependency_generator 0 @@ -30,20 +40,29 @@ ExclusiveArch: x86_64 BuildRequires: elfutils-libelf-devel BuildRequires: gcc BuildRequires: kernel-abi-whitelists -BuildRequires: kernel-devel = %{kernel_version} BuildRequires: kernel-rpm-macros BuildRequires: kmod BuildRequires: make BuildRequires: redhat-rpm-config BuildRequires: xz +%{!?kernel_version: +BuildRequires: kernel-devel >= %{kernel_version_min} +} + +%{?kernel_version: +BuildRequires: kernel-devel = %{kernel_version} + Supplements: kernel = %{kernel_version} Requires: (kernel = %{kernel_version} if kernel) + +Provides: kernel-modules = %{kernel_version}.%{_arch} +} + Requires(post): /usr/sbin/depmod Requires(postun): /usr/sbin/depmod -Provides: kernel-modules = %{kernel_version}.%{_arch} Provides: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}