commit:     caa98450d35c8884eaf502547db5b13932fb163a
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 31 18:46:28 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Oct 31 18:46:28 2017 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=caa98450

gen_configkernel: validate depmod/MODULE_COMPRESS

If there is a mismatch between compression support in depmod and the
kernel module settings, a bad initramfs would have been generated prior
to this commit. Validate and die early instead of building that bad
initramfs, so you don't get boot failures.

Impacts before:
- modules.dep and related files can be empty.
- module dependency verification for initramfs assembly can miss
  dependent modules.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

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

diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 476a883..26e4610 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -125,6 +125,21 @@ config_kernel() {
        if isTrue "$cfg_CONFIG_MODULES" ; then
                # yes, we support modules, set 'm' for new stuff.
                newcfg_setting='m'
+               # Compare the kernel module compression vs the depmod module 
compression support
+               # WARNING: if the buildhost has +XZ but the target machine has 
-XZ, you will get failures!
+               cfg_CONFIG_MODULE_COMPRESS_GZIP=$(kconfig_get_opt 
"${KERNEL_OUTPUTDIR}/.config" "CONFIG_MODULE_COMPRESS_GZIP")
+               cfg_CONFIG_MODULE_COMPRESS_XZ=$(kconfig_get_opt 
"${KERNEL_OUTPUTDIR}/.config" "CONFIG_MODULE_COMPRESS_XZ")
+               if isTrue "${cfg_CONFIG_MODULE_COMPRESS_GZIP}"; then
+                       depmod_GZIP=$(/sbin/depmod -V | tr ' ' '\n' | awk 
'/ZLIB/{print $1; exit}')
+                       if [[ "${depmod_GZIP}" != "+ZLIB" ]]; then
+                               gen_die 'depmod does not support ZLIB/GZIP, 
cannot build with CONFIG_MODULE_COMPRESS_GZIP'
+                       fi
+               elif isTrue "${cfg_CONFIG_MODULE_COMPRESS_XZ}" ; then
+                       depmod_XZ=$(/sbin/depmod -V | tr ' ' '\n' | awk 
'/XZ/{print $1; exit}')
+                       if [[ "${depmod_XZ}" != "+XZ" ]]; then
+                               gen_die 'depmod does not support XZ, cannot 
build with CONFIG_MODULE_COMPRESS_XZ'
+                       fi
+               fi
        else
                # no, we support modules, set 'y' for new stuff.
                newcfg_setting='y'

Reply via email to