commit:     6b2ad24605d0bd6320cdd006e9ca78fdcbaa7a27
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  1 18:11:48 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sat Aug  1 20:35:00 2020 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=6b2ad246

gen_configkernel.sh: set_initramfs_compression_method(): Ensure that set 
compression method is supported by the kernel

When we didn't build kernel we have to be sure that kernel can actually
decompress chosen initramfs compression type.

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 gen_configkernel.sh | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 666f525..b30d079 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -119,7 +119,7 @@ set_initramfs_compression_method() {
 
        if [[ "${COMPRESS_INITRD_TYPE}" =~ ^(BEST|FASTEST)$ ]]
        then
-               print_info 5 "Determining '${COMPRESS_INITRD_TYPE}' compression 
method for initramfs ..."
+               print_info 5 "Determining '${COMPRESS_INITRD_TYPE}' compression 
method for initramfs using kernel config '${kernel_config}' ..."
                local ranked_methods
                if [[ "${COMPRESS_INITRD_TYPE}" == "BEST" ]]
                then
@@ -162,6 +162,20 @@ set_initramfs_compression_method() {
                fi
        fi
 
+       if ! isTrue "${BUILD_KERNEL}"
+       then
+               local cfg_DECOMPRESS_SUPPORT=$(kconfig_get_opt 
"${kernel_config}" "CONFIG_RD_${COMPRESS_INITRD_TYPE}")
+               if [[ "${cfg_DECOMPRESS_SUPPORT}" != "y" ]]
+               then
+                       gen_die "The kernel config '${kernel_config}' this 
initramfs will be build for cannot decompress set --compress-initrd-type 
'${COMPRESS_INITRD_TYPE}'!"
+               fi
+
+               # If we are not building kernel, there is no point in
+               # changing kernel config file at all so exit function
+               # here.
+               return
+       fi
+
        local KOPTION_PREFIX=CONFIG_RD_
        [ ${KV_NUMERIC} -ge 4010 ] && 
KOPTION_PREFIX=CONFIG_INITRAMFS_COMPRESSION_
 

Reply via email to