config/dracut/90zfs: handle cases where hostid(1) returns all zeros
[zfs.git] / rpm / generic / zfs-kmod.spec.in
blob782ad465e36d5b0e8df4f784ca02c522453b912d
1 %define module @PACKAGE@
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
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
31 #define repo rpmfusion
32 #define repo chaos
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
39 %bcond_with debug
40 %bcond_with debuginfo
43 Name: %{module}-kmod
45 Version: @VERSION@
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
53 Source10: kmodtool
54 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id} -u -n)
55 %if 0%{?rhel}%{?fedora}
56 BuildRequires: gcc, make
57 BuildRequires: elfutils-libelf-devel
58 %endif
60 # The developments headers will conflict with the dkms packages.
61 Conflicts: %{module}-dkms
63 %if %{defined repo}
65 # Building for a repository use the proper build-sysbuild package
66 # to determine which kernel-devel packages should be installed.
67 BuildRequires: %{_bindir}/kmodtool
68 %{!?kernels:BuildRequires: buildsys-build-%{repo}-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu}}
70 %else
72 # Building local packages attempt to to use the installed kernel.
73 %{?rhel:BuildRequires: kernel-devel}
74 %{?fedora:BuildRequires: kernel-devel}
75 %{?suse_version:BuildRequires: kernel-source}
77 %if !%{defined kernels} && !%{defined build_src_rpm}
78 %if 0%{?rhel}%{?fedora}%{?suse_version}
79 %define kernels %(ls -1 /usr/src/kernels)
80 %else
81 %define kernels %(ls -1 /lib/modules)
82 %endif
83 %endif
84 %endif
86 # LDFLAGS are not sanitized by arch/*/Makefile for these architectures.
87 %ifarch ppc ppc64 ppc64le aarch64
88 %global __global_ldflags %{nil}
89 %endif
91 %if 0%{?fedora} >= 17
92 %define prefix /usr
93 %endif
95 # Kmodtool does its magic here. A patched version of kmodtool is shipped
96 # with the source rpm until kmod development packages are supported upstream.
97 # https://bugzilla.rpmfusion.org/show_bug.cgi?id=2714
98 %{expand:%(bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} --obsolete-name spl --obsolete-version 0.8 2>/dev/null) }
101 %description
102 This package contains the ZFS kernel modules.
104 %prep
105 # Error out if there was something wrong with kmodtool.
106 %{?kmodtool_check}
108 # Print kmodtool output for debugging purposes:
109 bash %{SOURCE10} --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} --devel %{?prefix:--prefix "%{?prefix}"} %{?kernels:--for-kernels "%{?kernels}"} %{?kernelbuildroot:--buildroot "%{?kernelbuildroot}"} --obsolete-name spl --obsolete-version 0.8 2>/dev/null
111 %if %{with debug}
112 %define debug --enable-debug
113 %else
114 %define debug --disable-debug
115 %endif
117 %if %{with debuginfo}
118 %define debuginfo --enable-debuginfo
119 %else
120 %define debuginfo --disable-debuginfo
121 %endif
123 # Leverage VPATH from configure to avoid making multiple copies.
124 %define _configure ../%{module}-%{version}/configure
126 %setup -q -c -T -a 0
128 for kernel_version in %{?kernel_versions}; do
129 %{__mkdir} _kmod_build_${kernel_version%%___*}
130 done
132 %build
133 for kernel_version in %{?kernel_versions}; do
134 cd _kmod_build_${kernel_version%%___*}
135 %configure \
136 --with-config=kernel \
137 --with-linux=%{ksrc} \
138 --with-linux-obj=%{kobj} \
139 %{debug} \
140 %{debuginfo}
141 make %{?_smp_mflags}
142 cd ..
143 done
146 %install
147 rm -rf ${RPM_BUILD_ROOT}
149 # Relies on the kernel 'modules_install' make target.
150 for kernel_version in %{?kernel_versions}; do
151 cd _kmod_build_${kernel_version%%___*}
152 make install \
153 DESTDIR=${RPM_BUILD_ROOT} \
154 %{?prefix:INSTALL_MOD_PATH=%{?prefix}} \
155 INSTALL_MOD_DIR=%{kmodinstdir_postfix}
156 cd ..
157 done
158 # find-debuginfo.sh only considers executables
159 chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/*
160 %{?akmod_install}
163 %clean
164 rm -rf $RPM_BUILD_ROOT