commit:     59e3804695ddfd8749aeb717421818122f1185cc
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 28 08:58:57 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Dec 30 16:19:09 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59e38046

linux-mod-r1.eclass: Add USE=modules-compress

Add a `modules-compress` USE flag to explicitly control kernel module
compression.  When the flag is disabled, modules are installed
uncompressed even if the kernel supports compression (which is going
to be the case for new sys-kernel/gentoo-kernel* builds).  When it is
enabled, the eclass compresses modules using the compressor configured,
or fails if no compression is supported.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/linux-mod-r1.eclass | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
index 44fc927c3a70..54df2406e5c7 100644
--- a/eclass/linux-mod-r1.eclass
+++ b/eclass/linux-mod-r1.eclass
@@ -111,7 +111,7 @@ _LINUX_MOD_R1_ECLASS=1
 
 inherit edo linux-info multiprocessing toolchain-funcs
 
-IUSE="dist-kernel modules-sign +strip ${MODULES_OPTIONAL_IUSE}"
+IUSE="dist-kernel modules-compress modules-sign +strip 
${MODULES_OPTIONAL_IUSE}"
 
 RDEPEND="
        sys-apps/kmod[tools]
@@ -835,6 +835,8 @@ _modules_prepare_toolchain() {
 # If enabled in the kernel configuration, this compresses the given
 # modules using the same format.
 _modules_process_compress() {
+       use modules-compress || return
+
        local -a compress
        if linux_chkconfig_present MODULE_COMPRESS_XZ; then
                compress=(
@@ -853,13 +855,13 @@ _modules_process_compress() {
                fi
        elif linux_chkconfig_present MODULE_COMPRESS_ZSTD; then
                compress=(zstd -qT"$(makeopts_jobs)" --rm)
+       else
+               die "USE=modules-compress enabled but no MODULE_COMPRESS* 
configured"
        fi
 
-       if [[ -v compress ]]; then
-               # could fail, assumes have commands that were needed for the 
kernel
-               einfo "Compressing modules (matching the kernel configuration) 
..."
-               edob "${compress[@]}" -- "${@}"
-       fi
+       # could fail, assumes have commands that were needed for the kernel
+       einfo "Compressing modules (matching the kernel configuration) ..."
+       edob "${compress[@]}" -- "${@}"
 }
 
 # @FUNCTION: _modules_process_depmod.d

Reply via email to