M. Vefa Bicakci 98156ab911 kernel-modules: Fix 'build-pkgs --edit'
Since commit f438b8b5f6fb ("Support out of tree modules in kernel
5.10.", 2021-06-30), the use of 'build-pkgs --edit' has resulted in the
following errors:

  ===
  raw_create_tarballs_extract_script ...
  EXTRACT_TO_DIR=.../std/srpm_work/i40e-kmod/gits/i40e-kmod.spec
  ++ umask 022
  ++ cd .../std/srpm_work/i40e-kmod/gits/i40e-kmod.spec
  ++ source scl_source enable devtoolset-8
  +++ _scl_source_help='Usage: source scl_source <action> [<collection> ...]

  Don'\''t use this script outside of SCL scriptlets!

  Options:
      -h, --help    display this help and exit'
  +++ '[' 2 -eq 0 -o enable = -h -o enable = --help ']'
  +++ '[' -z '' ']'
  +++ _recursion=false
  +++ '[' -z '' ']'
  +++ _scl_scriptlet_name=enable
  +++ shift 1
  +++ '[' -z '' ']'
  +++ _scl_dir=/etc/scl/conf
  +++ '[' '!' -e /etc/scl/conf ']'
  +++ for arg in '"$@"'
  +++ _scl_prefix_file=/etc/scl/conf/devtoolset-8
  ++++ cat /etc/scl/conf/devtoolset-8
  +++ _scl_prefix=
  ERROR: Failed in script '.../std/srpm_work/i40e-kmod/extract_script'
  ERROR: tar_and_spec_extract_to_git (2361): tarball_extract failed ...
  ===

This is caused by the use of 'source scl_source enable ...' in the
%prep sections of the out-of-tree kernel modules' spec files. In
summary, the build procedure is executed with a shell that has 'xtrace'
(i.e., 'set -x') enabled, and the 'source' statement to pull in the
software collections for updated toolchains causes debugging lines to be
printed out. These lines are in turn attempted to be parsed by the
cgcs-root/build-tools/srpm-utils shell script to generate a source code
extraction script for the '--edit' mode. However, the unexpected shell
debugging output confuses srpm-utils, which causes 'build-pkgs --edit'
to fail.

All of this can be avoided by removing the 'source scl_source enable'
lines from the %prep sections, which are only expected to unpack the
source code, and hence are not involved in compilation, and hence do not
need to be aware of updated toolchains. This commit takes this approach
instead of attempting to modify the srpm-utils shell script, given the
author's lack of familiarity with the script in question.

This commit also removes unnecessary use of the 'llvm-toolset-7.0'
software collection from the kernel modules for two reasons:
- The modified kernel modules do not use the LLVM/clang toolchain.
- The attempt to use the llvm-toolset-7.0 toolchain was likely broken
  from day 1, because the kernel modules do not actually depend on the
  llvm-toolset-7.0 toolchain via a 'Requires:' line in their spec files.
  No errors were encountered because of the ' || :' at the end of the
  line, which causes errors to be ignored.

Testing:
- An ISO image was successfully built using a monolithic build
  procedure.

Change-Id: Ie0772efa0f98963186f36d993b02d28ac0e4575d
Fixes: f438b8b5f6fb ("Support out of tree modules in kernel 5.10.")
Closes-Bug: 1958411
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
2022-01-19 19:27:22 -05:00

149 lines
4.9 KiB
RPMSpec

%if "%{?_tis_build_type}" == "rt"
%define bt_ext -rt
%else
%undefine bt_ext
%endif
Summary: Intel(r) QuickAssist Technology API
%define pkgname qat17
Name: %{pkgname}%{?bt_ext}
Version: 4.14.0
%define upstream_release 00031
Release: %{upstream_release}%{?_tis_dist}.%{tis_patch_ver}
License: GPLv2
Group: base
Packager: Wind River <info@windriver.com>
URL: https://01.org/packet-processing/intel%C2%AE-quickassist-technology-drivers-and-patches
BuildRequires: kernel%{?bt_ext}-devel
BuildRequires: zlib-devel
BuildRequires: openssl-devel
BuildRequires: pciutils
BuildRequires: libudev-devel
BuildRequires: boost-devel
BuildRequires: perl
BuildRequires: openssl
BuildRequires: elfutils-libelf-devel
BuildRequires: yasm
%if 0%{?rhel} == 7
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-make
%endif
%define icp_tools accelcomp
%define kernel_version %(rpm -q kernel%{?bt_ext}-devel | sed 's/kernel%{?bt_ext}-devel-//')
%define staging_kernel_dir /usr/src/kernels/%{kernel_version}/
%define qat_unpack_dir %{_builddir}/%{name}-%{version}
%define qat_src_dir %{qat_unpack_dir}
Source: QAT1.7.L.%{version}-%{upstream_release}.tar.gz
Source1: qat
# Use our own service script rather than massively patching theirs
Source2: qat_service
Patch1: crypto-qat-Silence-smp_processor_id-warning.patch
Patch2: qat17-build-Do-not-override-KERNELVERSION-with-build-machi.patch
%description
Intel(r) QuickAssist Technology API
%prep
rm -rf %{qat_unpack_dir}
mkdir -p %{qat_unpack_dir}
cd %{qat_unpack_dir}
gzip -dc %{_sourcedir}/QAT1.7.L.%{version}-%{upstream_release}.tar.gz | tar -xvvf -
if [ $? -ne 0 ]; then
exit $?
fi
%patch1 -p1
%patch2 -p1
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
ICP_ROOT=%{qat_src_dir}
KERNEL_SOURCE_ROOT=%{staging_kernel_dir}
mkdir -p %{qat_src_dir}/build
ICP_BUILD_OUTPUT=%{qat_src_dir}/build
export ICP_ROOT KERNEL_SOURCE_ROOT ICP_BUILD_OUTPUT
cd %{qat_src_dir}
%configure --enable-icp-sriov=host
make -C %{qat_src_dir}/
# intel test sample
make -C %{qat_src_dir}/ sample-all
%install
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
%{__install} -d %{buildroot}%{_sysconfdir}/default
%{__install} -m 750 %SOURCE1 %{buildroot}%{_sysconfdir}/default
%{__install} -d %{buildroot}%{_sysconfdir}/modprobe.d
%{__install} -d %{buildroot}%{_sysconfdir}/qat/conf_files
%{__install} -m 640 %{qat_src_dir}/build/*.conf %{buildroot}%{_sysconfdir}/qat/conf_files
%{__install} -m 640 %{qat_src_dir}/build/*.vm %{buildroot}%{_sysconfdir}/qat/conf_files
%{__install} -d %{buildroot}%{_sbindir}
%{__install} -m 750 %{qat_src_dir}/build/adf_ctl %{buildroot}%{_sbindir}
%{__install} -d %{buildroot}%{_sysconfdir}/init.d
%{__install} -m 750 %SOURCE2 %{buildroot}%{_sysconfdir}/init.d/qat_service
%{__install} -d %{buildroot}%{_libdir}
%{__install} -m 750 %{qat_src_dir}/build/*.so %{buildroot}%{_libdir}
%{__install} -d %{buildroot}/lib/modules/%{kernel_version}/kernel/drivers/crypto/qat/
%{__install} -m 750 %{qat_src_dir}/build/*qat*.ko %{buildroot}/lib/modules/%{kernel_version}/kernel/drivers/crypto/qat/
%{__install} -m 750 %{qat_src_dir}/build/usdm_drv.ko %{buildroot}/lib/modules/%{kernel_version}/kernel/drivers/crypto/qat
# intel test sample
%{__install} -d %{buildroot}/usr/lib/firmware
%{__install} -m 750 %{qat_src_dir}/build/cpa_sample_code %{buildroot}%{_sbindir}/cpa_sample_code
%{__install} -m 640 %{qat_src_dir}/quickassist/lookaside/access_layer/src/sample_code/performance/compression/calgary %{buildroot}/usr/lib/firmware
%{__install} -m 640 %{qat_src_dir}/quickassist/lookaside/access_layer/src/sample_code/performance/compression/calgary32 %{buildroot}/usr/lib/firmware
%{__install} -m 640 %{qat_src_dir}/quickassist/lookaside/access_layer/src/sample_code/performance/compression/canterbury %{buildroot}/usr/lib/firmware
# device firmware
# install to the updates directory so this firmware will get grabbed ahead of
# anything supplied by the linux-firmware package
%{__install} -d %{buildroot}/usr/lib/firmware/updates
%{__install} -m 640 %{qat_src_dir}/build/*.bin %{buildroot}/usr/lib/firmware/updates
# Strip the modules(s).
find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kernel_version}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kernel_version}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do /usr/src/kernels/%{kernel_version}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%clean
%{__rm} -rf %{buildroot}
%files
"%{_sbindir}/*"
"%{_sysconfdir}/default/qat"
"%{_sysconfdir}/init.d/qat_service"
"/lib/modules/%{kernel_version}/kernel/drivers/crypto/qat/*.ko"
"%{_libdir}/*.so"
"/usr/lib/firmware/*"
"/usr/lib/firmware/updates/*"
"%{_sysconfdir}/qat/*"
"%{_sysconfdir}/qat/conf_files/*"