Blame SOURCES/0251-Factor-out-all-the-type-V-commands.patch

64b87c
From da3dacfa5e63ca00d4c8efd8c3c603bce7937cdd Mon Sep 17 00:00:00 2001
64b87c
From: Harald Hoyer <harald@redhat.com>
64b87c
Date: Thu, 6 Feb 2014 16:45:20 +0100
64b87c
Subject: [PATCH] Factor out all the "type -V" commands
64b87c
64b87c
Add new functions require_binaries() and require_any_binary() to be used
64b87c
in the check() section of module-setup.sh.
64b87c
64b87c
These functions print a warning line telling the user, which binary is
64b87c
missing for the specific dracut module.
64b87c
64b87c
This unifies the way of checking for binaries and makes the life of an
64b87c
initramfs creator easier, if he wants to find out why a specific dracut
64b87c
module is not included in the initramfs.
64b87c
64b87c
(cherry picked from commit 30e6e809ed8d189cc8374df3c28cfbcab5a299b9)
64b87c
---
64b87c
 dracut-functions.sh                           | 57 ++++++++++++++++++++++++---
64b87c
 modules.d/00bash/module-setup.sh              |  2 +-
64b87c
 modules.d/00bootchart/module-setup.sh         |  2 +-
64b87c
 modules.d/00dash/module-setup.sh              |  2 +-
64b87c
 modules.d/00systemd-bootchart/module-setup.sh |  2 +-
64b87c
 modules.d/02caps/module-setup.sh              | 14 ++++---
64b87c
 modules.d/03modsign/module-setup.sh           |  2 +-
64b87c
 modules.d/05busybox/module-setup.sh           |  2 +-
64b87c
 modules.d/10i18n/module-setup.sh              |  4 +-
64b87c
 modules.d/40network/module-setup.sh           |  7 +---
64b87c
 modules.d/45url-lib/module-setup.sh           |  2 +-
64b87c
 modules.d/50plymouth/module-setup.sh          |  2 +-
64b87c
 modules.d/90btrfs/module-setup.sh             |  2 +-
64b87c
 modules.d/90crypt/module-setup.sh             |  2 +-
64b87c
 modules.d/90dm/module-setup.sh                |  2 +-
64b87c
 modules.d/90dmraid/module-setup.sh            |  2 +-
64b87c
 modules.d/90lvm/module-setup.sh               |  2 +-
64b87c
 modules.d/90mdraid/module-setup.sh            |  2 +-
64b87c
 modules.d/90multipath/module-setup.sh         |  2 +-
64b87c
 modules.d/91crypt-gpg/module-setup.sh         |  2 +-
64b87c
 modules.d/91crypt-loop/module-setup.sh        | 21 ++++++----
64b87c
 modules.d/95cifs/module-setup.sh              |  2 +-
64b87c
 modules.d/95dasd/module-setup.sh              |  1 +
64b87c
 modules.d/95dasd_mod/module-setup.sh          |  1 +
64b87c
 modules.d/95fcoe-uefi/module-setup.sh         |  4 +-
64b87c
 modules.d/95fcoe/module-setup.sh              |  5 +--
64b87c
 modules.d/95iscsi/module-setup.sh             |  2 +-
64b87c
 modules.d/95nbd/module-setup.sh               |  2 +-
64b87c
 modules.d/95nfs/module-setup.sh               |  4 +-
64b87c
 modules.d/95ssh-client/module-setup.sh        |  6 +--
64b87c
 modules.d/95udev-rules/module-setup.sh        |  2 +-
64b87c
 modules.d/95zfcp/module-setup.sh              |  2 +
64b87c
 modules.d/95znet/module-setup.sh              |  2 +
64b87c
 modules.d/97biosdevname/module-setup.sh       |  2 +-
64b87c
 modules.d/97masterkey/module-setup.sh         |  2 +-
64b87c
 modules.d/98systemd/module-setup.sh           |  2 +-
64b87c
 modules.d/99img-lib/module-setup.sh           |  4 +-
64b87c
 37 files changed, 112 insertions(+), 66 deletions(-)
64b87c
64b87c
diff --git a/dracut-functions.sh b/dracut-functions.sh
1755ca
index 89438b29..4ea3204d 100755
64b87c
--- a/dracut-functions.sh
64b87c
+++ b/dracut-functions.sh
64b87c
@@ -35,6 +35,51 @@ fi
64b87c
 # Generic substring function.  If $2 is in $1, return 0.
64b87c
 strstr() { [[ $1 = *$2* ]]; }
64b87c
 
64b87c
+# helper function for check() in module-setup.sh
64b87c
+# to check for required installed binaries
64b87c
+# issues a standardized warning message
64b87c
+require_binaries() {
64b87c
+    local _module_name="${moddir##*/}"
64b87c
+    local _ret=0
64b87c
+
64b87c
+    if [[ "$1" = "-m" ]]; then
64b87c
+        _module_name="$2"
64b87c
+        shift 2
64b87c
+    fi
64b87c
+
64b87c
+    for cmd in "$@"; do
64b87c
+        if ! find_binary "$cmd" &>/dev/null; then
64b87c
+            dwarning "$_module_name: Could not find command '$cmd'!"
64b87c
+            ((_ret++))
64b87c
+        fi
64b87c
+    done
64b87c
+    return $_ret
64b87c
+}
64b87c
+
64b87c
+require_any_binary() {
64b87c
+    local _module_name="${moddir##*/}"
64b87c
+    local _ret=1
64b87c
+
64b87c
+    if [[ "$1" = "-m" ]]; then
64b87c
+        _module_name="$2"
64b87c
+        shift 2
64b87c
+    fi
64b87c
+
64b87c
+    for cmd in "$@"; do
64b87c
+        if find_binary "$cmd" &>/dev/null; then
64b87c
+            _ret=0
64b87c
+            break
64b87c
+        fi
64b87c
+    done
64b87c
+
64b87c
+    if (( $_ret != 0 )); then
64b87c
+        dwarning "$_module_name: Could not find any command of '$@'!"
64b87c
+        return 1
64b87c
+    fi
64b87c
+
64b87c
+    return 0
64b87c
+}
64b87c
+
64b87c
 # find a binary.  If we were not passed the full path directly,
64b87c
 # search in the usual places to find the binary.
64b87c
 find_binary() {
64b87c
@@ -1055,7 +1100,7 @@ module_check() {
64b87c
         . $_moddir/module-setup.sh
64b87c
         is_func check || return 0
64b87c
         [ $_forced -ne 0 ] && unset hostonly
64b87c
-        check $hostonly
64b87c
+        moddir=$_moddir check $hostonly
64b87c
         _ret=$?
64b87c
         unset check depends cmdline install installkernel
64b87c
     fi
64b87c
@@ -1081,7 +1126,7 @@ module_check_mount() {
64b87c
         unset check depends cmdline install installkernel
64b87c
         check() { false; }
64b87c
         . $_moddir/module-setup.sh
64b87c
-        check 0
64b87c
+        moddir=$_moddir check 0
64b87c
         _ret=$?
64b87c
         unset check depends cmdline install installkernel
64b87c
     fi
64b87c
@@ -1105,7 +1150,7 @@ module_depends() {
64b87c
         unset check depends cmdline install installkernel
64b87c
         depends() { true; }
64b87c
         . $_moddir/module-setup.sh
64b87c
-        depends
64b87c
+        moddir=$_moddir depends
64b87c
         _ret=$?
64b87c
         unset check depends cmdline install installkernel
64b87c
         return $_ret
64b87c
@@ -1126,7 +1171,7 @@ module_cmdline() {
64b87c
         unset check depends cmdline install installkernel
64b87c
         cmdline() { true; }
64b87c
         . $_moddir/module-setup.sh
64b87c
-        cmdline
64b87c
+        moddir=$_moddir cmdline
64b87c
         _ret=$?
64b87c
         unset check depends cmdline install installkernel
64b87c
         return $_ret
64b87c
@@ -1147,7 +1192,7 @@ module_install() {
64b87c
         unset check depends cmdline install installkernel
64b87c
         install() { true; }
64b87c
         . $_moddir/module-setup.sh
64b87c
-        install
64b87c
+        moddir=$_moddir install
64b87c
         _ret=$?
64b87c
         unset check depends cmdline install installkernel
64b87c
         return $_ret
64b87c
@@ -1168,7 +1213,7 @@ module_installkernel() {
64b87c
         unset check depends cmdline install installkernel
64b87c
         installkernel() { true; }
64b87c
         . $_moddir/module-setup.sh
64b87c
-        installkernel
64b87c
+        moddir=$_moddir installkernel
64b87c
         _ret=$?
64b87c
         unset check depends cmdline install installkernel
64b87c
         return $_ret
64b87c
diff --git a/modules.d/00bash/module-setup.sh b/modules.d/00bash/module-setup.sh
1755ca
index e874e73d..109642ac 100755
64b87c
--- a/modules.d/00bash/module-setup.sh
64b87c
+++ b/modules.d/00bash/module-setup.sh
64b87c
@@ -3,7 +3,7 @@
64b87c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
 
64b87c
 check() {
64b87c
-    [ -x /bin/bash ]
64b87c
+    require_binaries /bin/bash
64b87c
 }
64b87c
 
64b87c
 depends() {
64b87c
diff --git a/modules.d/00bootchart/module-setup.sh b/modules.d/00bootchart/module-setup.sh
1755ca
index 72b60633..f03fc540 100755
64b87c
--- a/modules.d/00bootchart/module-setup.sh
64b87c
+++ b/modules.d/00bootchart/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     [[ "$mount_needs" ]] && return 1
64b87c
-    [ -x /sbin/bootchartd ] || return 1
64b87c
+    require_binaries /sbin/bootchartd || return 1
64b87c
     return 255
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/00dash/module-setup.sh b/modules.d/00dash/module-setup.sh
1755ca
index dfd4d7bf..9a2a92fc 100755
64b87c
--- a/modules.d/00dash/module-setup.sh
64b87c
+++ b/modules.d/00dash/module-setup.sh
64b87c
@@ -3,7 +3,7 @@
64b87c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
 
64b87c
 check() {
64b87c
-    [ -x /bin/dash ]
64b87c
+    require_binaries /bin/dash
64b87c
 }
64b87c
 
64b87c
 depends() {
64b87c
diff --git a/modules.d/00systemd-bootchart/module-setup.sh b/modules.d/00systemd-bootchart/module-setup.sh
1755ca
index 3eb4de1e..eb6f383c 100755
64b87c
--- a/modules.d/00systemd-bootchart/module-setup.sh
64b87c
+++ b/modules.d/00systemd-bootchart/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     [[ "$mount_needs" ]] && return 1
64b87c
-    [ -x $systemdutildir/systemd-bootchart ] || return 1
64b87c
+    require_binaries $systemdutildir/systemd-bootchart || return 1
64b87c
     return 255
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/02caps/module-setup.sh b/modules.d/02caps/module-setup.sh
1755ca
index c9d94eeb..73eb215b 100755
64b87c
--- a/modules.d/02caps/module-setup.sh
64b87c
+++ b/modules.d/02caps/module-setup.sh
64b87c
@@ -3,7 +3,7 @@
64b87c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
 
64b87c
 check() {
64b87c
-    type -P capsh >/dev/null 2>&1
64b87c
+    require_binaries capsh
64b87c
 }
64b87c
 
64b87c
 depends() {
64b87c
@@ -11,9 +11,13 @@ depends() {
64b87c
 }
64b87c
 
64b87c
 install() {
64b87c
-    inst_hook pre-pivot 00 "$moddir/caps.sh"
64b87c
-    inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
64b87c
-    # capsh wants bash and we need bash also
64b87c
-    inst /bin/bash
64b87c
+    if ! dracut_module_included "systemd"; then
64b87c
+        inst_hook pre-pivot 00 "$moddir/caps.sh"
64b87c
+        inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
64b87c
+        # capsh wants bash and we need bash also
64b87c
+        inst /bin/bash
64b87c
+    else
64b87c
+        dwarning "caps: does not work with systemd in the initramfs"
64b87c
+    fi
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/03modsign/module-setup.sh b/modules.d/03modsign/module-setup.sh
1755ca
index 730cd86e..bed5cfe1 100755
64b87c
--- a/modules.d/03modsign/module-setup.sh
64b87c
+++ b/modules.d/03modsign/module-setup.sh
64b87c
@@ -8,7 +8,7 @@
64b87c
 # Peter Jones <pjones@redhat.com>
64b87c
 
64b87c
 check() {
64b87c
-    [[ -x /usr/bin/keyctl ]] || return 1
64b87c
+    require_binaries keyctl || return 1
64b87c
 
64b87c
     # do not include module in hostonly mode,
64b87c
     # if no keys are present
64b87c
diff --git a/modules.d/05busybox/module-setup.sh b/modules.d/05busybox/module-setup.sh
1755ca
index edcc8daa..c35ab2e9 100755
64b87c
--- a/modules.d/05busybox/module-setup.sh
64b87c
+++ b/modules.d/05busybox/module-setup.sh
64b87c
@@ -3,7 +3,7 @@
64b87c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
 
64b87c
 check() {
64b87c
-    type -P busybox >/dev/null || return 1
64b87c
+    require_binaries busybox || return 1
64b87c
 
64b87c
     return 255
64b87c
 }
64b87c
diff --git a/modules.d/10i18n/module-setup.sh b/modules.d/10i18n/module-setup.sh
1755ca
index 413ee123..2c0a275c 100755
64b87c
--- a/modules.d/10i18n/module-setup.sh
64b87c
+++ b/modules.d/10i18n/module-setup.sh
64b87c
@@ -5,9 +5,7 @@
64b87c
 check() {
64b87c
     [[ "$mount_needs" ]] && return 1
64b87c
 
64b87c
-    for i in setfont loadkeys kbd_mode; do
64b87c
-        type -P "$i" >/dev/null || return 1
64b87c
-    done
64b87c
+    require_binaries setfont loadkeys kbd_mode || return 1
64b87c
 
64b87c
     return 0
64b87c
 }
64b87c
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
1755ca
index a52e881b..3134b5ff 100755
64b87c
--- a/modules.d/40network/module-setup.sh
64b87c
+++ b/modules.d/40network/module-setup.sh
64b87c
@@ -5,12 +5,7 @@
64b87c
 check() {
64b87c
     local _program
64b87c
 
64b87c
-    for _program in ip arping dhclient ; do
64b87c
-        if ! type -P $_program >/dev/null; then
64b87c
-            derror "Could not find program \"$_program\" required by network."
64b87c
-            return 1
64b87c
-        fi
64b87c
-    done
64b87c
+    require_binaries ip arping dhclient || return 1
64b87c
 
64b87c
     return 255
64b87c
 }
64b87c
diff --git a/modules.d/45url-lib/module-setup.sh b/modules.d/45url-lib/module-setup.sh
1755ca
index b5cf36f2..f2d068b3 100755
64b87c
--- a/modules.d/45url-lib/module-setup.sh
64b87c
+++ b/modules.d/45url-lib/module-setup.sh
64b87c
@@ -2,7 +2,7 @@
64b87c
 # module-setup for url-lib
64b87c
 
64b87c
 check() {
64b87c
-    command -v curl >/dev/null || return 1
64b87c
+    require_binaries curl || return 1
64b87c
     return 255
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/50plymouth/module-setup.sh b/modules.d/50plymouth/module-setup.sh
1755ca
index e0e69367..961c1e39 100755
64b87c
--- a/modules.d/50plymouth/module-setup.sh
64b87c
+++ b/modules.d/50plymouth/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     [[ "$mount_needs" ]] && return 1
64b87c
-    type -P plymouthd >/dev/null && type -P plymouth >/dev/null
64b87c
+    require_binaries plymouthd plymouth
64b87c
 }
64b87c
 
64b87c
 depends() {
64b87c
diff --git a/modules.d/90btrfs/module-setup.sh b/modules.d/90btrfs/module-setup.sh
1755ca
index a2805946..4804f58b 100755
64b87c
--- a/modules.d/90btrfs/module-setup.sh
64b87c
+++ b/modules.d/90btrfs/module-setup.sh
64b87c
@@ -6,7 +6,7 @@ check() {
64b87c
     local _rootdev
64b87c
     # if we don't have btrfs installed on the host system,
64b87c
     # no point in trying to support it in the initramfs.
64b87c
-    type -P btrfs >/dev/null || return 1
64b87c
+    require_binaries btrfs || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for fs in ${host_fs_types[@]}; do
64b87c
diff --git a/modules.d/90crypt/module-setup.sh b/modules.d/90crypt/module-setup.sh
1755ca
index 272e527d..dbc87a43 100755
64b87c
--- a/modules.d/90crypt/module-setup.sh
64b87c
+++ b/modules.d/90crypt/module-setup.sh
64b87c
@@ -5,7 +5,7 @@
64b87c
 check() {
64b87c
     local _rootdev
64b87c
     # if cryptsetup is not installed, then we cannot support encrypted devices.
64b87c
-    type -P cryptsetup >/dev/null || return 1
64b87c
+    require_binaries cryptsetup || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for fs in "${host_fs_types[@]}"; do
64b87c
diff --git a/modules.d/90dm/module-setup.sh b/modules.d/90dm/module-setup.sh
1755ca
index 1fd92987..ed94f436 100755
64b87c
--- a/modules.d/90dm/module-setup.sh
64b87c
+++ b/modules.d/90dm/module-setup.sh
64b87c
@@ -3,7 +3,7 @@
64b87c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
 
64b87c
 check() {
64b87c
-    type -P dmsetup >/dev/null || return 1
64b87c
+    require_binaries dmsetup || return 1
64b87c
     return 255
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/90dmraid/module-setup.sh b/modules.d/90dmraid/module-setup.sh
1755ca
index b230cb0e..8ca69aa8 100755
64b87c
--- a/modules.d/90dmraid/module-setup.sh
64b87c
+++ b/modules.d/90dmraid/module-setup.sh
64b87c
@@ -6,7 +6,7 @@ check() {
64b87c
     local _rootdev
64b87c
     # if we don't have dmraid installed on the host system, no point
64b87c
     # in trying to support it in the initramfs.
64b87c
-    type -P dmraid >/dev/null || return 1
64b87c
+    require_binaries dmraid || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for dev in "${!host_fs_types[@]}"; do
64b87c
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
1755ca
index 0c5890a7..5ec62812 100755
64b87c
--- a/modules.d/90lvm/module-setup.sh
64b87c
+++ b/modules.d/90lvm/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     # No point trying to support lvm if the binaries are missing
64b87c
-    type -P lvm >/dev/null || return 1
64b87c
+    require_binaries lvm || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for fs in "${host_fs_types[@]}"; do
64b87c
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
1755ca
index 815a3ebc..2092daea 100755
64b87c
--- a/modules.d/90mdraid/module-setup.sh
64b87c
+++ b/modules.d/90mdraid/module-setup.sh
64b87c
@@ -5,7 +5,7 @@
64b87c
 check() {
64b87c
     local _rootdev
64b87c
     # No mdadm?  No mdraid support.
64b87c
-    type -P mdadm >/dev/null || return 1
64b87c
+    require_binaries mdadm || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for dev in "${!host_fs_types[@]}"; do
64b87c
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
1755ca
index feb58dcd..d37f9587 100755
64b87c
--- a/modules.d/90multipath/module-setup.sh
64b87c
+++ b/modules.d/90multipath/module-setup.sh
64b87c
@@ -5,7 +5,7 @@
64b87c
 check() {
64b87c
     local _rootdev
64b87c
     # if there's no multipath binary, no go.
64b87c
-    type -P multipath >/dev/null || return 1
64b87c
+    require_binaries multipath || return 1
64b87c
 
64b87c
     is_mpath() {
64b87c
         local _dev=$1
64b87c
diff --git a/modules.d/91crypt-gpg/module-setup.sh b/modules.d/91crypt-gpg/module-setup.sh
1755ca
index 43a5a000..17b58f1a 100755
64b87c
--- a/modules.d/91crypt-gpg/module-setup.sh
64b87c
+++ b/modules.d/91crypt-gpg/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 # GPG support is optional
64b87c
 check() {
64b87c
-    type -P gpg >/dev/null || return 1
64b87c
+    require_binaries gpg || return 1
64b87c
 
64b87c
     return 255
64b87c
 }
64b87c
diff --git a/modules.d/91crypt-loop/module-setup.sh b/modules.d/91crypt-loop/module-setup.sh
1755ca
index c14fd45a..d0a49567 100644
64b87c
--- a/modules.d/91crypt-loop/module-setup.sh
64b87c
+++ b/modules.d/91crypt-loop/module-setup.sh
64b87c
@@ -1,19 +1,24 @@
64b87c
+#!/bin/bash
64b87c
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
64b87c
+# ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
+
64b87c
+# called by dracut
64b87c
 check() {
64b87c
-	type -P losetup >/dev/null || return 1
64b87c
-	
64b87c
-	return 255
64b87c
+    require_binaries losetup || return 1
64b87c
+
64b87c
+    return 255
64b87c
 }
64b87c
 
64b87c
 depends() {
64b87c
-	echo crypt
64b87c
+    echo crypt
64b87c
 }
64b87c
 
64b87c
 installkernel() {
64b87c
-	    instmods loop
64b87c
+    instmods loop
64b87c
 }
64b87c
 
64b87c
 install() {
64b87c
-	inst_multiple losetup
64b87c
-	inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
64b87c
-        dracut_need_initqueue
64b87c
+    inst_multiple losetup
64b87c
+    inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
64b87c
+    dracut_need_initqueue
64b87c
 }
64b87c
diff --git a/modules.d/95cifs/module-setup.sh b/modules.d/95cifs/module-setup.sh
1755ca
index c17b973a..9e36f87f 100755
64b87c
--- a/modules.d/95cifs/module-setup.sh
64b87c
+++ b/modules.d/95cifs/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     # If our prerequisites are not met, fail anyways.
64b87c
-    type -P mount.cifs >/dev/null || return 1
64b87c
+    require_binaries mount.cifs || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for fs in ${host_fs_types[@]}; do
64b87c
diff --git a/modules.d/95dasd/module-setup.sh b/modules.d/95dasd/module-setup.sh
1755ca
index 3b8396db..70b2fcc8 100755
64b87c
--- a/modules.d/95dasd/module-setup.sh
64b87c
+++ b/modules.d/95dasd/module-setup.sh
64b87c
@@ -5,6 +5,7 @@
64b87c
 check() {
64b87c
     local _arch=$(uname -m)
64b87c
     [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
64b87c
+    require_binaries normalize_dasd_arg || return 1
64b87c
     return 0
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/95dasd_mod/module-setup.sh b/modules.d/95dasd_mod/module-setup.sh
1755ca
index 9c9eeead..d20764eb 100755
64b87c
--- a/modules.d/95dasd_mod/module-setup.sh
64b87c
+++ b/modules.d/95dasd_mod/module-setup.sh
64b87c
@@ -5,6 +5,7 @@
64b87c
 check() {
64b87c
     local _arch=$(uname -m)
64b87c
     [ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
64b87c
+    require_binaries grep sed seq
64b87c
 
64b87c
     return 0
64b87c
 }
64b87c
diff --git a/modules.d/95fcoe-uefi/module-setup.sh b/modules.d/95fcoe-uefi/module-setup.sh
1755ca
index c91f7754..0fb06e23 100755
64b87c
--- a/modules.d/95fcoe-uefi/module-setup.sh
64b87c
+++ b/modules.d/95fcoe-uefi/module-setup.sh
64b87c
@@ -4,9 +4,7 @@
64b87c
 
64b87c
 # called by dracut
64b87c
 check() {
64b87c
-    for i in dcbtool fipvlan lldpad ip readlink; do
64b87c
-        type -P $i >/dev/null || return 1
64b87c
-    done
64b87c
+    require_binaries dcbtool fipvlan lldpad ip readlink || return 1
64b87c
     return 0
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
1755ca
index 3ffaf5a5..8c6290d4 100755
64b87c
--- a/modules.d/95fcoe/module-setup.sh
64b87c
+++ b/modules.d/95fcoe/module-setup.sh
64b87c
@@ -3,10 +3,7 @@
64b87c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
64b87c
 
64b87c
 check() {
64b87c
-    for i in dcbtool fipvlan lldpad ip readlink; do
64b87c
-        type -P $i >/dev/null || return 1
64b87c
-    done
64b87c
-
64b87c
+    require_binaries dcbtool fipvlan lldpad ip readlink || return 1
64b87c
     return 0
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh
1755ca
index c6901c08..49f9a0ed 100755
64b87c
--- a/modules.d/95iscsi/module-setup.sh
64b87c
+++ b/modules.d/95iscsi/module-setup.sh
64b87c
@@ -5,7 +5,7 @@
64b87c
 check() {
64b87c
     local _rootdev
64b87c
     # If our prerequisites are not met, fail anyways.
64b87c
-    type -P iscsistart hostname iscsi-iname >/dev/null || return 1
64b87c
+    require_binaries iscsistart hostname iscsi-iname || return 1
64b87c
 
64b87c
     # If hostonly was requested, fail the check if we are not actually
64b87c
     # booting from root.
64b87c
diff --git a/modules.d/95nbd/module-setup.sh b/modules.d/95nbd/module-setup.sh
1755ca
index 3ac00f60..7e8a416c 100755
64b87c
--- a/modules.d/95nbd/module-setup.sh
64b87c
+++ b/modules.d/95nbd/module-setup.sh
64b87c
@@ -5,7 +5,7 @@
64b87c
 check() {
64b87c
     local _rootdev
64b87c
     # If our prerequisites are not met, fail.
64b87c
-    type -P nbd-client >/dev/null || return 1
64b87c
+    require_binaries nbd-client || return 1
64b87c
 
64b87c
     # if an nbd device is not somewhere in the chain of devices root is
64b87c
     # mounted on, fail the hostonly check.
64b87c
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
1755ca
index 75beb746..02838a49 100755
64b87c
--- a/modules.d/95nfs/module-setup.sh
64b87c
+++ b/modules.d/95nfs/module-setup.sh
64b87c
@@ -4,8 +4,8 @@
64b87c
 
64b87c
 check() {
64b87c
     # If our prerequisites are not met, fail anyways.
64b87c
-    type -P rpcbind >/dev/null || type -P portmap >/dev/null || return 1
64b87c
-    type -P rpc.statd mount.nfs mount.nfs4 umount >/dev/null || return 1
64b87c
+    require_any_binary rpcbind portmap || return 1
64b87c
+    require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
64b87c
 
64b87c
     [[ $hostonly ]] || [[ $mount_needs ]] && {
64b87c
         for fs in ${host_fs_types[@]}; do
64b87c
diff --git a/modules.d/95ssh-client/module-setup.sh b/modules.d/95ssh-client/module-setup.sh
1755ca
index c7d8ee24..6b441075 100755
64b87c
--- a/modules.d/95ssh-client/module-setup.sh
64b87c
+++ b/modules.d/95ssh-client/module-setup.sh
64b87c
@@ -5,11 +5,11 @@
64b87c
 # fixme: assume user is root
64b87c
 
64b87c
 check() {
64b87c
-    # If our prerequisites are not met, fail.
64b87c
-    type -P ssh >/dev/null || return 1
64b87c
-    type -P scp >/dev/null || return 1
64b87c
     [[ $mount_needs ]] && return 1
64b87c
 
64b87c
+    # If our prerequisites are not met, fail.
64b87c
+    require_binaries ssh scp  || return 1
64b87c
+
64b87c
     if [[ $sshkey ]]; then
64b87c
         [ ! -f $sshkey ] && {
64b87c
             derror "ssh key: $sshkey is not found!"
64b87c
diff --git a/modules.d/95udev-rules/module-setup.sh b/modules.d/95udev-rules/module-setup.sh
1755ca
index 094479a3..fdea8c6d 100755
64b87c
--- a/modules.d/95udev-rules/module-setup.sh
64b87c
+++ b/modules.d/95udev-rules/module-setup.sh
64b87c
@@ -5,7 +5,7 @@
64b87c
 install() {
64b87c
     local _i
64b87c
 
64b87c
-    # Fixme: would be nice if we didn't have to know which rules to grab....
64b87c
+    # Fixme: would be nice if we didn't have to guess, which rules to grab....
64b87c
     # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
64b87c
     # of the rules we want so that we just copy those in would be best
64b87c
     inst_multiple udevadm cat uname blkid \
64b87c
diff --git a/modules.d/95zfcp/module-setup.sh b/modules.d/95zfcp/module-setup.sh
1755ca
index 99066958..d19eba4c 100755
64b87c
--- a/modules.d/95zfcp/module-setup.sh
64b87c
+++ b/modules.d/95zfcp/module-setup.sh
64b87c
@@ -6,6 +6,8 @@ check() {
64b87c
     arch=$(uname -m)
64b87c
     [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
64b87c
 
64b87c
+    require_binaries zfcp_cio_free grep sed seq || return 1
64b87c
+
64b87c
     return 0
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/95znet/module-setup.sh b/modules.d/95znet/module-setup.sh
1755ca
index 16f84938..b052ec37 100755
64b87c
--- a/modules.d/95znet/module-setup.sh
64b87c
+++ b/modules.d/95znet/module-setup.sh
64b87c
@@ -6,6 +6,8 @@ check() {
64b87c
     arch=$(uname -m)
64b87c
     [ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
64b87c
 
64b87c
+    require_binaries znet_cio_free grep sed seq readlink || return 1
64b87c
+
64b87c
     return 0
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/97biosdevname/module-setup.sh b/modules.d/97biosdevname/module-setup.sh
1755ca
index 4a0b4f41..fd4d4632 100755
64b87c
--- a/modules.d/97biosdevname/module-setup.sh
64b87c
+++ b/modules.d/97biosdevname/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     [[ "$mount_needs" ]] && return 1
64b87c
-    type -P biosdevname >/dev/null || return 1
64b87c
+    require_binaries biosdevname || return 1
64b87c
     return 0
64b87c
 }
64b87c
 
64b87c
diff --git a/modules.d/97masterkey/module-setup.sh b/modules.d/97masterkey/module-setup.sh
1755ca
index a94c4f53..cda6e809 100755
64b87c
--- a/modules.d/97masterkey/module-setup.sh
64b87c
+++ b/modules.d/97masterkey/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     [[ $hostonly ]] && {
64b87c
-        [ -x "/bin/keyctl" ] || return 1
64b87c
+        require_binaries keyctl uname || return 1
64b87c
     }
64b87c
 
64b87c
     return 255
64b87c
diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh
1755ca
index aae0319a..d0271f15 100755
64b87c
--- a/modules.d/98systemd/module-setup.sh
64b87c
+++ b/modules.d/98systemd/module-setup.sh
64b87c
@@ -4,7 +4,7 @@
64b87c
 
64b87c
 check() {
64b87c
     [[ $mount_needs ]] && return 1
64b87c
-    if [[ -x $systemdutildir/systemd ]]; then
64b87c
+    if require_binaries $systemdutildir/systemd; then
64b87c
         SYSTEMD_VERSION=$($systemdutildir/systemd --version | { read a b a; echo $b; })
64b87c
         (( $SYSTEMD_VERSION >= 198 )) && return 0
64b87c
        return 255
64b87c
diff --git a/modules.d/99img-lib/module-setup.sh b/modules.d/99img-lib/module-setup.sh
1755ca
index 28bfc2aa..a951b930 100755
64b87c
--- a/modules.d/99img-lib/module-setup.sh
64b87c
+++ b/modules.d/99img-lib/module-setup.sh
64b87c
@@ -2,9 +2,7 @@
64b87c
 # module-setup for img-lib
64b87c
 
64b87c
 check() {
64b87c
-    for cmd in tar gzip dd; do
64b87c
-        command -v $cmd >/dev/null || return 1
64b87c
-    done
64b87c
+    require_binaries tar gzip dd bash || return 1
64b87c
     return 255
64b87c
 }
64b87c