]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix: revise all module checks
authorHarald Hoyer <harald@redhat.com>
Tue, 9 Feb 2021 15:24:59 +0000 (16:24 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Wed, 10 Feb 2021 12:29:17 +0000 (13:29 +0100)
1. no module checks for modules which are in depends()
2. no `derror` for optional (255) modules checking for dependencies
3. fix dbus meta module

12 files changed:
modules.d/01systemd-coredump/module-setup.sh
modules.d/01systemd-initrd/module-setup.sh
modules.d/01systemd-repart/module-setup.sh
modules.d/01systemd-sysusers/module-setup.sh
modules.d/02systemd-networkd/module-setup.sh
modules.d/06dbus-broker/module-setup.sh
modules.d/06dbus-daemon/module-setup.sh
modules.d/06rngd/module-setup.sh
modules.d/09dbus/module-setup.sh [moved from modules.d/00dbus/module-setup.sh with 50% similarity]
modules.d/40network/module-setup.sh
modules.d/98dracut-systemd/module-setup.sh
modules.d/99squash/module-setup.sh

index db849fc0b928d60fb1f879a3293475c445f471e1..8b85e93cfdb0d8865102fccabcb5da6f732ddd7c 100755 (executable)
@@ -10,23 +10,6 @@ check() {
     require_binaries coredumpctl || return 1
     require_binaries $systemdutildir/systemd-coredump || return 1
 
-    # If the module dependency requirements are not fulfilled
-    # return 1 to not include the required module(s).
-    if ! dracut_module_included "systemd"; then
-        derror "systemd-coredump needs systemd in the initramfs."
-        return 1
-    fi
-
-    if ! dracut_module_included "systemd-journald"; then
-         derror "systemd-coredump needs systemd-journald in the initramfs."
-         return 1
-    fi
-
-    if ! dracut_module_included "systemd-sysctl"; then
-        derror "systemd-coredump needs systemd-sysctl in the initramfs."
-        return 1
-    fi
-
     # Return 255 to only include the module, if another module requires it.
     return 255
 
index 1e9f5691365c0d5874aceba53d3ac431d90f1448..3f86c5278090774f7317efa0597004ce43a96f2f 100755 (executable)
@@ -4,11 +4,6 @@
 check() {
     [[ $mount_needs ]] && return 1
 
-    if ! dracut_module_included "systemd"; then
-        derror "systemd-initrd needs systemd in the initramfs"
-        return 1
-    fi
-
     return 0
 }
 
index a08e89f8ae7cabfed4860f463dfebc4284079d53..6f370bd468b0baeda937fd9b634e384320b192b9 100755 (executable)
@@ -9,13 +9,6 @@ check() {
     # return 1 to not include the binary.
     require_binaries systemd-repart || return 1
 
-    # If the module dependency requirements are not fulfilled
-    # return 1 to not include the required module(s).
-    if ! dracut_module_included "systemd"; then
-        derror "systemd-repart needs systemd in the initramfs."
-        return 1
-    fi
-
     # Return 255 to only include the module, if another module requires it.
     return 255
 
index 3436c8fccb4395a0c67a05d30a7a8e8aa74a2f76..6fcc0262fb075da51be33c2dc31c793851afb4cd 100644 (file)
@@ -9,13 +9,6 @@ check() {
     # return 1 to not include the binary.
     require_binaries systemd-sysusers || return 1
 
-    # If the module dependency requirements are not fulfilled
-    # return 1 to not include the required module(s).
-    if ! dracut_module_included "systemd"; then
-        derror "systemd-sysuser needs systemd in the initramfs."
-        return 1
-    fi
-
     # Return 255 to only include the module, if another module requires it.
     return 255
 
index 03c3a7b56484281ea718d2aa6564b4bd96102ce0..b7603a9d89adba9b6f7ebdca97b935970457f176 100755 (executable)
@@ -4,11 +4,6 @@
 check() {
     [[ $mount_needs ]] && return 1
 
-    if ! dracut_module_included "systemd"; then
-        derror "systemd-networkd needs systemd in the initramfs"
-        return 1
-    fi
-
     return 255
 }
 
index e011a6396e7a8edc923fca7b8e49bc548c4f22b2..d18deb41311afdfdc2222f06c01016f25e29ea7a 100755 (executable)
@@ -11,25 +11,6 @@ check() {
     require_binaries dbus-broker || return 1
     require_binaries dbus-broker-launch || return 1
 
-    # If the module dependency requirements are not fulfilled
-    # return 1 to not include the required module(s).
-    if ! dracut_module_included "systemd"; then
-        derror "dbus-broker needs systemd in the initramfs."
-        return 1
-    fi
-
-    if ! dracut_module_included "systemd-sysusers"; then
-        derror "dbus-broker needs systemd-sysusers in the initramfs."
-        return 1
-    fi
-
-    # dbus-broker conflicts with dbus.
-
-    if dracut_module_included "dbus"; then
-        derror "dbus-broker conflicts with dbus in the initramfs."
-        exit 1
-    fi
-
     # Return 255 to only include the module, if another module requires it.
     return 255
 
@@ -37,7 +18,6 @@ check() {
 
 # Module dependency requirements.
 depends() {
-
     # This module has external dependency on the systemd module.
     echo systemd systemd-sysusers
     # Return 0 to include the dependent systemd module in the initramfs.
index 213c785ec3719384efc71478cda9cb8fefbc8d8c..273dd3d7c38e5419b5758c40a0a958fc2e8f70a7 100755 (executable)
@@ -11,13 +11,6 @@ check() {
     require_binaries dbus-daemon || return 1
     require_binaries dbus-send || return 1
 
-    # If the module dependency requirements are not fulfilled
-    # return 1 to not include the required module(s).
-    if ! dracut_module_included "systemd"; then
-        derror "dbus needs systemd in the initramfs."
-        return 1
-    fi
-
     # dbus conflicts with dbus-broker.
     if dracut_module_included "dbus-broker"; then
         derror "dbus conflicts with dbus-broker in the initramfs."
index 668e39fe4114aad36fc0bd73b671205b19546d34..d94a47afaee2429323349c60a4fe43ecb145b5f0 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-depends() {
-    echo systemd
-    return 0
-}
-
 check() {
     # if there's no rngd binary, no go.
     require_binaries rngd || return 1
@@ -30,6 +25,11 @@ check() {
     return 0
 }
 
+depends() {
+    echo systemd
+    return 0
+}
+
 install() {
     inst rngd
     inst_simple "${moddir}/rngd.service" "${systemdsystemunitdir}/rngd.service"
similarity index 50%
rename from modules.d/00dbus/module-setup.sh
rename to modules.d/09dbus/module-setup.sh
index 9c60a464ab15908ab3ac27a06b89ea4fac79957f..7f8317afa8ca80c28600c79bcab470ab86638719 100755 (executable)
@@ -10,14 +10,22 @@ check() {
 
 # Module dependency requirements.
 depends() {
+    local _module
     # Add a dbus meta dependency based on the module in use.
-    for module in dbus-daemon dbus-broker; do
-        if dracut_module_included "$module" ; then
-            dbus="$module"
-            break
+    for _module in dbus-daemon dbus-broker; do
+        if dracut_module_included "$_module" ; then
+            echo "$_module"
+            return 0
         fi
     done;
 
-    echo "$dbus"
-    return 0
+    if find_binary dbus-broker &> /dev/null ; then
+        echo "dbus-broker"
+        return 0
+    else
+        echo "dbus-daemon"
+        return 0
+    fi
+
+    return 1
 }
index eca635d5fade9eb1e720f357d93b9a452c66d0a4..d72c30620f135ae22abd8d5cf67a755eb4f90f05 100755 (executable)
@@ -17,7 +17,7 @@ depends() {
         done;
 
         if [ -z "$network_handler" ]; then
-            if require_binaries wicked; then
+            if find_binary wicked  &>/dev/null ; then
                 network_handler="network-wicked"
             elif [ -x "$dracutsysrootdir/usr/libexec/nm-initrd-generator" ]; then
                 network_handler="network-manager"
index 9c4e1b3dcef01154032db094a18c4c47baa6d5d2..0e5cd7ab93b894f98fd5e71f0f5dee80a8184621 100755 (executable)
@@ -4,11 +4,6 @@
 check() {
     [[ $mount_needs ]] && return 1
 
-    if ! dracut_module_included "systemd-initrd"; then
-        derror "dracut-systemd needs systemd-initrd in the initramfs"
-        return 1
-    fi
-
     return 0
 }
 
index 1bcc5da15f3362c8a94a0d6854307d994935d4c6..9886d1262ecd187d03304befc9fe6675d293fe8f 100644 (file)
@@ -1,19 +1,11 @@
 #!/bin/bash
 
 check() {
-    if ! dracut_module_included "systemd-initrd"; then
-        derror "dracut-squash only supports systemd bases initramfs"
-        return 1
-    fi
-
-    if ! find_binary mksquashfs >/dev/null || ! find_binary unsquashfs >/dev/null ; then
-        derror "dracut-squash module requires squashfs-tools"
-        return 1
-    fi
+    require_binaries mksquashfs unsquashfs || return 1
 
     for i in CONFIG_SQUASHFS CONFIG_BLK_DEV_LOOP CONFIG_OVERLAY_FS ; do
         if ! check_kernel_config $i; then
-            derror "dracut-squash module requires kernel configuration $i (y or m)"
+            dinfo "dracut-squash module requires kernel configuration $i (y or m)"
             return 1
         fi
     done