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

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