public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Subject: [gentoo-dev] [PATCH 2/4] kernel-install.eclass: use dist-kernel_get_module_suffix to find compression
Date: Tue,  6 Aug 2024 21:06:14 +0200	[thread overview]
Message-ID: <20240806190616.25975-2-andrewammerlaan@gentoo.org> (raw)
In-Reply-To: <20240806190616.25975-1-andrewammerlaan@gentoo.org>

Adjusts kernel-install_compress_modules to use the new function
dist-kernel_get_module_suffix. This makes no functional difference
at the moment since gentoo-kernel-bin is the only consumer and it has
XZ compression in the config. Still this makes it possible to compile
alternate prebuilt kernels with alternate module compression support, and may
in the future help to support gzip and zstd module compression in
gentoo-kernel-bin.

Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
 eclass/kernel-install.eclass | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index 0a85bfb8629d..e5dd6db5b7ed 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -766,13 +766,35 @@ kernel-install_compress_modules() {
 
 	if use modules-compress; then
 		einfo "Compressing kernel modules ..."
-		# xz options taken from scripts/Makefile.modinst
-		# we don't do 'xz -T' because it applies multithreading per file,
-		# so it works only for big files, and we have lots of small files
-		# instead
-		find "${ED}/lib" -name '*.ko' -print0 |
-			xargs -0 -P "$(makeopts_jobs)" -n 128 \
-				xz --check=crc32 --lzma2=dict=1MiB
+		if [[ -z ${KV_FULL} ]]; then
+			KV_FULL=${PV}${KV_LOCALVERSION}
+		fi
+		local suffix=$(dist-kernel_get_module_suffix "${ED}/usr/src/linux-${KV_FULL}")
+		local compress=()
+		# Options taken from linux-mod-r1.eclass.
+		# We don't instruct the compressor to parallelize because it applies
+		# multithreading per file, so it works only for big files, and we have
+		# lots of small files instead.
+		case ${suffix} in
+			.ko)
+				return
+				;;
+			.ko.gz)
+				compress+=( gzip )
+				;;
+			.ko.xz)
+				compress+=( xz --check=crc32 --lzma2=dict=1MiB )
+				;;
+			.ko.zst)
+				compress+=( zstd -q --rm )
+				;;
+			*)
+				die "Unknown compressor: ${suffix}"
+				;;
+		esac
+
+		find "${ED}/lib/modules/${KV_FULL}" -name '*.ko' -print0 |
+			xargs -0 -P "$(makeopts_jobs)" -n 128 "${compress[@]}"
 		assert "Compressing kernel modules failed"
 	fi
 }
-- 
2.45.2



  reply	other threads:[~2024-08-06 19:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 19:06 [gentoo-dev] [PATCH 1/4] dist-kernel-utils.eclass: fix module cleanup when using binpkgs Andrew Ammerlaan
2024-08-06 19:06 ` Andrew Ammerlaan [this message]
2024-08-06 19:06 ` [gentoo-dev] [PATCH 3/4] eclass/tests/tests-common.sh: add in_iuse function Andrew Ammerlaan
2024-08-06 19:06 ` [gentoo-dev] [PATCH 4/4] eclass/tests/dist-kernel-utils.sh: add compressed_module_cleanup tests Andrew Ammerlaan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806190616.25975-2-andrewammerlaan@gentoo.org \
    --to=andrewammerlaan@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox