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

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