44. shell-error
55. shell-quote
66
7+ declare -A DIRS FILES LOCALFILES FEATUREFILES
8+
79FEATUREFILES=()
810LOCALFILES=()
911FILES=()
@@ -12,18 +14,6 @@ DIRS=()
1214LIB_PATHS=()
1315BIN_PATHS=()
1416
15- append_uniq ()
16- {
17- local arr i sz v
18- eval " sz=\$ {#$1 [*]}"
19- for (( i= 0 ; $i < $sz ; i++ )) ; do
20- eval " v=\"\$ {$1 [$i ]}\" "
21- [ " $v " != " $2 " ] ||
22- return 0
23- done
24- eval " $1 +=(\"\$ 2\" )"
25- }
26-
2717in_runtimedir ()
2818{
2919 local f=" ${1# $LOCALBUILDDIR } "
@@ -45,7 +35,7 @@ append_progs()
4535 continue
4636 if [ -z " ${n##/* } " ]; then
4737 message " WARNING: it doesn't make sense to search in PATH for a utility with absolute path: $n "
48- append_uniq FILES " $n "
38+ FILES[ " $n " ]=1
4939 continue
5040 elif [ -z " ${n##*/* } " ]; then
5141 message " WARNING: it doesn't make sense to search in PATH for a utility with subpath: $n "
@@ -71,11 +61,11 @@ append_progs()
7161 # We put these utilities on a separate list because we need to
7262 # remove a prefix from them.
7363 if in_features_bindir " $f " ; then
74- append_uniq FEATUREFILES " $f "
64+ FEATUREFILES[ " $f " ]=1
7565 continue
7666 fi
7767
78- append_uniq FILES " $f "
68+ FILES[ " $f " ]=1
7969 done
8070}
8171
@@ -124,7 +114,7 @@ append_libs()
124114 continue
125115
126116 if [ -z " ${n##/* } " ]; then
127- append_uniq FILES " $n "
117+ FILES[ " $n " ]=1
128118 continue
129119 elif [ -z " ${n##*/* } " ]; then
130120 message " WARNING: it doesn't make sense to search in PATH for a library with subpath: $n "
@@ -153,7 +143,7 @@ append_libs()
153143 continue
154144 fi
155145
156- append_uniq FILES " $f "
146+ FILES[ " $f " ]=1
157147
158148 done
159149}
@@ -166,26 +156,19 @@ for n in \
166156 ${LOCALBUILDDIR: +" ${LOCALBUILDDIR-} $RUNTIMEDIR " } \
167157 ${PUT_FEATURE_DIRS-} $PUT_DIRS ;
168158do
169- append_uniq DIRS " $n "
159+ DIRS[ " $n " ]=1
170160done
171161
172- FILES+=(
173- " $UDEVD "
174- " $UDEVADM "
175- /lib/udev/ata_id
176- /lib/udev/cdrom_id
177- /lib/udev/scsi_id
178- )
179-
180162for n in \
181- /lib/udev/{edd_id,vol_id,path_id,usb_id,firmware} \
163+ " $UDEVD " " $UDEVADM " \
164+ /lib/udev/{ata_id,cdrom_id,scsi_id,edd_id,vol_id,path_id,usb_id,firmware} \
182165 $( find-terminfo linux) \
183166 /var/resolv \
184167 " $KERNEL_MODULES_DIR " /modules.{builtin,order,builtin.modinfo} \
185168 /etc/modprobe.conf;
186169do
187170 [ ! -e " $n " ] ||
188- append_uniq FILES " $n "
171+ FILES[ " $n " ]=1
189172done
190173
191174append_progs \
@@ -210,18 +193,18 @@ while read -d: -r n; do
210193 [ -z " ${bin## $pattern } " ] ||
211194 continue
212195 if [ -n " $LOCALBUILDDIR " ] && [ -z " ${bin## $LOCALBUILDDIR /* } " ]; then
213- append_uniq LOCALFILES " $bin "
196+ LOCALFILES[ " $bin " ]=1
214197 continue
215198 fi
216199 [ -n " ${bin## $RUNTIMEDIR /* } " ] ||
217200 continue
218- append_uniq FILES " $bin "
201+ FILES[ " $bin " ]=1
219202 done
220203 done < <( set +f; shopt -s nullglob dotglob; printf ' %s\n' " $n " /* )
221204done <<< " $BUILDDIR_PATH:$BUSYBOX_PATH:$SYSTEM_PATH"
222205
223206for n in ${PUT_FEATURE_FILES-} $PUT_FILES ; do
224- append_uniq FILES " $n "
207+ FILES[ " $n " ]=1
225208done
226209
227210cd " $ROOTDIR "
@@ -288,16 +271,16 @@ if [ -h /bin/sh ]; then
288271 ln_if_missing " $BASH " " .$f "
289272fi
290273
291- for f in " ${FEATUREFILES[@]} " ; do
274+ for f in " ${! FEATUREFILES[@]} " ; do
292275 n=" ${f# $LOCALBUILDDIR } "
293276 n=" ${n# $BIN_FEATURESDIR /*/ } "
294277 p=" ${f%/ $n } "
295278 put-file -r " $p " . " $f "
296279done
297280
298- printf ' %s\n' " ${DIRS[@]} " | xargs -r put-tree .
299- printf ' %s\n' " ${FILES[@]} " | xargs -r put-file .
300- printf ' %s\n' " ${LOCALFILES[@]} " | xargs -r put-file -r " $LOCALBUILDDIR " .
281+ printf ' %s\n' " ${! DIRS[@]} " | xargs -r put-tree .
282+ printf ' %s\n' " ${! FILES[@]} " | xargs -r put-file .
283+ printf ' %s\n' " ${! LOCALFILES[@]} " | xargs -r put-file -r " $LOCALBUILDDIR " .
301284
302285ln_if_missing " $UDEVD " ./sbin/udevd
303286ln_if_missing " $UDEVADM " ./sbin/udevadm
0 commit comments