summaryrefslogtreecommitdiff
path: root/sys-kernel/dracut/files/050-busybox-module-fix.patch
blob: faaf026e536a19634aac367e1ae4fb0884b74d0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From f769154bccf22d2b5caf5e4888f88bf7edde2662 Mon Sep 17 00:00:00 2001
From: Alexander Tsoy <alexander@tsoy.me>
Date: Mon, 25 May 2020 19:02:05 +0300
Subject: [PATCH 1/2] dracut-functions: fix find_binary() to return full path

Fixes: a01204202b30 (Allow running on a cross-compiled rootfs)
---
 dracut-functions.sh | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index 3cb9c7af..b5c28248 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -41,31 +41,36 @@ str_ends() { [ "${1%*"$2"}" != "$1" ]; }
 # search in the usual places to find the binary.
 find_binary() {
     local _delim
+    local _path
     local l
     local p
     [[ -z ${1##/*} ]] || _delim="/"
 
     if [[ "$1" == *.so* ]]; then
         for l in libdirs ; do
-            if { $DRACUT_LDD "$dracutsysrootdir$l$_delim$1" &>/dev/null; };  then
-                printf "%s\n" "$1"
+            _path="${l}${_delim}${1}"
+            if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; };  then
+                printf "%s\n" "${_path}"
                 return 0
             fi
         done
-        if { $DRACUT_LDD "$dracutsysrootdir$_delim$1" &>/dev/null; }; then
-            printf "%s\n" "$1"
+        _path="${_delim}${1}"
+        if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
+            printf "%s\n" "${_path}"
             return 0
         fi
     fi
     if [[ "$1" == */* ]]; then
-        if [[ -L $dracutsysrootdir$_delim$1 ]] || [[ -x $dracutsysrootdir$_delim$1 ]]; then
-            printf "%s\n" "$1"
+        _path="${_delim}${1}"
+        if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
+            printf "%s\n" "${_path}"
             return 0
         fi
     fi
     for p in $DRACUT_PATH ; do
-        if [[ -L $dracutsysrootdir$p$_delim$1 ]] || [[ -x $dracutsysrootdir$p$_delim$1 ]];  then
-            printf "%s\n" "$1"
+        _path="${p}${_delim}${1}"
+        if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]];  then
+            printf "%s\n" "${_path}"
             return 0
         fi
     done
-- 
2.26.2

From 50cc23ba32b0fda63eff7623b529dbeb4e6a38c6 Mon Sep 17 00:00:00 2001
From: Alexander Tsoy <alexander@tsoy.me>
Date: Mon, 25 May 2020 17:49:20 +0300
Subject: [PATCH 2/2] busybox: simplify listing of supported utilities

'--list' option is supported since busybox-1.20.0, which was released
in 2010.
---
 modules.d/05busybox/module-setup.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/modules.d/05busybox/module-setup.sh b/modules.d/05busybox/module-setup.sh
index ecbd6a13..5d88c5d1 100755
--- a/modules.d/05busybox/module-setup.sh
+++ b/modules.d/05busybox/module-setup.sh
@@ -14,15 +14,16 @@ depends() {
 
 # called by dracut
 install() {
-    local _i _progs _path _busybox
+    local _i _path _busybox
+    local _progs=()
     _busybox=$(type -P busybox)
     inst $_busybox /usr/bin/busybox
-    for _i in $($_busybox | sed -ne '1,/Currently/!{s/,//g; s/busybox//g; p}')
-    do
-        _progs="$_progs $_i"
+    for _i in $($_busybox --list); do
+        [[ ${_i} == busybox ]] && continue
+        _progs+=("${_i}")
     done
 
-    for _i in $_progs; do
+    for _i in "${_progs[@]}"; do
         _path=$(find_binary "$_i")
         [ -z "$_path" ] && continue
         ln_r /usr/bin/busybox $_path
-- 
2.26.2