xref: /freebsd/sys/contrib/openzfs/rpm/redhat/zfs-kmod.spec.in (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1%bcond_with     debug
2%bcond_with     debuginfo
3
4Name:           @PACKAGE@-kmod
5Version:        @VERSION@
6Release:        @RELEASE@%{?dist}
7
8Summary:        Kernel module(s)
9Group:          System Environment/Kernel
10License:        @ZFS_META_LICENSE@
11URL:            https://github.com/openzfs/zfs
12BuildRequires:  %kernel_module_package_buildreqs
13Source0:        @PACKAGE@-%{version}.tar.gz
14BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
15
16# Additional dependency information for the kmod sub-package must be specified
17# by generating a preamble text file which kmodtool can append to the spec file.
18%(/bin/echo -e "\
19Requires:       @PACKAGE@ = %{version}\n\
20Conflicts:      @PACKAGE@-dkms" > %{_sourcedir}/kmod-preamble)
21
22# LDFLAGS are not sanitized by arch/*/Makefile for these architectures.
23%ifarch ppc ppc64 ppc64le aarch64
24%global __global_ldflags %{nil}
25%endif
26
27%description
28This package contains the ZFS kernel modules.
29
30%define kmod_name @PACKAGE@
31
32%kernel_module_package -n %{kmod_name} -p %{_sourcedir}/kmod-preamble
33
34%define ksrc %{_usrsrc}/kernels/%{kverrel}
35%define kobj %{ksrc}
36
37%package -n kmod-%{kmod_name}-devel
38Summary:        ZFS kernel module(s) devel common
39Group:          System Environment/Kernel
40
41%description -n  kmod-%{kmod_name}-devel
42This package provides the header files and objects to build kernel modules.
43
44%prep
45if ! [ -d "%{ksrc}"  ]; then
46        echo "Kernel build directory isn't set properly, cannot continue"
47        exit 1
48fi
49
50%if %{with debug}
51%define debug --enable-debug
52%else
53%define debug --disable-debug
54%endif
55
56%if %{with debuginfo}
57%define debuginfo --enable-debuginfo
58%else
59%define debuginfo --disable-debuginfo
60%endif
61
62%setup -n %{kmod_name}-%{version}
63%build
64%configure \
65        --with-config=kernel \
66        --with-linux=%{ksrc} \
67        --with-linux-obj=%{kobj} \
68        %{debug} \
69        %{debuginfo} \
70        %{?kernel_cc} \
71        %{?kernel_ld} \
72        %{?kernel_llvm} \
73        %{?kernel_cross_compile} \
74        %{?kernel_arch}
75make %{?_smp_mflags}
76
77# Module signing (modsign)
78#
79# This must be run _after_ find-debuginfo.sh runs, otherwise that will strip
80# the signature off of the modules.
81# (Based on Fedora's kernel.spec workaround)
82%define __modsign_install_post \
83        sign_pem="%{ksrc}/certs/signing_key.pem"; \
84        sign_x509="%{ksrc}/certs/signing_key.x509"; \
85        if [ -f "${sign_x509}" ]\
86        then \
87            echo "Signing kernel modules ..."; \
88            for kmod in $(find %{buildroot}/lib/modules/%{kverrel}/extra/ -name \*.ko); do \
89                    %{ksrc}/scripts/sign-file sha256 ${sign_pem} ${sign_x509} ${kmod}; \
90            done \
91        fi \
92%{nil}
93
94# hack to ensure signing happens after find-debuginfo.sh runs
95%define __spec_install_post \
96        %{?__debug_package:%{__debug_install_post}}\
97        %{__arch_install_post}\
98        %{__os_install_post}\
99        %{__modsign_install_post}
100
101%install
102make install \
103        DESTDIR=${RPM_BUILD_ROOT} \
104        INSTALL_MOD_DIR=extra/%{kmod_name}
105%{__rm} -f %{buildroot}/lib/modules/%{kverrel}/modules.*
106
107# find-debuginfo.sh only considers executables
108%{__chmod} u+x  %{buildroot}/lib/modules/%{kverrel}/extra/*/*
109
110%clean
111rm -rf $RPM_BUILD_ROOT
112
113%files -n kmod-%{kmod_name}-devel
114%{_usrsrc}/%{kmod_name}-%{version}
115