1%define module @PACKAGE@ 2 3%if !%{defined ksrc} 4%if 0%{?rhel}%{?fedora} 5%define ksrc ${kernel_version##*___} 6%else 7%define ksrc "$( \ 8 if [ -e "/usr/src/linux-${kernel_version%%___*}" ]; then \ 9 echo "/usr/src/linux-${kernel_version%%___*}"; \ 10 elif [ -e "/lib/modules/${kernel_version%%___*}/source" ]; then \ 11 echo "/lib/modules/${kernel_version%%___*}/source"; \ 12 else \ 13 echo "/lib/modules/${kernel_version%%___*}/build"; \ 14 fi)" 15%endif 16%endif 17 18%if !%{defined kobj} 19%if 0%{?rhel}%{?fedora} 20%define kobj ${kernel_version##*___} 21%else 22%define kobj "$( \ 23 if [ -e "/usr/src/linux-${kernel_version%%___*}" ]; then \ 24 echo "/usr/src/linux-${kernel_version%%___*}"; \ 25 else \ 26 echo "/lib/modules/${kernel_version%%___*}/build"; \ 27 fi)" 28%endif 29%endif 30 31#define repo rpmfusion 32#define repo chaos 33 34# (un)define the next line to either build for the newest or all current kernels 35%define buildforkernels newest 36#define buildforkernels current 37#define buildforkernels akmod 38 39%bcond_with debug 40%bcond_with debuginfo 41 42 43Name: %{module}-kmod 44 45Version: @VERSION@ 46Release: @RELEASE@%{?dist} 47Summary: Kernel module(s) 48 49Group: System Environment/Kernel 50License: @ZFS_META_LICENSE@ 51URL: https://github.com/openzfs/zfs 52Source0: %{module}-%{version}.tar.gz 53Source10: kmodtool 54BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id} -u -n) 55%if 0%{?rhel}%{?fedora} 56BuildRequires: gcc, make 57BuildRequires: elfutils-libelf-devel 58%endif 59 60%if (0%{?fedora}%{?suse_version}) || (0%{?rhel} && 0%{?rhel} < 9) 61# We don't directly use it, but if this isn't installed, rpmbuild as root can 62# crash+corrupt rpmdb 63# See issue #12071 64BuildRequires: ncompress 65%endif 66 67# The developments headers will conflict with the dkms packages. 68Conflicts: %{module}-dkms 69 70%if %{defined repo} 71 72# Building for a repository use the proper build-sysbuild package 73# to determine which kernel-devel packages should be installed. 74BuildRequires: %{_bindir}/kmodtool 75%{!?kernels:BuildRequires: buildsys-build-%{repo}-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu}} 76 77%else 78 79# Building local packages attempt to to use the installed kernel. 80%{?rhel:BuildRequires: kernel-devel} 81%{?fedora:BuildRequires: kernel-devel} 82%{?suse_version:BuildRequires: kernel-source} 83 84%if !%{defined kernels} && !%{defined build_src_rpm} 85 %if 0%{?rhel}%{?fedora}%{?suse_version} 86 %define kernels %(ls -1 /usr/src/kernels) 87 %else 88 %define kernels %(ls -1 /lib/modules) 89 %endif 90%endif 91%endif 92 93# LDFLAGS are not sanitized by arch/*/Makefile for these architectures. 94%ifarch ppc ppc64 ppc64le aarch64 95%global __global_ldflags %{nil} 96%endif 97 98# Kmodtool does its magic here. A patched version of kmodtool is shipped 99# with the source rpm until kmod development packages are supported upstream. 100# https://bugzilla.rpmfusion.org/show_bug.cgi?id=2714 101%{expand:%(bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} 2>/dev/null) } 102 103 104%description 105This package contains the ZFS kernel modules. 106 107%prep 108# Error out if there was something wrong with kmodtool. 109%{?kmodtool_check} 110 111# Print kmodtool output for debugging purposes: 112bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} 2>/dev/null 113 114%if %{with debug} 115 %define debug --enable-debug 116%else 117 %define debug --disable-debug 118%endif 119 120%if %{with debuginfo} 121 %define debuginfo --enable-debuginfo 122%else 123 %define debuginfo --disable-debuginfo 124%endif 125 126# Leverage VPATH from configure to avoid making multiple copies. 127%define _configure ../%{module}-%{version}/configure 128 129%setup -q -c -T -a 0 130 131for kernel_version in %{?kernel_versions}; do 132 %{__mkdir} _kmod_build_${kernel_version%%___*} 133done 134 135%build 136for kernel_version in %{?kernel_versions}; do 137 cd _kmod_build_${kernel_version%%___*} 138 %configure \ 139 --with-config=kernel \ 140 --with-linux=%{ksrc} \ 141 --with-linux-obj=%{kobj} \ 142 %{debug} \ 143 %{debuginfo} \ 144 %{?kernel_cc} \ 145 %{?kernel_ld} \ 146 %{?kernel_llvm} 147 make %{?_smp_mflags} 148 cd .. 149done 150 151 152%install 153rm -rf ${RPM_BUILD_ROOT} 154 155# Relies on the kernel 'modules_install' make target. 156for kernel_version in %{?kernel_versions}; do 157 cd _kmod_build_${kernel_version%%___*} 158 make install \ 159 DESTDIR=${RPM_BUILD_ROOT} \ 160 %{?prefix:INSTALL_MOD_PATH=%{?prefix}} \ 161 INSTALL_MOD_DIR=%{kmodinstdir_postfix} 162 cd .. 163done 164# find-debuginfo.sh only considers executables 165chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/* 166%{?akmod_install} 167 168 169%clean 170rm -rf $RPM_BUILD_ROOT 171