From: Prarit Bhargava on gitlab.com Merge Request: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173
Most of the kernel and its packing is currently xz. There are two exceptions: the aarch64 boot an initrd images [1] and KABI. Mark gzip as only being necessary for aarch64, and change the KABI symbol compression to xz.
There are other compression algorithms that are becoming more popular. To prepare for this change, add a compression variable and compression file extension variable.
Signed-off-by: Prarit Bhargava prarit@redhat.com
[1] There is upstream work on implementing xz and other compression algorithms for aarch64. This work should be completed in the next few upstream kernel and bootloader releases.
--- redhat/kernel.spec.template | 40 +++++++++++++++++++++------------------- 1 files changed, 21 insertions(+), 19 deletions(-)
From: Prarit Bhargava prarit@redhat.com
kernel.spec.template: Only use gzip with aarch64
gzip is only needed for aarch64.
Signed-off-by: Prarit Bhargava prarit@redhat.com
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100755 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -575,7 +575,7 @@ Requires: kernel-modules-uname-r = %{KVERREL} # List the packages used during the kernel build # BuildRequires: kmod, bash, coreutils, tar, git-core, which -BuildRequires: bzip2, xz, findutils, gzip, 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 BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, bison, flex, gcc-c++ BuildRequires: net-tools, hostname, bc, elfutils-devel BuildRequires: dwarves @@ -609,6 +609,7 @@ BuildRequires: numactl-devel %endif %ifarch aarch64 BuildRequires: opencsd-devel >= 1.0.0 +BuildRequires: gzip %endif %endif %if %{with_tools} @@ -1711,14 +1712,11 @@ BuildKernel() { CopyKernel=cp fi
- # Sign the image if we're using EFI - # aarch64 kernels are gziped EFI images - KernelExtension=${KernelImage##*.} - if [ "$KernelExtension" == "gz" ]; then + SignImage=$KernelImage + %ifarch aarch64 + # aarch64 kernels are gziped EFI images SignImage=${KernelImage%.*} - else - SignImage=$KernelImage - fi + %endif
%ifarch x86_64 aarch64 %pesign -s -i $SignImage -o vmlinuz.tmp -a %{secureboot_ca_0} -c %{secureboot_key_0} -n %{pesign_name_0} @@ -1741,9 +1739,9 @@ BuildKernel() { exit 1 fi mv vmlinuz.signed $SignImage - if [ "$KernelExtension" == "gz" ]; then + %ifarch aarch64 gzip -f9 $SignImage - fi + %endif # signkernel %endif
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173
From: Prarit Bhargava prarit@redhat.com
kernel.spec.template: Use xz for KABI
Use xz for KABI instead of gzip.
Signed-off-by: Prarit Bhargava prarit@redhat.com
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100755 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -475,6 +475,7 @@ Summary: The Linux kernel %define all_arch_configs kernel-%{version}-aarch64*.config %define asmarch arm64 %define hdrarch arm64 +# only aarch64 uses gzip compression for boot images %define make_target Image.gz %define kernel_image arch/arm64/boot/Image.gz %endif @@ -1818,8 +1819,8 @@ 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 ****" - gzip -c9 < Module.symvers > $RPM_BUILD_ROOT/boot/symvers-$KernelVer.gz - cp $RPM_BUILD_ROOT/boot/symvers-$KernelVer.gz $RPM_BUILD_ROOT/lib/modules/$KernelVer/symvers.gz + xz -c9 < Module.symvers > $RPM_BUILD_ROOT/boot/symvers-$KernelVer.xz + cp $RPM_BUILD_ROOT/boot/symvers-$KernelVer.xz $RPM_BUILD_ROOT/lib/modules/$KernelVer/symvers.xz
%if %{with_kabichk} echo "**** kABI checking is enabled in kernel SPEC file. ****" @@ -2859,9 +2860,9 @@ fi\ %endif\ rm -f %{_localstatedir}/lib/rpm-state/%{name}/installing_core_%{KVERREL}%{?1:+%{1}}\ /bin/kernel-install add %{KVERREL}%{?1:+%{1}} /lib/modules/%{KVERREL}%{?1:+%{1}}/vmlinuz || exit $?\ -if [[ ! -e "/boot/symvers-%{KVERREL}%{?1:+%{1}}.gz" ]]; then\ - ln -s "/lib/modules/%{KVERREL}%{?1:+%{1}}/symvers.gz" "/boot/symvers-%{KVERREL}%{?1:+%{1}}.gz"\ - command -v restorecon &>/dev/null && restorecon "/boot/symvers-%{KVERREL}%{?1:+%{1}}.gz" \ +if [[ ! -e "/boot/symvers-%{KVERREL}%{?1:+%{1}}.xz" ]]; then\ + ln -s "/lib/modules/%{KVERREL}%{?1:+%{1}}/symvers.xz" "/boot/symvers-%{KVERREL}%{?1:+%{1}}.xz"\ + command -v restorecon &>/dev/null && restorecon "/boot/symvers-%{KVERREL}%{?1:+%{1}}.xz" \ fi\ %{nil}
@@ -3118,9 +3119,9 @@ fi %endif\ %attr(0600, root, root) /lib/modules/%{KVERREL}%{?3:+%{3}}/System.map\ %ghost %attr(0600, root, root) /boot/System.map-%{KVERREL}%{?3:+%{3}}\ -/lib/modules/%{KVERREL}%{?3:+%{3}}/symvers.gz\ +/lib/modules/%{KVERREL}%{?3:+%{3}}/symvers.xz\ /lib/modules/%{KVERREL}%{?3:+%{3}}/config\ -%ghost %attr(0600, root, root) /boot/symvers-%{KVERREL}%{?3:+%{3}}.gz\ +%ghost %attr(0600, root, root) /boot/symvers-%{KVERREL}%{?3:+%{3}}.xz\ %ghost %attr(0600, root, root) /boot/initramfs-%{KVERREL}%{?3:+%{3}}.img\ %ghost %attr(0644, root, root) /boot/config-%{KVERREL}%{?3:+%{3}}\ %dir /lib/modules\
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173
From: Prarit Bhargava prarit@redhat.com
kernel.spec.template: Add global compression variables
Add global compression variables. 'compression' is the compression utility, and 'compext' is the compression extension. In the case of xz, these variables have the same value but that may not always be the case.
Signed-off-by: Prarit Bhargava prarit@redhat.com
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100755 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -88,8 +88,11 @@ Summary: The Linux kernel %global zipmodules 1 %endif
+# Default compression algorithm +%global compression xz +%global compext xz %if %{zipmodules} -%global zipsed -e 's/.ko$/.ko.xz/' +%global zipsed -e 's/.ko$/.ko.%compext/' %endif
%if 0%{?fedora} @@ -1819,8 +1822,8 @@ 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 ****" - xz -c9 < Module.symvers > $RPM_BUILD_ROOT/boot/symvers-$KernelVer.xz - cp $RPM_BUILD_ROOT/boot/symvers-$KernelVer.xz $RPM_BUILD_ROOT/lib/modules/$KernelVer/symvers.xz + %compression -c9 < 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} echo "**** kABI checking is enabled in kernel SPEC file. ****" @@ -2438,7 +2441,7 @@ find Documentation -type d | xargs chmod u+w fi \ fi \ if [ "%{zipmodules}" -eq "1" ]; then \ - find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs -P${RPM_BUILD_NCPUS} -r xz; \ + find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs -P${RPM_BUILD_NCPUS} -r %compression; \ fi \ %{nil}
@@ -2860,9 +2863,9 @@ fi\ %endif\ rm -f %{_localstatedir}/lib/rpm-state/%{name}/installing_core_%{KVERREL}%{?1:+%{1}}\ /bin/kernel-install add %{KVERREL}%{?1:+%{1}} /lib/modules/%{KVERREL}%{?1:+%{1}}/vmlinuz || exit $?\ -if [[ ! -e "/boot/symvers-%{KVERREL}%{?1:+%{1}}.xz" ]]; then\ - ln -s "/lib/modules/%{KVERREL}%{?1:+%{1}}/symvers.xz" "/boot/symvers-%{KVERREL}%{?1:+%{1}}.xz"\ - command -v restorecon &>/dev/null && restorecon "/boot/symvers-%{KVERREL}%{?1:+%{1}}.xz" \ +if [[ ! -e "/boot/symvers-%{KVERREL}%{?1:+%{1}}.%compext" ]]; then\ + ln -s "/lib/modules/%{KVERREL}%{?1:+%{1}}/symvers.%compext" "/boot/symvers-%{KVERREL}%{?1:+%{1}}.%compext"\ + command -v restorecon &>/dev/null && restorecon "/boot/symvers-%{KVERREL}%{?1:+%{1}}.%compext" \ fi\ %{nil}
@@ -3119,9 +3122,9 @@ fi %endif\ %attr(0600, root, root) /lib/modules/%{KVERREL}%{?3:+%{3}}/System.map\ %ghost %attr(0600, root, root) /boot/System.map-%{KVERREL}%{?3:+%{3}}\ -/lib/modules/%{KVERREL}%{?3:+%{3}}/symvers.xz\ +/lib/modules/%{KVERREL}%{?3:+%{3}}/symvers.%compext\ /lib/modules/%{KVERREL}%{?3:+%{3}}/config\ -%ghost %attr(0600, root, root) /boot/symvers-%{KVERREL}%{?3:+%{3}}.xz\ +%ghost %attr(0600, root, root) /boot/symvers-%{KVERREL}%{?3:+%{3}}.%compext\ %ghost %attr(0600, root, root) /boot/initramfs-%{KVERREL}%{?3:+%{3}}.img\ %ghost %attr(0644, root, root) /boot/config-%{KVERREL}%{?3:+%{3}}\ %dir /lib/modules\
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173
From: Herton R. Krzesinski on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173#note_1195644...
I'm not sure you can really change the symvers file compression away from gzip right now. At least looking quickly here, it seems grub2 on Fedora 36 has a script that references it:
``` $ grep -r symvers /usr/lib/kernel/install.d/* /usr/lib/kernel/install.d/20-grub.install: # symvers is symvers-<version>.gz symlink, needs a special treatment /usr/lib/kernel/install.d/20-grub.install: i="$KERNEL_DIR/symvers.gz" /usr/lib/kernel/install.d/20-grub.install: rm -f "/boot/symvers-${KERNEL_VERSION}.gz" /usr/lib/kernel/install.d/20-grub.install: ln -s "$i" "/boot/symvers-${KERNEL_VERSION}.gz" /usr/lib/kernel/install.d/20-grub.install: restorecon "/boot/symvers-${KERNEL_VERSION}.gz" /usr/lib/kernel/install.d/20-grub.install: # symvers is symvers-<version>.gz symlink, needs a special treatment /usr/lib/kernel/install.d/20-grub.install: rm -f "/boot/symvers-${KERNEL_VERSION}.gz" $ rpm -qf /usr/lib/kernel/install.d/20-grub.install grub2-common-2.06-54.fc36.noarch ```
From: Prarit Bhargava on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173#note_1195725...
Ah thanks. I've opened https://src.fedoraproject.org/rpms/grub2/pull- request/24 to add xz to this script.
From: Prarit Bhargava on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2173#note_1195725...
@hertonrk-rh , let's keep this blocked until that MR is merged. Then we can merge this change IMO.
kernel@lists.fedoraproject.org