1 %define module @PACKAGE@
4 %if 0%{?rhel}%{?fedora}%{?openEuler}
5 %define ksrc $
{kernel_version
##*___}
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"
; \
13 echo "
/lib
/modules
/$
{kernel_version%
%___*}/build"
; \
19 %if 0%{?rhel}%{?fedora}%{?openEuler}
20 %define kobj $
{kernel_version
##*___}
23 if [ -e "
/usr
/src
/linux
-$
{kernel_version%
%___*}"
]; then \
24 echo "
/usr
/src
/linux
-$
{kernel_version%
%___*}"
; \
26 echo "
/lib
/modules
/$
{kernel_version%
%___*}/build"
; \
31 #define repo rpmfusion
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
46 Release: @RELEASE@
%{?dist}
47 Summary: Kernel module
(s
)
49 Group: System Environment
/Kernel
50 License: @ZFS_META_LICENSE@
51 URL: https
://github.com
/openzfs
/zfs
52 Source0: %{module}-%{version}.tar.gz
54 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id} -u
-n
)
55 %if 0%{?rhel}%{?fedora}%{?openEuler}
56 BuildRequires
: gcc
, make
57 BuildRequires
: elfutils
-libelf
-devel
60 %if (0%{?fedora}%{?suse_version}%{?openEuler}) || (0%{?rhel} && 0%{?rhel} < 9)
61 # We don't directly use it, but if this isn't installed, rpmbuild as root can
64 BuildRequires
: ncompress
67 # The developments headers will conflict with the dkms packages.
68 Conflicts: %{module}-dkms
72 # Building for a repository use the proper build-sysbuild package
73 # to determine which kernel-devel packages should be installed.
74 BuildRequires
: %{_bindir}/kmodtool
75 %{!?kernels:BuildRequires: buildsys-build-%{repo}-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu}}
79 # Building local packages attempt to to use the installed kernel.
80 %{?rhel:BuildRequires: kernel-devel}
81 %{?fedora:BuildRequires: kernel-devel}
82 %{?openEuler:BuildRequires: kernel-devel}
83 %{?suse_version:BuildRequires: kernel-source}
85 %if !%{defined kernels} && !%{defined build_src_rpm}
86 %if 0%{?rhel}%{?fedora}%{?suse_version}%{?openEuler}
87 %define kernels %
(ls
-1 /usr
/src
/kernels
)
89 %define kernels %
(ls
-1 /lib
/modules
)
94 # LDFLAGS are not sanitized by arch/*/Makefile for these architectures.
95 %ifarch ppc ppc64 ppc64le aarch64
96 %global __global_ldflags
%{nil}
99 # Kmodtool does its magic here. A patched version of kmodtool is shipped
100 # with the source rpm until kmod development packages are supported upstream.
101 # https://bugzilla.rpmfusion.org/show_bug.cgi?id=2714
102 %{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) }
106 This package contains the ZFS kernel modules.
109 # Error out if there was something wrong with kmodtool.
112 # Print kmodtool output for debugging purposes:
113 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
116 %define debug
--enable-debug
118 %define debug
--disable
-debug
121 %if %{with debuginfo}
122 %define debuginfo
--enable-debuginfo
124 %define debuginfo
--disable
-debuginfo
127 # Leverage VPATH from configure to avoid making multiple copies.
128 %define _configure ..
/%{module}-%{version}/configure
132 for kernel_version
in %{?kernel_versions}; do
133 %{__mkdir} _kmod_build_${kernel_version%%___*}
137 for kernel_version
in %{?kernel_versions}; do
138 cd _kmod_build_$
{kernel_version%
%___*}
140 --with
-config
=kernel \
141 --with
-linux
=%{ksrc} \
142 --with
-linux
-obj
=%{kobj} \
149 # Pre-6.10 kernel builds didn't need to copy over the source files to the
150 # build directory. However we do need to do it though post-6.10 due to
153 # b1992c3772e6 kbuild: use $(src) instead of $(srctree)/$(src) for source
156 # 9a0ebe5011f4 kbuild: use $(obj)/ instead of $(src)/ for common pattern
159 # Note that kmodtool actually copies over the source into the build
160 # directory, so what we're doing here is normal. For efficiency reasons
161 # though we just use hardlinks instead of copying.
163 # See https://github.com/openzfs/zfs/issues/16439 for more info.
164 cp
-lR ..
/%{module}-%{version}/module
/* module
/
171 # Module signing (modsign)
173 # This must be run _after_ find-debuginfo.sh runs, otherwise that will strip
174 # the signature off of the modules.
175 # (Based on Fedora's kernel.spec workaround)
176 %define __modsign_install_post \
177 sign_pem
="
%{ksrc}/certs
/signing_key.pem"
; \
178 sign_x509
="
%{ksrc}/certs
/signing_key.x509"
; \
179 if [ -f "$
{sign_x509
}"
]\
181 echo "Signing kernel modules ..."
; \
182 for kmod
in $
(find $
{RPM_BUILD_ROOT
}%{kmodinstdir_prefix}/*/extra
/ -name \
*.ko
); do \
183 %{ksrc}/scripts/sign-file sha256 ${sign_pem} ${sign_x509} ${kmod}; \
188 # hack to ensure signing happens after find-debuginfo.sh runs
189 %define __spec_install_post \
190 %{?__debug_package:%{__debug_install_post}}\
191 %{__arch_install_post}\
192 %{__os_install_post}\
193 %{__modsign_install_post}
196 rm -rf $
{RPM_BUILD_ROOT
}
198 # Relies on the kernel 'modules_install' make target.
199 for kernel_version
in %{?kernel_versions}; do
200 cd _kmod_build_$
{kernel_version%
%___*}
202 DESTDIR
=$
{RPM_BUILD_ROOT
} \
203 %{?prefix:INSTALL_MOD_PATH=%{?prefix}} \
204 INSTALL_MOD_DIR
=%{kmodinstdir_postfix}
207 # find-debuginfo.sh only considers executables
208 chmod u
+x $
{RPM_BUILD_ROOT
}%{kmodinstdir_prefix}/*/extra
/*/*
213 rm -rf $RPM_BUILD_ROOT