From 9bc18b25d1a5a5c08b01c40fbf0624f3107d04d3 Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 2 Mar 2026 07:25:44 +0000 Subject: [PATCH] eclass/dist-kernel-utils: Sync with Gentoo It's from Gentoo commit 5d417624a82991d4786b59dff1213e10ee641a12. Signed-off-by: Flatcar Buildbot --- .../eclass/dist-kernel-utils.eclass | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/dist-kernel-utils.eclass b/sdk_container/src/third_party/portage-stable/eclass/dist-kernel-utils.eclass index 975efd2d63..1ebf17092b 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/dist-kernel-utils.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/dist-kernel-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 2020-2025 Gentoo Authors +# Copyright 2020-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: dist-kernel-utils.eclass @@ -215,6 +215,43 @@ dist-kernel_PV_to_KV() { echo "${kv}" } +# @FUNCTION: dist-kernel_get_compressor +# @USAGE: +# @DESCRIPTION: +# Returns the compressor with arguments for compressing kernel modules +# based on the CONFIG_MODULES_COMPESS_* setting in the kernel config. +dist-kernel_get_compressor() { + debug-print-function ${FUNCNAME} "$@" + + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments" + + local suffix=$(dist-kernel_get_module_suffix "${1}") + 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 + + echo "${compress[@]}" +} + # @FUNCTION: dist-kernel_get_module_suffix # @USAGE: # @DESCRIPTION: