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