commit:     008d2cf12926c2fe91139c4fed802c053676d74c
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 27 12:08:07 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Wed Nov 27 16:18:56 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=008d2cf1

initrd.scripts: modules_load(): Log what we do

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

 defaults/initrd.scripts | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 597fb09..59e39fc 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -29,30 +29,49 @@ modules_load() {
 modules_scan() {
        local MODS
        local loaded
+       local x
        local smart_loading=yes
        local _root_dev
        local root_dev_found="Root block device found, skipping loading of 
module group \"${1}\" ..."
 
+       MODS=$(cat /etc/modules/${1} 2>/dev/null)
+       if [ -z "${MODS}" ]
+       then
+               log_msg "/etc/modules/${1} is empty; Nothing to load for '${1}' 
..."
+               return
+       fi
+
+       if [ -z "${MODULES_SCAN_WARNING_SHOWN}" ]
+       then
+               local note_msg="NOTE: Due to how genkernel auto-detects your"
+               note_msg="${note_msg} hardware you will now see a lot of failed 
modprobe" \
+               note_msg="${note_msg} attempts which you can ignore:"
+
+               log_msg "${note_msg}"
+
+               MODULES_SCAN_WARNING_SHOWN=yes
+       fi
+
        if [ "${GK_HW_LOAD_ALL_MODULES}" = '1' ]
        then
-               smart_loading=
+               smart_loading=no
        elif [ "${1}" = "virtio" ] || [ "${1}" = "hyperv" ]
        then
                # Virtio/HyperV modules group is special -- it's about
                # hypervisor support in general, not root block device
-               smart_loading=
+               smart_loading=no
        elif [ "${1}" = "net" ]
        then
                # We already load network modules only when we need
                # network so don't stop loading network modules when
                # $REAL_ROOT is already present or we will probably
                # end up without network we wanted ...
-               smart_loading=
+               smart_loading=no
        elif [ "${1}" = "fs" ]
        then
                # We don't know if kernel supports root filesystem so
                # better load all filesystems ...
-               smart_loading=
+               smart_loading=no
        elif [ "${USE_MDADM}" = '1' ] \
                || [ "${USE_LVM_NORMAL}" = '1' ] \
                || [ "${USE_CRYPTSETUP}" = '1' ] \
@@ -63,24 +82,13 @@ modules_scan() {
                # All of this will require the call of another program before
                # root becomes available so checking for root after each module
                # was loaded will only waste time.
-               smart_loading=
+               smart_loading=no
        fi
 
-       MODS=$(cat /etc/modules/${1} 2>/dev/null)
-       [ -n "${MODS}" ] && [ -z "${QUIET}" ] && \
+       log_msg "Loading modules of module group '${1}' (smart loading: 
${smart_loading}) ..."
+       [ -z "${QUIET}" ] && \
                printf "%b" "${BOLD}   ::${NORMAL} Loading from ${1}: "
 
-       if [ -z "${MODULES_SCAN_WARNING_SHOWN}" ]
-       then
-               local note_msg="NOTE: Due to how genkernel auto-detects your"
-               note_msg="${note_msg} hardware you will now see a lot of failed 
modprobe" \
-               note_msg="${note_msg} attempts which you can ignore:"
-
-               log_msg "${note_msg}"
-
-               MODULES_SCAN_WARNING_SHOWN=yes
-       fi
-
        for x in ${MODS}
        do
                MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/")
@@ -90,7 +98,7 @@ modules_scan() {
                                printf "%b\n" "${BOLD}   ::${NORMAL} Skipping 
${x} ..."
                elif [ "${MLOAD}" = "${MLIST}" ]
                then
-                       if [ -n "${smart_loading}" ]
+                       if [ "${smart_loading}" = "yes" ]
                        then
                                _root_dev=$(findfs "${REAL_ROOT}" 2>/dev/null)
 
@@ -124,7 +132,7 @@ modules_scan() {
                                printf "%b\n" "${BOLD}   ::${NORMAL} Skipping 
${x} ..."
                fi
        done
-       [ -n "${MODS}" ] && [ -z "${QUIET}" ] && echo
+       [ -z "${QUIET}" ] && echo
 }
 
 uppercase() {

Reply via email to