28ab1c
From 47bc3efe3e3d2b97b4a47e9380c061db0bc368c6 Mon Sep 17 00:00:00 2001
28ab1c
From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= <zboszor@pr.hu>
28ab1c
Date: Sun, 7 Feb 2021 15:01:49 +0100
28ab1c
Subject: [PATCH] fix: use find_binary
28ab1c
MIME-Version: 1.0
28ab1c
Content-Type: text/plain; charset=UTF-8
28ab1c
Content-Transfer-Encoding: 8bit
28ab1c
28ab1c
Use find_binary instead of type -P because the former works if
28ab1c
dracutsysrootdir is set.
28ab1c
28ab1c
Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
28ab1c
(cherry picked from commit 433a9ec0147e578b91b4c6e20629a0dbeb9d0725)
28ab1c
28ab1c
Resolves: #1959336
28ab1c
---
28ab1c
 modules.d/00systemd/module-setup.sh   | 4 ++--
28ab1c
 modules.d/02caps/module-setup.sh      | 2 +-
28ab1c
 modules.d/05busybox/module-setup.sh   | 2 +-
28ab1c
 modules.d/50gensplash/module-setup.sh | 2 +-
28ab1c
 modules.d/50plymouth/module-setup.sh  | 2 +-
28ab1c
 modules.d/90lvm/module-setup.sh       | 2 +-
28ab1c
 modules.d/98syslog/module-setup.sh    | 6 +++---
28ab1c
 modules.d/99memstrack/module-setup.sh | 2 +-
28ab1c
 modules.d/99squash/module-setup.sh    | 2 +-
28ab1c
 9 files changed, 12 insertions(+), 12 deletions(-)
