From f037f6d1bdb893ab94a5fcfffdcb158720fbf138 Mon Sep 17 00:00:00 2001 From: Peter Georg Date: Jul 22 2021 11:21:31 +0000 Subject: Improve handling kernel versions * Add auto-detection for latest (installed) kernel version * Allow setting minimum kernel version supported * Allow setting a particular kernel version --- diff --git a/SPECS/kmod-wireguard.spec b/SPECS/kmod-wireguard.spec index 662a5b2..6083728 100644 --- a/SPECS/kmod-wireguard.spec +++ b/SPECS/kmod-wireguard.spec @@ -1,6 +1,16 @@ %global pkg wireguard -%global kernel_version 4.18.0-315.el8 +%global kernel_version_min 4.18.0-315.el8 + +# To pick a specific kernel use `--define "kernel_version 4.18.0-315.el8"` +# Otherwise the later version of %%{kernel_version_min} and the 'latest' +# installed version of kernel-devel will be used. + +%global kernel_version_latest %({ echo %{kernel_version_min}; rpm --query kernel-devel --queryformat '%%{VERSION}-%%{RELEASE}\\\n' | grep -v kernel-devel; } | 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 @@ -32,20 +42,29 @@ ExclusiveArch: x86_64 aarch64 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} Supplements: wireguard-tools