File nfit_test.spec of Package nfit_test

#
# spec file for package nfit_test-kmp
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

# needssslcertforbuild

Name:           nfit_test
Version:        0
Release:        0
Summary:        NVDIMM test module
License:        GPL-2.0-only
Source1:        x86-libnvdimm-test-Remove-COPY_MC_TEST.patch
Source2:        tools-testing-nvdimm-Make-symbol-__nfit_test_ioremap.patch
Source3:        testing-nvdimm-asm-mce.h-is-only-available-on-x86.patch
Source4:        testing-nvdimm-iomap-make-__nfit_test_ioremap-a-macr.patch
BuildRequires:  %kernel_module_package_buildreqs
BuildRequires:  pesign-obs-integration
# on 4.12 the module should be technically buildable but there are different errors on each SLE version
BuildRequires:  kernel-source > 5
BuildRequires:  bc bison flex openssl-devel python3
BuildRequires:  lndir
%if 0%{?sle_version} && 0%{?sle_version} < 150400
# on 5.3 and earlier the pmem modules are not buildable for ppc and arm does not have pmem features that these modules require
ExclusiveArch:  x86_64
%else
ExclusiveArch:  aarch64 ppc64 ppc64le x86_64
%endif

%kernel_module_package -c %_sourcedir/_projectcert.crt

%description
NVDIMM test module

%prep

%build
for flavor in %flavors_to_build; do
        rc=0
        rm -rf linux-obj/%_target_cpu/$flavor/
        mkdir -p linux-obj/%_target_cpu/$flavor/
        lndir -silent /usr/src/linux linux-obj/%_target_cpu/$flavor/
        pushd linux-obj/%_target_cpu/$flavor/
        %if 0%{?sle_version} > 150200
        %if 0%{?sle_version} == 150300
        cat %{SOURCE1} | patch -p1 --follow-symlinks
        cat %{SOURCE2} | patch -p1 --follow-symlinks
        cat %{SOURCE3} | patch -p1 --follow-symlinks
        cat %{SOURCE4} | patch -p1 --follow-symlinks --fuzz=3
        %endif
        %endif
        popd
        cp -a %_sourcedir/_projectcert.crt linux-obj/%_target_cpu/$flavor/.kernel_signing_key.pem
        cp -a /usr/src/linux-obj/%_target_cpu/$flavor/.config linux-obj/%_target_cpu/$flavor/
        make -C linux-obj/%_target_cpu/$flavor/ oldconfig prepare lib/crc7.ko ||:
        make -C linux-obj/%_target_cpu/$flavor/ modules M=$PWD/linux-obj/%_target_cpu/$flavor/tools/testing/nvdimm CFLAGS_MODULE=-save-temps=obj || rc=$?
        # cat $PWD/linux-obj/%_target_cpu/$flavor/tools/testing/nvdimm/test/iomap.i
        [ $rc = 0 ] || exit $rc
        ( cd $PWD/linux-obj/%_target_cpu/$flavor/tools/testing/nvdimm ; ls *.ko test/*.ko > Module.supported ; rm *.mod.o test/*.mod.o )
        make -C linux-obj/%_target_cpu/$flavor/ modules M=$PWD/linux-obj/%_target_cpu/$flavor/tools/testing/nvdimm CFLAGS_MODULE=-save-temps=obj
done



%install
export BRP_PESIGN_FILES='*.ko'
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
# ndctl tests require that the modules are in 'extra' directory
export INSTALL_MOD_DIR=extra
for flavor in %flavors_to_build; do
        make -C linux-obj/%_target_cpu/$flavor/ modules_install M=$PWD/linux-obj/%_target_cpu/$flavor/tools/testing/nvdimm
done

%changelog
openSUSE Build Service is sponsored by