28ab1c
28ab1c
diff --git a/modules.d/00systemd/module-setup.sh b/modules.d/00systemd/module-setup.sh
28ab1c
index 1f0b5dad..38c244a2 100755
28ab1c
--- a/modules.d/00systemd/module-setup.sh
28ab1c
+++ b/modules.d/00systemd/module-setup.sh
28ab1c
@@ -209,8 +209,8 @@ install() {
28ab1c
     ln_r $systemdutildir/systemd "/sbin/init"
28ab1c
 
28ab1c
     inst_binary true
28ab1c
-    ln_r $(type -P true) "/usr/bin/loginctl"
28ab1c
-    ln_r $(type -P true) "/bin/loginctl"
28ab1c
+    ln_r $(find_binary true) "/usr/bin/loginctl"
28ab1c
+    ln_r $(find_binary true) "/bin/loginctl"
28ab1c
     inst_rules \
28ab1c
         70-uaccess.rules \
28ab1c
         71-seat.rules \
28ab1c
diff --git a/modules.d/02caps/module-setup.sh b/modules.d/02caps/module-setup.sh
28ab1c
index fb16526a..d1ce6cdc 100755
28ab1c
--- a/modules.d/02caps/module-setup.sh
28ab1c
+++ b/modules.d/02caps/module-setup.sh
28ab1c
@@ -15,7 +15,7 @@ depends() {
28ab1c
 install() {
28ab1c
     if ! dracut_module_included "systemd"; then
28ab1c
         inst_hook pre-pivot 00 "$moddir/caps.sh"
28ab1c
-        inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
28ab1c
+        inst $(find_binary capsh 2>/dev/null) /usr/sbin/capsh
28ab1c
         # capsh wants bash and we need bash also
28ab1c
         inst /bin/bash
28ab1c
     else
28ab1c
diff --git a/modules.d/05busybox/module-setup.sh b/modules.d/05busybox/module-setup.sh
28ab1c
index 5d88c5d1..20b36c16 100755
28ab1c
--- a/modules.d/05busybox/module-setup.sh
28ab1c
+++ b/modules.d/05busybox/module-setup.sh
28ab1c
@@ -16,7 +16,7 @@ depends() {
28ab1c
 install() {
28ab1c
     local _i _path _busybox
28ab1c
     local _progs=()
28ab1c
-    _busybox=$(type -P busybox)
28ab1c
+    _busybox=$(find_binary busybox)
28ab1c
     inst $_busybox /usr/bin/busybox
28ab1c
     for _i in $($_busybox --list); do
28ab1c
         [[ ${_i} == busybox ]] && continue
28ab1c
diff --git a/modules.d/50gensplash/module-setup.sh b/modules.d/50gensplash/module-setup.sh
28ab1c
index d2fccc26..d0aa4a78 100755
28ab1c
--- a/modules.d/50gensplash/module-setup.sh
28ab1c
+++ b/modules.d/50gensplash/module-setup.sh
28ab1c
@@ -40,7 +40,7 @@ install() {
28ab1c
         return ${_ret}
28ab1c
     }
28ab1c
 
28ab1c
-    type -P splash_geninitramfs >/dev/null || return 1
28ab1c
+    find_binary splash_geninitramfs >/dev/null || return 1
28ab1c
 
28ab1c
     _opts=''
28ab1c
     if [[ ${DRACUT_GENSPLASH_THEME} ]]; then
28ab1c
diff --git a/modules.d/50plymouth/module-setup.sh b/modules.d/50plymouth/module-setup.sh
28ab1c
index b51913e8..0568d21c 100755
28ab1c
--- a/modules.d/50plymouth/module-setup.sh
28ab1c
+++ b/modules.d/50plymouth/module-setup.sh
28ab1c
@@ -2,7 +2,7 @@
28ab1c
 
28ab1c
 pkglib_dir() {
28ab1c
     local _dirs="/usr/lib/plymouth /usr/libexec/plymouth/"
28ab1c
-    if type -P dpkg-architecture &>/dev/null; then
28ab1c
+    if find_binary dpkg-architecture &>/dev/null; then
28ab1c
         _dirs+=" /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/plymouth"
28ab1c
     fi
28ab1c
     for _dir in $_dirs; do
28ab1c
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
28ab1c
index 6ca4ee44..fffcbe31 100755
28ab1c
--- a/modules.d/90lvm/module-setup.sh
28ab1c
+++ b/modules.d/90lvm/module-setup.sh
28ab1c
@@ -119,7 +119,7 @@ install() {
28ab1c
 
28ab1c
     inst_libdir_file "libdevmapper-event-lvm*.so"
28ab1c
 
28ab1c
-    if [[ $hostonly ]] && type -P lvs &>/dev/null; then
28ab1c
+    if [[ $hostonly ]] && find_binary lvs &>/dev/null; then
28ab1c
         for dev in "${!host_fs_types[@]}"; do
28ab1c
             [ -e /sys/block/${dev#/dev/}/dm/name ] || continue
28ab1c
             dev=$(
28ab1c
diff --git a/modules.d/98syslog/module-setup.sh b/modules.d/98syslog/module-setup.sh
28ab1c
index aa0c8eaf..2435c4d5 100755
28ab1c
--- a/modules.d/98syslog/module-setup.sh
28ab1c
+++ b/modules.d/98syslog/module-setup.sh
28ab1c
@@ -15,12 +15,12 @@ depends() {
28ab1c
 install() {
28ab1c
     local _i
28ab1c
     local _installs
28ab1c
-    if type -P rsyslogd >/dev/null; then
28ab1c
+    if find_binary rsyslogd >/dev/null; then
28ab1c
         _installs="rsyslogd"
28ab1c
         inst_libdir_file rsyslog/lmnet.so rsyslog/imklog.so rsyslog/imuxsock.so rsyslog/imjournal.so
28ab1c
-    elif type -P syslogd >/dev/null; then
28ab1c
+    elif find_binary syslogd >/dev/null; then
28ab1c
         _installs="syslogd"
28ab1c
-    elif type -P syslog-ng >/dev/null; then
28ab1c
+    elif find_binary syslog-ng >/dev/null; then
28ab1c
         _installs="syslog-ng"
28ab1c
     else
28ab1c
         derror "Could not find any syslog binary although the syslogmodule" \
28ab1c
diff --git a/modules.d/99memstrack/module-setup.sh b/modules.d/99memstrack/module-setup.sh
28ab1c
index d5bacb4d..e156290c 100755
28ab1c
--- a/modules.d/99memstrack/module-setup.sh
28ab1c
+++ b/modules.d/99memstrack/module-setup.sh
28ab1c
@@ -1,7 +1,7 @@
28ab1c
 #!/usr/bin/bash
28ab1c
 
28ab1c
 check() {
28ab1c
-    if type -P memstrack >/dev/null; then
28ab1c
+    if find_binary memstrack >/dev/null; then
28ab1c
         dinfo "memstrack is available"
28ab1c
         return 0
28ab1c
     fi
28ab1c
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
28ab1c
index d3680d63..b183daf7 100644
28ab1c
--- a/modules.d/99squash/module-setup.sh
28ab1c
+++ b/modules.d/99squash/module-setup.sh
28ab1c
@@ -6,7 +6,7 @@ check() {
28ab1c
         return 1
28ab1c
     fi
28ab1c
 
28ab1c
-    if ! type -P mksquashfs >/dev/null || ! type -P unsquashfs >/dev/null ; then
28ab1c
+    if ! find_binary mksquashfs >/dev/null || ! find_binary unsquashfs >/dev/null ; then
28ab1c
         derror "dracut-squash module requires squashfs-tools"
28ab1c
         return 1
28ab1c
     fi
28ab1c