From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4A9B6159C9B for ; Tue, 6 Aug 2024 19:06:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 94B1C2BC09B; Tue, 6 Aug 2024 19:06:44 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 23B252BC098 for ; Tue, 6 Aug 2024 19:06:44 +0000 (UTC) From: Andrew Ammerlaan To: gentoo-dev@lists.gentoo.org Cc: Andrew Ammerlaan 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 Message-ID: <20240806190616.25975-2-andrewammerlaan@gentoo.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806190616.25975-1-andrewammerlaan@gentoo.org> References: <20240806190616.25975-1-andrewammerlaan@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: fc72fc2b-368e-4bba-8044-73d873154715 X-Archives-Hash: fcc39dd5c884996e34891bc17ed6ccf4 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 --- 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