From: Brian Masney <bmasney(a)redhat.com>
redhat/kernel.spec.template: update compression variables to support zstd
Upstream Status: RHEL Only
The kernel.spec.template file has a compression variable to define which
binary is used to compress the kernel modules. The binary is currently
invoked in the following manner: '%compression -c9'. There is a desire
to use zstd for automotive since it results in faster decompression,
and faster boot times. To support zstd, different flags need to be
passed to the compression binary, so let's introduce a compression_flags
variable.
The BuildRequires needs to be updated to include the compression
binary as well since these variables can be overridden on the command
line with "rpmbuild --define 'compression zstd' ...".
The zstd support was tested with the following configuration:
%global compression zstd
%global compression_flags --rm
%global compext zst
Note that the --stdout flag that's passed to the compression binary
works with bz2, gz, xz, and zstd.
Signed-off-by: Brian Masney <bmasney(a)redhat.com>
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index blahblah..blahblah 100644
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -120,6 +120,7 @@ Summary: The Linux kernel
# Default compression algorithm
%global compression xz
+%global compression_flags
%global compext xz
%if %{zipmodules}
%global zipsed -e 's/\.ko$/\.ko.%compext/'
@@ -659,7 +660,7 @@ Provides: installonlypkg(kernel)
# List the packages used during the kernel build
#
BuildRequires: kmod, bash, coreutils, tar, git-core, which
-BuildRequires: bzip2, xz, findutils, m4, perl-interpreter, perl-Carp, perl-devel,
perl-generators, make, diffutils, gawk
+BuildRequires: bzip2, xz, findutils, m4, perl-interpreter, perl-Carp, perl-devel,
perl-generators, make, diffutils, gawk, %compression
BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, bison, flex, gcc-c++
BuildRequires: net-tools, hostname, bc, elfutils-devel
BuildRequires: dwarves
@@ -2115,7 +2116,7 @@ BuildKernel() {
# NOTENOTE: checksums to the rpm metadata provides list.
# NOTENOTE: if you change the symvers name, update the backend too
echo "**** GENERATING kernel ABI metadata ****"
- %compression -c9 < Module.symvers >
$RPM_BUILD_ROOT/boot/symvers-$KernelVer.%compext
+ %compression --stdout %compression_flags < Module.symvers >
$RPM_BUILD_ROOT/boot/symvers-$KernelVer.%compext
cp $RPM_BUILD_ROOT/boot/symvers-$KernelVer.%compext
$RPM_BUILD_ROOT/lib/modules/$KernelVer/symvers.%compext
%if %{with_kabichk}
@@ -2824,7 +2825,7 @@ find Documentation -type d | xargs chmod u+w
fi \
if [ "%{zipmodules}" -eq "1" ]; then \
echo "Compressing kernel modules ..." \
- find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs -n 16
-P${RPM_BUILD_NCPUS} -r %compression; \
+ find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs -n 16
-P${RPM_BUILD_NCPUS} -r %compression %compression_flags; \
fi \
%{nil}
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2650