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