From: Harald Hoyer Date: Tue, 9 Feb 2021 15:24:59 +0000 (+0100) Subject: fix: revise all module checks X-Git-Tag: 052~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16efdfa25c65c31acc97d91b7baf4f7bb4ea8510;p=thirdparty%2Fdracut.git fix: revise all module checks 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 --- diff --git a/modules.d/01systemd-coredump/module-setup.sh b/modules.d/01systemd-coredump/module-setup.sh index db849fc0b..8b85e93cf 100755 --- a/modules.d/01systemd-coredump/module-setup.sh +++ b/modules.d/01systemd-coredump/module-setup.sh @@ -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 diff --git a/modules.d/01systemd-initrd/module-setup.sh b/modules.d/01systemd-initrd/module-setup.sh index 1e9f56913..3f86c5278 100755 --- a/modules.d/01systemd-initrd/module-setup.sh +++ b/modules.d/01systemd-initrd/module-setup.sh @@ -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 } diff --git a/modules.d/01systemd-repart/module-setup.sh b/modules.d/01systemd-repart/module-setup.sh index a08e89f8a..6f370bd46 100755 --- a/modules.d/01systemd-repart/module-setup.sh +++ b/modules.d/01systemd-repart/module-setup.sh @@ -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 diff --git a/modules.d/01systemd-sysusers/module-setup.sh b/modules.d/01systemd-sysusers/module-setup.sh index 3436c8fcc..6fcc0262f 100644 --- a/modules.d/01systemd-sysusers/module-setup.sh +++ b/modules.d/01systemd-sysusers/module-setup.sh @@ -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 diff --git a/modules.d/02systemd-networkd/module-setup.sh b/modules.d/02systemd-networkd/module-setup.sh index 03c3a7b56..b7603a9d8 100755 --- a/modules.d/02systemd-networkd/module-setup.sh +++ b/modules.d/02systemd-networkd/module-setup.sh @@ -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 } diff --git a/modules.d/06dbus-broker/module-setup.sh b/modules.d/06dbus-broker/module-setup.sh index e011a6396..d18deb413 100755 --- a/modules.d/06dbus-broker/module-setup.sh +++ b/modules.d/06dbus-broker/module-setup.sh @@ -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. diff --git a/modules.d/06dbus-daemon/module-setup.sh b/modules.d/06dbus-daemon/module-setup.sh index 213c785ec..273dd3d7c 100755 --- a/modules.d/06dbus-daemon/module-setup.sh +++ b/modules.d/06dbus-daemon/module-setup.sh @@ -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." diff --git a/modules.d/06rngd/module-setup.sh b/modules.d/06rngd/module-setup.sh index 668e39fe4..d94a47afa 100644 --- a/modules.d/06rngd/module-setup.sh +++ b/modules.d/06rngd/module-setup.sh @@ -18,11 +18,6 @@ # along with this program. If not, see . # -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" diff --git a/modules.d/00dbus/module-setup.sh b/modules.d/09dbus/module-setup.sh similarity index 50% rename from modules.d/00dbus/module-setup.sh rename to modules.d/09dbus/module-setup.sh index 9c60a464a..7f8317afa 100755 --- a/modules.d/00dbus/module-setup.sh +++ b/modules.d/09dbus/module-setup.sh @@ -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 } diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index eca635d5f..d72c30620 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -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" diff --git a/modules.d/98dracut-systemd/module-setup.sh b/modules.d/98dracut-systemd/module-setup.sh index 9c4e1b3dc..0e5cd7ab9 100755 --- a/modules.d/98dracut-systemd/module-setup.sh +++ b/modules.d/98dracut-systemd/module-setup.sh @@ -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 } diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh index 1bcc5da15..9886d1262 100644 --- a/modules.d/99squash/module-setup.sh +++ b/modules.d/99squash/module-setup.sh @@ -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