4
4
. shell-error
5
5
. shell-quote
6
6
7
+ declare -A DIRS FILES LOCALFILES FEATUREFILES
8
+
7
9
FEATUREFILES=()
8
10
LOCALFILES=()
9
11
FILES=()
@@ -12,18 +14,6 @@ DIRS=()
12
14
LIB_PATHS=()
13
15
BIN_PATHS=()
14
16
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
-
27
17
in_runtimedir ()
28
18
{
29
19
local f=" ${1# $LOCALBUILDDIR } "
@@ -45,7 +35,7 @@ append_progs()
45
35
continue
46
36
if [ -z " ${n##/* } " ]; then
47
37
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
49
39
continue
50
40
elif [ -z " ${n##*/* } " ]; then
51
41
message " WARNING: it doesn't make sense to search in PATH for a utility with subpath: $n "
@@ -71,11 +61,11 @@ append_progs()
71
61
# We put these utilities on a separate list because we need to
72
62
# remove a prefix from them.
73
63
if in_features_bindir " $f " ; then
74
- append_uniq FEATUREFILES " $f "
64
+ FEATUREFILES[ " $f " ]=1
75
65
continue
76
66
fi
77
67
78
- append_uniq FILES " $f "
68
+ FILES[ " $f " ]=1
79
69
done
80
70
}
81
71
@@ -124,7 +114,7 @@ append_libs()
124
114
continue
125
115
126
116
if [ -z " ${n##/* } " ]; then
127
- append_uniq FILES " $n "
117
+ FILES[ " $n " ]=1
128
118
continue
129
119
elif [ -z " ${n##*/* } " ]; then
130
120
message " WARNING: it doesn't make sense to search in PATH for a library with subpath: $n "
@@ -153,7 +143,7 @@ append_libs()
153
143
continue
154
144
fi
155
145
156
- append_uniq FILES " $f "
146
+ FILES[ " $f " ]=1
157
147
158
148
done
159
149
}
@@ -166,26 +156,19 @@ for n in \
166
156
${LOCALBUILDDIR: +" ${LOCALBUILDDIR-} $RUNTIMEDIR " } \
167
157
${PUT_FEATURE_DIRS-} $PUT_DIRS ;
168
158
do
169
- append_uniq DIRS " $n "
159
+ DIRS[ " $n " ]=1
170
160
done
171
161
172
- FILES+=(
173
- " $UDEVD "
174
- " $UDEVADM "
175
- /lib/udev/ata_id
176
- /lib/udev/cdrom_id
177
- /lib/udev/scsi_id
178
- )
179
-
180
162
for 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} \
182
165
$( find-terminfo linux) \
183
166
/var/resolv \
184
167
" $KERNEL_MODULES_DIR " /modules.{builtin,order,builtin.modinfo} \
185
168
/etc/modprobe.conf;
186
169
do
187
170
[ ! -e " $n " ] ||
188
- append_uniq FILES " $n "
171
+ FILES[ " $n " ]=1
189
172
done
190
173
191
174
append_progs \
@@ -210,18 +193,18 @@ while read -d: -r n; do
210
193
[ -z " ${bin## $pattern } " ] ||
211
194
continue
212
195
if [ -n " $LOCALBUILDDIR " ] && [ -z " ${bin## $LOCALBUILDDIR /* } " ]; then
213
- append_uniq LOCALFILES " $bin "
196
+ LOCALFILES[ " $bin " ]=1
214
197
continue
215
198
fi
216
199
[ -n " ${bin## $RUNTIMEDIR /* } " ] ||
217
200
continue
218
- append_uniq FILES " $bin "
201
+ FILES[ " $bin " ]=1
219
202
done
220
203
done < <( set +f; shopt -s nullglob dotglob; printf ' %s\n' " $n " /* )
221
204
done <<< " $BUILDDIR_PATH:$BUSYBOX_PATH:$SYSTEM_PATH"
222
205
223
206
for n in ${PUT_FEATURE_FILES-} $PUT_FILES ; do
224
- append_uniq FILES " $n "
207
+ FILES[ " $n " ]=1
225
208
done
226
209
227
210
cd " $ROOTDIR "
@@ -288,16 +271,16 @@ if [ -h /bin/sh ]; then
288
271
ln_if_missing " $BASH " " .$f "
289
272
fi
290
273
291
- for f in " ${FEATUREFILES[@]} " ; do
274
+ for f in " ${! FEATUREFILES[@]} " ; do
292
275
n=" ${f# $LOCALBUILDDIR } "
293
276
n=" ${n# $BIN_FEATURESDIR /*/ } "
294
277
p=" ${f%/ $n } "
295
278
put-file -r " $p " . " $f "
296
279
done
297
280
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 " .
301
284
302
285
ln_if_missing " $UDEVD " ./sbin/udevd
303
286
ln_if_missing " $UDEVADM " ./sbin/udevadm
0 commit comments