%global buildforkernels current %global debug_package %{nil} %global __os_install_post %{nil} Name: focal-spi-kmod Summary: Kernel module (kmod) for FocalTech SPI FPR Version: 0.1 Release: 4%{?dist} License: GPLv2 URL: https://github.com/ftfpteams/ubuntu_spi Source0: focal_spi_cs_high.zip Source1: Makefile Patch0: focal_spi_cs_high.patch # get the needed BuildRequires (in parts depending on what we build for) BuildRequires: %{_bindir}/kmodtool %{!?kernels:BuildRequires: buildsys-build-msvsphere-kerneldevpkgs-%{?buildforkernels:%{buildforkernels}}%{!?buildforkernels:current}-%{_target_cpu} } %{?fedora:BuildRequires: unifdef} BuildRequires: gcc BuildRequires: make BuildRequires: elfutils-libelf-devel # kmodtool does its magic here %{expand:%(kmodtool --target %{_target_cpu} --repo msvsphere --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) } %description Driver module for FocalTech FPR on SPI bus %prep # error out if there was something wrong with kmodtool %{?kmodtool_check} # print kmodtool output for debugging purposes: kmodtool --target %{_target_cpu} --repo msvsphere --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null %setup -q -c mkdir focal-spi ls -l cp focal_spi.c focal-spi pushd focal-spi cp %{SOURCE1} . %patch0 -p0 -b .fix-segfault popd #Copied from kernel sources pwd ls for kernel_version in %{?kernel_versions} ; do cp -a focal-spi _kmod_build_${kernel_version%%___*} done %build for kernel_version in %{?kernel_versions} ; do %make_build -C ${kernel_version##*___} \ M=${PWD}/_kmod_build_${kernel_version%%___*} \ modules done %install for kernel_version in %{?kernel_versions}; do mkdir -p ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/ install -D -m 755 -t ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/ $(find _kmod_build_${kernel_version%%___*}/ -name '*.ko') done # Fix for the SB-signing issue caused by a bug in /usr/lib/rpm/brp-strip # https://bugzilla.redhat.com/show_bug.cgi?id=1967291 find %{buildroot} -name \*.ko -type f | xargs --no-run-if-empty %{__strip} --strip-debug # Sign the modules(s) %if %{?_with_modsign:1}%{!?_with_modsign:0} for kernel_version in %{?kernel_versions}; do # If the module signing keys are not defined, define them here. %{!?privkey: %define privkey %{_sysconfdir}/pki/kmod/msvsphere_kmod.priv} %{!?pubkey: %define pubkey %{_sysconfdir}/pki/kmod/msvsphere_kmod.pem} for module in $(find %{buildroot} -type f -name \*.ko); do %{_usrsrc}/kernels/${kernel_version%%___*}/scripts/sign-file \ sha256 %{privkey} %{pubkey} $module; done done %endif %{?akmod_install} %changelog * Thu Nov 21 2024 Eduard Basov - 0.1-4 - Build for MSVSphere 9