Factor out all the "type -V" commands
Add new functions require_binaries() and require_any_binary() to be used in the check() section of module-setup.sh. These functions print a warning line telling the user, which binary is missing for the specific dracut module. This unifies the way of checking for binaries and makes the life of an initramfs creator easier, if he wants to find out why a specific dracut module is not included in the initramfs.master
parent
8d21728942
commit
30e6e809ed
|
|
@ -35,6 +35,51 @@ fi
|
|||
# Generic substring function. If $2 is in $1, return 0.
|
||||
strstr() { [[ $1 = *$2* ]]; }
|
||||
|
||||
# helper function for check() in module-setup.sh
|
||||
# to check for required installed binaries
|
||||
# issues a standardized warning message
|
||||
require_binaries() {
|
||||
local _module_name="${moddir##*/}"
|
||||
local _ret=0
|
||||
|
||||
if [[ "$1" = "-m" ]]; then
|
||||
_module_name="$2"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
for cmd in "$@"; do
|
||||
if ! find_binary "$cmd" &>/dev/null; then
|
||||
dwarning "$_module_name: Could not find command '$cmd'!"
|
||||
((_ret++))
|
||||
fi
|
||||
done
|
||||
return $_ret
|
||||
}
|
||||
|
||||
require_any_binary() {
|
||||
local _module_name="${moddir##*/}"
|
||||
local _ret=1
|
||||
|
||||
if [[ "$1" = "-m" ]]; then
|
||||
_module_name="$2"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
for cmd in "$@"; do
|
||||
if find_binary "$cmd" &>/dev/null; then
|
||||
_ret=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if (( $_ret != 0 )); then
|
||||
dwarning "$_module_name: Could not find any command of '$@'!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# find a binary. If we were not passed the full path directly,
|
||||
# search in the usual places to find the binary.
|
||||
find_binary() {
|
||||
|
|
@ -1084,7 +1129,7 @@ module_check() {
|
|||
. $_moddir/module-setup.sh
|
||||
is_func check || return 0
|
||||
[ $_forced -ne 0 ] && unset hostonly
|
||||
check $hostonly
|
||||
moddir=$_moddir check $hostonly
|
||||
_ret=$?
|
||||
unset check depends cmdline install installkernel
|
||||
fi
|
||||
|
|
@ -1110,7 +1155,7 @@ module_check_mount() {
|
|||
unset check depends cmdline install installkernel
|
||||
check() { false; }
|
||||
. $_moddir/module-setup.sh
|
||||
check 0
|
||||
moddir=$_moddir check 0
|
||||
_ret=$?
|
||||
unset check depends cmdline install installkernel
|
||||
fi
|
||||
|
|
@ -1134,7 +1179,7 @@ module_depends() {
|
|||
unset check depends cmdline install installkernel
|
||||
depends() { true; }
|
||||
. $_moddir/module-setup.sh
|
||||
depends
|
||||
moddir=$_moddir depends
|
||||
_ret=$?
|
||||
unset check depends cmdline install installkernel
|
||||
return $_ret
|
||||
|
|
@ -1155,7 +1200,7 @@ module_cmdline() {
|
|||
unset check depends cmdline install installkernel
|
||||
cmdline() { true; }
|
||||
. $_moddir/module-setup.sh
|
||||
cmdline
|
||||
moddir=$_moddir cmdline
|
||||
_ret=$?
|
||||
unset check depends cmdline install installkernel
|
||||
return $_ret
|
||||
|
|
@ -1176,7 +1221,7 @@ module_install() {
|
|||
unset check depends cmdline install installkernel
|
||||
install() { true; }
|
||||
. $_moddir/module-setup.sh
|
||||
install
|
||||
moddir=$_moddir install
|
||||
_ret=$?
|
||||
unset check depends cmdline install installkernel
|
||||
return $_ret
|
||||
|
|
@ -1197,7 +1242,7 @@ module_installkernel() {
|
|||
unset check depends cmdline install installkernel
|
||||
installkernel() { true; }
|
||||
. $_moddir/module-setup.sh
|
||||
installkernel
|
||||
moddir=$_moddir installkernel
|
||||
_ret=$?
|
||||
unset check depends cmdline install installkernel
|
||||
return $_ret
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
[ -x /bin/bash ]
|
||||
require_binaries /bin/bash
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
[ -x /sbin/bootchartd ] || return 1
|
||||
require_binaries /sbin/bootchartd || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
[ -x /bin/dash ]
|
||||
require_binaries /bin/dash
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
[ -x $systemdutildir/systemd-bootchart ] || return 1
|
||||
require_binaries $systemdutildir/systemd-bootchart || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
type -P capsh >/dev/null 2>&1
|
||||
require_binaries capsh
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
|
|
@ -14,9 +14,13 @@ depends() {
|
|||
|
||||
# called by dracut
|
||||
install() {
|
||||
inst_hook pre-pivot 00 "$moddir/caps.sh"
|
||||
inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
|
||||
# capsh wants bash and we need bash also
|
||||
inst /bin/bash
|
||||
if ! dracut_module_included "systemd"; then
|
||||
inst_hook pre-pivot 00 "$moddir/caps.sh"
|
||||
inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
|
||||
# capsh wants bash and we need bash also
|
||||
inst /bin/bash
|
||||
else
|
||||
dwarning "caps: does not work with systemd in the initramfs"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
[[ -x /usr/bin/keyctl ]] || return 1
|
||||
require_binaries keyctl || return 1
|
||||
|
||||
# do not include module in hostonly mode,
|
||||
# if no keys are present
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
type -P busybox >/dev/null || return 1
|
||||
require_binaries busybox || return 1
|
||||
|
||||
return 255
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@
|
|||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
|
||||
for i in setfont loadkeys kbd_mode; do
|
||||
type -P "$i" >/dev/null || return 1
|
||||
done
|
||||
require_binaries setfont loadkeys kbd_mode || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,7 @@
|
|||
check() {
|
||||
local _program
|
||||
|
||||
for _program in ip arping dhclient ; do
|
||||
if ! type -P $_program >/dev/null; then
|
||||
derror "Could not find program \"$_program\" required by network."
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
require_binaries ip arping dhclient || return 1
|
||||
|
||||
return 255
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
command -v curl >/dev/null || return 1
|
||||
require_binaries curl || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
type -P plymouthd >/dev/null && type -P plymouth >/dev/null
|
||||
require_binaries plymouthd plymouth
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ check() {
|
|||
local _rootdev
|
||||
# if we don't have btrfs installed on the host system,
|
||||
# no point in trying to support it in the initramfs.
|
||||
type -P btrfs >/dev/null || return 1
|
||||
require_binaries btrfs || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
check() {
|
||||
local _rootdev
|
||||
# if cryptsetup is not installed, then we cannot support encrypted devices.
|
||||
type -P cryptsetup >/dev/null || return 1
|
||||
require_binaries cryptsetup || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in "${host_fs_types[@]}"; do
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
type -P dmsetup >/dev/null || return 1
|
||||
require_binaries dmsetup || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ check() {
|
|||
local _rootdev
|
||||
# if we don't have dmraid installed on the host system, no point
|
||||
# in trying to support it in the initramfs.
|
||||
type -P dmraid >/dev/null || return 1
|
||||
require_binaries dmraid || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for dev in "${!host_fs_types[@]}"; do
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
# No point trying to support lvm if the binaries are missing
|
||||
type -P lvm >/dev/null || return 1
|
||||
require_binaries lvm || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in "${host_fs_types[@]}"; do
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
check() {
|
||||
local _rootdev
|
||||
# No mdadm? No mdraid support.
|
||||
type -P mdadm >/dev/null || return 1
|
||||
require_binaries mdadm || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for dev in "${!host_fs_types[@]}"; do
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
check() {
|
||||
local _rootdev
|
||||
# if there's no multipath binary, no go.
|
||||
type -P multipath >/dev/null || return 1
|
||||
require_binaries multipath || return 1
|
||||
|
||||
is_mpath() {
|
||||
local _dev=$1
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# GPG support is optional
|
||||
# called by dracut
|
||||
check() {
|
||||
type -P gpg >/dev/null || return 1
|
||||
require_binaries gpg || return 1
|
||||
|
||||
return 255
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,27 @@
|
|||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
# called by dracut
|
||||
check() {
|
||||
type -P losetup >/dev/null || return 1
|
||||
|
||||
return 255
|
||||
require_binaries losetup || return 1
|
||||
|
||||
return 255
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
depends() {
|
||||
echo crypt
|
||||
echo crypt
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
installkernel() {
|
||||
instmods loop
|
||||
instmods loop
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
install() {
|
||||
inst_multiple losetup
|
||||
inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
|
||||
dracut_need_initqueue
|
||||
inst_multiple losetup
|
||||
inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
|
||||
dracut_need_initqueue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
# If our prerequisites are not met, fail anyways.
|
||||
type -P mount.cifs >/dev/null || return 1
|
||||
require_binaries mount.cifs || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
local _arch=$(uname -m)
|
||||
[ -x /sbin/normalize_dasd_arg ] || return 1
|
||||
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
|
||||
require_binaries normalize_dasd_arg || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
check() {
|
||||
local _arch=$(uname -m)
|
||||
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
|
||||
require_binaries grep sed seq
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
local _arch=$(uname -m)
|
||||
[ -x /sbin/dasd_configure ] || return 1
|
||||
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
|
||||
require_binaries dasd_configure /usr/lib/udev/collect || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
for i in dcbtool fipvlan lldpad ip readlink; do
|
||||
type -P $i >/dev/null || return 1
|
||||
done
|
||||
require_binaries dcbtool fipvlan lldpad ip readlink || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
for i in dcbtool fipvlan lldpad ip readlink; do
|
||||
type -P $i >/dev/null || return 1
|
||||
done
|
||||
|
||||
require_binaries dcbtool fipvlan lldpad ip readlink || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
check() {
|
||||
local _rootdev
|
||||
# If our prerequisites are not met, fail anyways.
|
||||
type -P iscsistart hostname iscsi-iname >/dev/null || return 1
|
||||
require_binaries iscsistart hostname iscsi-iname || return 1
|
||||
|
||||
# If hostonly was requested, fail the check if we are not actually
|
||||
# booting from root.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
check() {
|
||||
local _rootdev
|
||||
# If our prerequisites are not met, fail.
|
||||
type -P nbd-client >/dev/null || return 1
|
||||
require_binaries nbd-client || return 1
|
||||
|
||||
# if an nbd device is not somewhere in the chain of devices root is
|
||||
# mounted on, fail the hostonly check.
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
# If our prerequisites are not met, fail anyways.
|
||||
type -P rpcbind >/dev/null || type -P portmap >/dev/null || return 1
|
||||
type -P rpc.statd mount.nfs mount.nfs4 umount >/dev/null || return 1
|
||||
require_any_binary rpcbind portmap || return 1
|
||||
require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
# If our prerequisites are not met, fail.
|
||||
type -P ssh >/dev/null || return 1
|
||||
type -P scp >/dev/null || return 1
|
||||
[[ $mount_needs ]] && return 1
|
||||
|
||||
# If our prerequisites are not met, fail.
|
||||
require_binaries ssh scp || return 1
|
||||
|
||||
if [[ $sshkey ]]; then
|
||||
[ ! -f $sshkey ] && {
|
||||
derror "ssh key: $sshkey is not found!"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
install() {
|
||||
local _i
|
||||
|
||||
# Fixme: would be nice if we didn't have to know which rules to grab....
|
||||
# Fixme: would be nice if we didn't have to guess, which rules to grab....
|
||||
# ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
|
||||
# of the rules we want so that we just copy those in would be best
|
||||
inst_multiple udevadm cat uname blkid \
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
arch=$(uname -m)
|
||||
[ -x /sbin/zfcp_cio_free ] || return 1
|
||||
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
|
||||
|
||||
require_binaries zfcp_cio_free grep sed seq || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
local _arch=$(uname -m)
|
||||
[ -x /sbin/zfcp_disk_configure ] || return 1
|
||||
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] || return 1
|
||||
require_binaries zfcp_disk_configure /usr/lib/udev/collect || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
arch=$(uname -m)
|
||||
[ -z /sbin/znet_cio_free ] || return 1
|
||||
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
|
||||
|
||||
require_binaries znet_cio_free grep sed seq readlink || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
type -P biosdevname >/dev/null || return 1
|
||||
require_binaries biosdevname || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
[[ $hostonly ]] && {
|
||||
[ -x "/bin/keyctl" ] || return 1
|
||||
require_binaries keyctl uname || return 1
|
||||
}
|
||||
|
||||
return 255
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
# called by dracut
|
||||
check() {
|
||||
[[ $mount_needs ]] && return 1
|
||||
if [[ -x $systemdutildir/systemd ]]; then
|
||||
if require_binaries $systemdutildir/systemd; then
|
||||
SYSTEMD_VERSION=$($systemdutildir/systemd --version | { read a b a; echo $b; })
|
||||
(( $SYSTEMD_VERSION >= 198 )) && return 0
|
||||
return 255
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
# called by dracut
|
||||
check() {
|
||||
for cmd in tar gzip dd; do
|
||||
command -v $cmd >/dev/null || return 1
|
||||
done
|
||||
require_binaries tar gzip dd bash || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue