commit 92b96df
chld
·
2026-08-23 23:09:27 +0000 UTC
parent 2870a74
toybox: import
4 files changed,
+753,
-0
+1,
-0
1@@ -0,0 +1 @@
2+.linux-headers
+6,
-0
1@@ -0,0 +1,6 @@
2+name: toybox
3+description:
4+license:
5+upstream: https://github.com/landley/toybox
6+version: git
7+maintainer:
+12,
-0
1@@ -0,0 +1,12 @@
2+#!/bin/sh -ue
3+NAME=toybox
4+VERSION=git
5+RELEASE=1
6+SOURCE="https://github.com/landley/toybox.git"
7+BUILD_STYLE=gmake
8+build(){
9+ gmake defconfig || die "defconfig failed"
10+ gmake PREFIX="$PKG" || die "gmake failed"
11+ gmake DESTDIR="$DESTDIR" install || die "install failed"
12+}
13+. ${0%/*}/../../libsh/libdmake.sh
+734,
-0
1@@ -0,0 +1,734 @@
2+This patch is the work of E5ten; Landley doesn't want toybox to be POSIX because
3+he's writing his own sh (toysh), and somehow that means the build system
4+shouldn't be buildable outside of toybox bootstrapping itself.
5+https://github.com/landley/toybox/pull/182
6+diff --git a/configure b/configure
7+index 0b6501fc..23dd687d 100755
8+--- a/configure
9++++ b/configure
10+@@ -1,10 +1,10 @@
11+-#!/bin/bash
12++#!/bin/sh
13+
14+ # This sets environment variables used by scripts/make.sh
15+
16+ # People run ./configure out of habit, so do "defconfig" for them.
17+
18+-if [ "$(basename "$0")" == configure ]
19++if [ "${0##*/}" = configure ]
20+ then
21+ echo "Assuming you want 'make defconfig', but you should probably check the README."
22+ make defconfig
23+diff --git a/scripts/bloatcheck b/scripts/bloatcheck
24+index fff4690f..30492c64 100755
25+--- a/scripts/bloatcheck
26++++ b/scripts/bloatcheck
27+@@ -1,4 +1,4 @@
28+-#!/bin/bash
29++#!/bin/sh
30+
31+ if [ $# -ne 2 ]
32+ then
33+@@ -40,7 +40,7 @@ do_bloatcheck()
34+ fi
35+
36+ SIZE=$(printf "%d" "0x$b")
37+- if [ "$a" == "-" ]
38++ if [ "$a" = "-" ]
39+ then
40+ OLD=$(($OLD+$SIZE))
41+ SIZE=$((-1*$SIZE))
42+diff --git a/scripts/change.sh b/scripts/change.sh
43+index 99dcfde9..b1fa62a0 100755
44+--- a/scripts/change.sh
45++++ b/scripts/change.sh
46+@@ -1,4 +1,4 @@
47+-#!/bin/bash
48++#!/bin/sh
49+
50+ # build each command as a standalone executable
51+
52+@@ -14,8 +14,8 @@ mkdir -p "$PREFIX" || exit 1
53+
54+ for i in $(generated/instlist | egrep -vw "sh|help")
55+ do
56+- echo -n " $i" &&
57++ printf ' %s' "$i" &&
58+ scripts/single.sh $i > /dev/null 2>$PREFIX/${i}.bad &&
59+- rm $PREFIX/${i}.bad || echo -n '*'
60++ rm $PREFIX/${i}.bad || printf '*'
61+ done
62+ echo
63+diff --git a/scripts/findglobals.sh b/scripts/findglobals.sh
64+index 2c63164b..9455bc61 100755
65+--- a/scripts/findglobals.sh
66++++ b/scripts/findglobals.sh
67+@@ -1,4 +1,4 @@
68+-#!/bin/bash
69++#!/bin/sh
70+
71+ # Quick and dirty check to see if anybody's leaked global variables.
72+ # We should have this, toy_list, toybuf, and toys.
73+diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
74+index 955c82cd..b5cff559 100755
75+--- a/scripts/genconfig.sh
76++++ b/scripts/genconfig.sh
77+@@ -1,11 +1,11 @@
78+-#!/bin/bash
79++#!/bin/sh
80+
81+ # This has to be a separate file from scripts/make.sh so it can be called
82+ # before menuconfig. (It's called again from scripts/make.sh just to be sure.)
83+
84+ mkdir -p generated
85+
86+-source scripts/portability.sh
87++. scripts/portability.sh
88+
89+ probecc()
90+ {
91+@@ -18,8 +18,8 @@ probesymbol()
92+ {
93+ probecc $2 2>/dev/null && DEFAULT=y || DEFAULT=n
94+ rm a.out 2>/dev/null
95+- echo -e "config $1\n\tbool" || exit 1
96+- echo -e "\tdefault $DEFAULT\n" || exit 1
97++ printf 'config %s\n\tbool' || exit 1
98++ printf '\tdefault %s\n\n' || exit 1
99+ }
100+
101+ probeconfig()
102+@@ -28,7 +28,7 @@ probeconfig()
103+ # llvm produces its own really stupid warnings about things that aren't wrong,
104+ # and although you can turn the warning off, gcc reacts badly to command line
105+ # arguments it doesn't understand. So probe.
106+- [ -z "$(probecc -Wno-string-plus-int <<< \#warn warn 2>&1 | grep string-plus-int)" ] &&
107++ [ -z "$(echo '#warn' | probecc -Wno-string-plus-int warn 2>&1 | grep string-plus-int)" ] &&
108+ echo -Wno-string-plus-int >> generated/cflags
109+
110+ # Probe for container support on target
111+@@ -92,7 +92,7 @@ EOF
112+ #include <unistd.h>
113+ int main(int argc, char *argv[]) { return fork(); }
114+ EOF
115+- echo -e '\tdepends on !TOYBOX_FORCE_NOMMU'
116++ printf '\tdepends on !TOYBOX_FORCE_NOMMU\n'
117+
118+ probesymbol TOYBOX_PRLIMIT << EOF
119+ #include <sys/types.h>
120+@@ -155,17 +155,18 @@ PENDING=
121+ toys toys/*/*.c | (
122+ while IFS=":" read FILE NAME
123+ do
124+- [ "$NAME" == help ] && continue
125+- [ "$NAME" == install ] && continue
126+- [ "$NAME" == sh ] && FILE="toys/*/*.c"
127+- echo -e "$NAME: $FILE *.[ch] lib/*.[ch]\n\tscripts/single.sh $NAME\n"
128+- echo -e "test_$NAME:\n\tscripts/test.sh $NAME\n"
129+- [ "${FILE/pending//}" != "$FILE" ] &&
130++ [ "$NAME" = help ] && continue
131++ [ "$NAME" = install ] && continue
132++ [ "$NAME" = sh ] && FILE="toys/*/*.c"
133++ printf '%s: %s *.[ch] lib/*.[ch]\n\tscripts/single.sh %s\n\n' \
134++ "$NAME" "$FILE" "$NAME"
135++ printf 'test_%s:\n\tscripts/test.sh \n\n' "$NAME" "$NAME"
136++ [ "${FILE#*pending}" != "$FILE" ] &&
137+ PENDING="$PENDING $NAME" ||
138+ WORKING="$WORKING $NAME"
139+ done &&
140+-echo -e "clean::\n\t@rm -f $WORKING $PENDING" &&
141+-echo -e "list:\n\t@echo $(echo $WORKING | tr ' ' '\n' | sort | xargs)" &&
142+-echo -e "list_pending:\n\t@echo $(echo $PENDING | tr ' ' '\n' | sort | xargs)" &&
143+-echo -e ".PHONY: $WORKING $PENDING" | $SED 's/ \([^ ]\)/ test_\1/g'
144++printf 'clean::\n\t@rm -f %s %s\n' "$WORKING" "$PENDING" &&
145++printf 'list:\n\t@echo %s\n' "$(echo $WORKING | tr ' ' '\n' | sort | xargs)" &&
146++printf 'list_pending:\n\t@echo %s\n' "$(echo $PENDING | tr ' ' '\n' | sort | xargs)" &&
147++echo ".PHONY: $WORKING $PENDING" | $SED 's/ \([^ ]\)/ test_\1/g'
148+ ) > .singlemake
149+diff --git a/scripts/install.sh b/scripts/install.sh
150+index 648a2411..0ee232cd 100755
151+--- a/scripts/install.sh
152++++ b/scripts/install.sh
153+@@ -1,8 +1,8 @@
154+-#!/bin/bash
155++#!/bin/sh
156+
157+ # Grab default values for $CFLAGS and such.
158+
159+-source ./configure
160++. ./configure
161+
162+ [ -z "$PREFIX" ] && PREFIX="/usr/toybox"
163+
164+@@ -12,19 +12,19 @@ LONG_PATH=""
165+ while [ ! -z "$1" ]
166+ do
167+ # Create symlinks instead of hardlinks?
168+- [ "$1" == "--symlink" ] && LINK_TYPE="-s"
169++ [ "$1" = "--symlink" ] && LINK_TYPE="-s"
170+
171+ # Uninstall?
172+- [ "$1" == "--uninstall" ] && UNINSTALL=Uninstall
173++ [ "$1" = "--uninstall" ] && UNINSTALL=Uninstall
174+
175+ # Delete destination command if it exists?
176+- [ "$1" == "--force" ] && DO_FORCE="-f"
177++ [ "$1" = "--force" ] && DO_FORCE="-f"
178+
179+ # Use {,usr}/{bin,sbin} paths instead of all files in one directory?
180+- [ "$1" == "--long" ] && LONG_PATH="bin/"
181++ [ "$1" = "--long" ] && LONG_PATH="bin/"
182+
183+ # Symlink host toolchain binaries to destination to create cross compile $PATH
184+- [ "$1" == "--airlock" ] && AIRLOCK=1
185++ [ "$1" = "--airlock" ] && AIRLOCK=1
186+
187+ shift
188+ done
189+@@ -131,7 +131,7 @@ do
190+ fi
191+
192+ X=$[$X+1]
193+- FALLBACK="$PREFIX/fallback-$X"
194++ FALLBACK="$PREFIX/fallback-$((X += 1))"
195+ done
196+
197+ if [ ! -f "$PREFIX/$i" ]
198+diff --git a/scripts/make.sh b/scripts/make.sh
199+index 5b2d5d81..68fcbc2d 100755
200+--- a/scripts/make.sh
201++++ b/scripts/make.sh
202+@@ -1,4 +1,4 @@
203+-#!/bin/bash
204++#!/bin/sh
205+
206+ # Grab default values for $CFLAGS and such.
207+
208+@@ -16,8 +16,7 @@ fi
209+
210+ export LANG=c
211+ export LC_ALL=C
212+-set -o pipefail
213+-source scripts/portability.sh
214++. scripts/portability.sh
215+
216+ [ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=.config
217+ [ -z "$OUTNAME" ] && OUTNAME=toybox"${TARGET:+-$TARGET}"
218+@@ -31,7 +30,7 @@ UNSTRIPPED="generated/unstripped/$(basename "$OUTNAME")"
219+ DOTPROG=
220+ do_loudly()
221+ {
222+- [ ! -z "$V" ] && echo "$@" || echo -n "$DOTPROG"
223++ [ ! -z "$V" ] && echo "$@" || printf '%s' "$DOTPROG"
224+ "$@"
225+ }
226+
227+@@ -60,7 +59,7 @@ fi
228+
229+ if isnewer generated/newtoys.h toys
230+ then
231+- echo -n "generated/newtoys.h "
232++ printf 'generated/newtoys.h '
233+
234+ echo "USE_TOYBOX(NEWTOY(toybox, NULL, TOYFLAG_STAYROOT))" > generated/newtoys.h
235+ $SED -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \
236+@@ -83,9 +82,9 @@ BUILD="$(echo ${CROSS_COMPILE}${CC} $CFLAGS -I . $OPTIMIZE $GITHASH)"
237+ LIBFILES="$(ls lib/*.c | grep -v lib/help.c)"
238+ TOYFILES="lib/help.c main.c $TOYFILES"
239+
240+-if [ "${TOYFILES/pending//}" != "$TOYFILES" ]
241++if [ "${TOYFILES#*pending}" != "$TOYFILES" ]
242+ then
243+- echo -e "\n\033[1;31mwarning: using unfinished code from toys/pending\033[0m"
244++ printf '\n\033[1;31mwarning: using unfinished code from toys/pending\033[0m\n'
245+ fi
246+
247+ genbuildsh()
248+@@ -106,10 +105,10 @@ genbuildsh()
249+ echo '$BUILD $FILES $LINK'
250+ }
251+
252+-if ! cmp -s <(genbuildsh 2>/dev/null | head -n 6 ; echo LINK="'"$LDOPTIMIZE $LDFLAGS) \
253+- <(head -n 7 generated/build.sh 2>/dev/null | $SED '7s/ -o .*//')
254++if [ "$(genbuildsh 2>/dev/null | head -n 6 ; echo LINK="'"$LDOPTIMIZE $LDFLAGS)" != \
255++ "$(head -n 7 generated/build.sh 2>/dev/null | $SED '7s/ -o .*//')" ]
256+ then
257+- echo -n "Library probe"
258++ printf 'Library probe'
259+
260+ # We trust --as-needed to remove each library if we don't use any symbols
261+ # out of it, this loop is because the compiler has no way to ignore a library
262+@@ -122,7 +121,7 @@ then
263+ echo "int main(int argc, char *argv[]) {return 0;}" | \
264+ ${CROSS_COMPILE}${CC} $CFLAGS $LDFLAGS -xc - -o generated/libprobe $LDASNEEDED -l$i > /dev/null 2>/dev/null &&
265+ echo -l$i >> generated/optlibs.dat
266+- echo -n .
267++ printf .
268+ done
269+ rm -f generated/libprobe
270+ echo
271+@@ -185,7 +184,7 @@ make_flagsh()
272+
273+ echo "#define NEWTOY(aa,bb,cc) aa $I bb"
274+ echo '#define OLDTOY(...)'
275+- if [ "$I" == A ]
276++ if [ "$I" = A ]
277+ then
278+ cat generated/config.h
279+ else
280+@@ -215,13 +214,13 @@ make_flagsh()
281+
282+ if isnewer generated/flags.h toys "$KCONFIG_CONFIG"
283+ then
284+- echo -n "generated/flags.h "
285++ printf 'generated/flags.h '
286+ make_flagsh
287+ fi
288+
289+ # Extract global structure definitions and flag definitions from toys/*/*.c
290+
291+-function getglobals()
292++getglobals()
293+ {
294+ for i in toys/*/*.c
295+ do
296+@@ -230,13 +229,13 @@ function getglobals()
297+ -e 's/^GLOBALS(/struct '"$NAME"'_data {/' \
298+ -e 's/^)/};/' -e 'p' $i)"
299+
300+- [ ! -z "$DATA" ] && echo -e "// $i\n\n$DATA\n"
301++ [ ! -z "$DATA" ] && printf '// %s\n\n%s\n\n' "$i" "$DATA"
302+ done
303+ }
304+
305+ if isnewer generated/globals.h toys
306+ then
307+- echo -n "generated/globals.h "
308++ printf 'generated/globals.h '
309+ GLOBSTRUCT="$(getglobals)"
310+ (
311+ echo "$GLOBSTRUCT"
312+@@ -255,7 +254,7 @@ fi
313+
314+ if isnewer generated/tags.h toys
315+ then
316+- echo -n "generated/tags.h "
317++ printf 'generated/tags.h '
318+
319+ $SED -n '/TAGGED_ARRAY(/,/^)/{s/.*TAGGED_ARRAY[(]\([^,]*\),/\1/;p}' \
320+ toys/*/*.c lib/*.c | generated/mktags > generated/tags.h
321+@@ -273,7 +272,7 @@ fi
322+
323+ [ ! -z "$NOBUILD" ] && exit 0
324+
325+-echo -n "Compile $OUTNAME"
326++printf 'Compile $OUTNAME'
327+ [ ! -z "$V" ] && echo
328+ DOTPROG=.
329+
330+@@ -286,7 +285,7 @@ if [ ! -e "$X" ] || [ ! -z "$(find toys -name "*.h" -newer "$X")" ]
331+ then
332+ rm -rf generated/obj && mkdir -p generated/obj || exit 1
333+ else
334+- rm -f generated/obj/{main,lib_help}.o || exit 1
335++ rm -f generated/obj/main.o generated/obj/lib_help.o || exit 1
336+ fi
337+
338+ # build each generated/obj/*.o file in parallel
339+@@ -299,9 +298,10 @@ CLICK=
340+
341+ for i in $LIBFILES click $TOYFILES
342+ do
343+- [ "$i" == click ] && CLICK=1 && continue
344++ [ "$i" = click ] && CLICK=1 && continue
345+
346+- X=${i/lib\//lib_}
347++ X="$i"
348++ [ "${X#*lib/}" = "$X" ] || X="${X%%lib/*}lib_${X#*lib/}"
349+ X=${X##*/}
350+ OUT="generated/obj/${X%%.c}.o"
351+ LNKFILES="$LNKFILES $OUT"
352+@@ -309,8 +309,9 @@ do
353+ # $LIBFILES doesn't need to be rebuilt if older than .config, $TOYFILES does
354+ # ($TOYFILES contents can depend on CONFIG symbols, lib/*.c never should.)
355+
356+- [ "$OUT" -nt "$i" ] && [ -z "$CLICK" -o "$OUT" -nt "$KCONFIG_CONFIG" ] &&
357+- continue
358++ [ -n "$(find "$OUT" -newer "$i" 2>/dev/null)" ] &&
359++ { [ -z "$CLICK" ] || [ -n "$(find "$OUT" -newer "$KCONFIG_CONFIG" 2>/dev/null)" ]; } &&
360++ continue
361+
362+ do_loudly $BUILD -c $i -o $OUT &
363+ PENDING="$PENDING $!"
364+diff --git a/scripts/mcm-buildall.sh b/scripts/mcm-buildall.sh
365+index cac41372..4075872f 100755
366+--- a/scripts/mcm-buildall.sh
367++++ b/scripts/mcm-buildall.sh
368+@@ -1,4 +1,4 @@
369+-#!/bin/bash
370++#!/bin/sh
371+
372+ # Script to build all cross and native compilers supported by musl-libc.
373+ # This isn't directly used by toybox, but is useful for testing.
374+@@ -22,7 +22,7 @@ BOOTSTRAP=i686-linux-musl
375+
376+ [ -z "$OUTPUT" ] && OUTPUT="$PWD/ccc"
377+
378+-if [ "$1" == clean ]
379++if [ "$1" = clean ]
380+ then
381+ rm -rf "$OUTPUT" host-* *.log
382+ make clean
383+@@ -38,7 +38,7 @@ make_toolchain()
384+ OUTPUT="$PWD/host-$TARGET"
385+ EXTRASUB=y
386+ else
387+- if [ "$TYPE" == static ]
388++ if [ "$TYPE" = static ]
389+ then
390+ HOST=$BOOTSTRAP
391+ [ "$TARGET" = "$HOST" ] && LP="$PWD/host-$HOST/bin:$LP"
392+@@ -53,7 +53,9 @@ make_toolchain()
393+ echo "no $TARGET-cc in $LP" && return
394+ fi
395+ COMMON_CONFIG="CC=\"$HOST-gcc -static --static\" CXX=\"$HOST-g++ -static --static\""
396+- export -n HOST
397++ _HOST="$HOST"
398++ unset HOST
399++ HOST="$_HOST"
400+ OUTPUT="$OUTPUT/${RENAME:-$TARGET}-$TYPE"
401+ fi
402+
403+@@ -66,7 +68,7 @@ make_toolchain()
404+ # Change title bar to say what we're currently building
405+
406+ echo === building $TARGET-$TYPE
407+- echo -en "\033]2;$TARGET-$TYPE\007"
408++ printf '\033]2;$TARGET-$TYPE\007' "$TARGET" "$TYPE"
409+
410+ rm -rf build/"$TARGET" "$OUTPUT" &&
411+ [ -z "$CPUS" ] && CPUS=$(($(nproc)+1))
412+@@ -76,10 +78,10 @@ make_toolchain()
413+ COMMON_CONFIG="CFLAGS=\"$CFLAGS -g0 -Os\" CXXFLAGS=\"$CXXFLAGS -g0 -Os\" LDFLAGS=\"$LDFLAGS -s\" $COMMON_CONFIG" \
414+ install -j$CPUS || exit 1
415+ set +x
416+- echo -e '#ifndef __MUSL__\n#define __MUSL__ 1\n#endif' \
417++ printf '#ifndef __MUSL__\n#define __MUSL__ 1\n#endif\n' \
418+ >> "$OUTPUT/${EXTRASUB:+$TARGET/}include/features.h"
419+
420+- if [ ! -z "$RENAME" ] && [ "$TYPE" == cross ]
421++ if [ ! -z "$RENAME" ] && [ "$TYPE" = cross ]
422+ then
423+ CONTEXT="output/$RENAME-cross/bin"
424+ for i in "$CONTEXT/$TARGET-"*
425+@@ -93,7 +95,7 @@ make_toolchain()
426+ # $BOOTSTRAP arch
427+ [ -z "$TYPE" ] && make clean
428+
429+- if [ "$TYPE" == native ]
430++ if [ "$TYPE" = native ]
431+ then
432+ # gcc looks in "../usr/include" but not "/bin/../include" (relative to the
433+ # executable). That means /usr/bin/gcc looks in /usr/usr/include, so that's
434+@@ -108,14 +110,14 @@ make_toolchain()
435+ # Expand compressed target into binutils/gcc "tuple" and call make_toolchain
436+ make_tuple()
437+ {
438+- PART1=${1/:*/}
439+- PART3=${1/*:/}
440+- PART2=${1:$((${#PART1}+1)):$((${#1}-${#PART3}-${#PART1}-2))}
441++ PART1=${1%%:*}
442++ PART3=${1##*:}
443++ PART2=${1#${PART1}:} PART2+${PART2%:${PART3}}
444+
445+ # Do we need to rename this toolchain after building it?
446+- RENAME=${PART1/*@/}
447+- [ "$RENAME" == "$PART1" ] && RENAME=
448+- PART1=${PART1/@*/}
449++ RENAME=${PART1##*@}
450++ [ "$RENAME" = "$PART1" ] && RENAME=
451++ PART1=${PART1%%@*}
452+ TARGET=${PART1}-linux-musl${PART2}
453+
454+ [ -z "$NOCLEAN" ] && rm -rf build
455+diff --git a/scripts/portability.sh b/scripts/portability.sh
456+index 618022c7..63dee932 100644
457+--- a/scripts/portability.sh
458++++ b/scripts/portability.sh
459+@@ -1,6 +1,6 @@
460+ # sourced to find alternate names for things
461+
462+-source configure
463++. ./configure
464+
465+ if [ -z "$(command -v "${CROSS_COMPILE}${CC}")" ]
466+ then
467+diff --git a/scripts/record-commands b/scripts/record-commands
468+index 8410966b..f49bcff9 100755
469+--- a/scripts/record-commands
470++++ b/scripts/record-commands
471+@@ -1,4 +1,4 @@
472+-#!/bin/bash
473++#!/bin/sh
474+
475+ # Set up command recording wrapper
476+
477+diff --git a/scripts/single.sh b/scripts/single.sh
478+index c40c6bcf..473bbdd4 100755
479+--- a/scripts/single.sh
480++++ b/scripts/single.sh
481+@@ -1,4 +1,4 @@
482+-#!/bin/bash
483++#!/bin/sh
484+
485+ # Build a standalone toybox command
486+
487+@@ -9,7 +9,7 @@ then
488+ fi
489+
490+ # Add trailing / to PREFIX when it's set but hasn't got one
491+-[ "$PREFIX" == "${PREFIX%/}" ] && PREFIX="${PREFIX:+$PREFIX/}"
492++[ "$PREFIX" = "${PREFIX%/}" ] && PREFIX="${PREFIX:+$PREFIX/}"
493+
494+ # Harvest TOYBOX_* symbols from .config
495+ if [ ! -e .config ]
496+@@ -24,7 +24,7 @@ touch -c .config
497+ export KCONFIG_CONFIG=.singleconfig
498+ for i in "$@"
499+ do
500+- echo -n "$i:"
501++ printf '%s:' "$i"
502+ TOYFILE="$(egrep -l "TOY[(]($i)[ ,]" toys/*/*.c)"
503+
504+ if [ -z "$TOYFILE" ]
505+@@ -37,7 +37,7 @@ do
506+
507+ DEPENDS=
508+ MPDEL=
509+- if [ "$i" == sh ]
510++ if [ "$i" = sh ]
511+ then
512+ DEPENDS="$(sed -n 's/USE_\([^(]*\)(NEWTOY([^,]*,.*TOYFLAG_MAYFORK.*/\1/p' toys/*/*.c)"
513+ else
514+--- a/scripts/mkroot.sh
515++++ b/scripts/mkroot.sh
516+@@ -6,7 +6,7 @@
517+
518+ # assign command line NAME=VALUE args to env vars, keeping rest as packages
519+ while [ $# -ne 0 ]; do
520+- [ "${1/=/}" != "$1" ] && eval "export ${1/=*/}=\"\${1#*=}\"" ||
521++ [ "${1#*=}" != "$1" ] && eval "export ${1%%=*}=\"\${1#*=}\"" ||
522+ { [ "$1" != '--' ] && PKG="${PKG:-plumbing} $1"; }
523+ shift
524+ done
525+@@ -13,6 +13,6 @@
526+
527+ die() { echo "$@" >&2; exit 1; }
528+-announce() { echo -e "\033]2;$CROSS $*\007\n=== $*"; }
529++announce() { printf '\033]2;%s %s\007\n=== %s\n' "$CROSS" "$*"; }
530+
531+ # Create target-independent working directories (cmdline can change locations)
532+ TOP="$PWD/root"
533+@@ -22,13 +22,13 @@
534+ if [ ! -z "$CROSS" ]; then
535+ [ ! -d "${CCC:=$PWD/ccc}" ] && die "No ccc symlink to compiler directory."
536+ CROSS_COMPILE="$(echo "$CCC/$CROSS"-*cross/bin/"$CROSS"*-cc | sed 's/cc$//')"
537+- if [ "${CROSS::3}" == all ]; then
538++ if [ "${CROSS::3}" = all ]; then
539+ for i in $(ls "$CCC" | sed -n 's/-.*//p' | sort -u | xargs); do
540+- { rm -f "$LOG/$i-log".{failed,success}
541+- "$0" "$@" CROSS=$i ; [ $? -eq 0 ] && mv "$LOG/$i".{txt,success}
542+- } |& tee "$LOG/$i.txt"
543++ { rm -f "$LOG/$i-logfailed" "$LOG/$i-log.success"
544++ "$0" "$@" CROSS=$i ; [ $? -eq 0 ] && mv "$LOG/$i.txt" "$LOG/$i.success"
545++ } 2>&1 | tee "$LOG/$i.txt"
546+ [ ! -e "$LOG/$i.success" ] &&
547+- { mv "$LOG/$i".{txt,failed};[ "$CROSS" != allnonstop ] && exit 1; }
548++ { mv "$LOG/$i.txt" "$LOG/$i.failed";[ "$CROSS" != allnonstop ] && exit 1; }
549+ done
550+ exit
551+ elif [ ! -e "${CROSS_COMPILE}cc" ]; then
552+@@ -37,8 +37,8 @@
553+ fi
554+ fi
555+
556+-${CROSS_COMPILE}cc --static -xc - -o /dev/null <<< "int main(void){return 0;}"||
557+- die "${CROSS_COMPILE}cc can't create static binaries"
558++! echo 'int main(void) {return 0;}' | cc --static -cx - -o /dev/null ||
559++ die "Warning: host compiler can't create static binaries." >&2; sleep 3
560+
561+ # Parse and sanity check $CROSS_COMPILE (if any)
562+ if [ ! -z "$CROSS_COMPILE" ]; then
563+@@ -45,6 +45,6 @@
564+ CROSS_PATH="$(dirname "$(which "${CROSS_COMPILE}cc")")"
565+ [ -z "$CROSS_PATH" ] && die "no ${CROSS_COMPILE}cc in path"
566+- : ${CROSS_BASE:=$(basename "$CROSS_COMPILE")} ${CROSS:=${CROSS_BASE/-*/}}
567++ : ${CROSS_BASE:=$(basename "$CROSS_COMPILE")} ${CROSS:=${CROSS_BASE/%%-*/}}
568+ fi
569+ echo "Building for ${CROSS:=host}"
570+
571+@@ -65,8 +65,10 @@
572+ fi
573+
574+ # Create new root filesystem's directory layout
575+-mkdir -p "$ROOT"/{etc,tmp,proc,sys,dev,home,mnt,root,usr/{bin,sbin,lib},var} &&
576+-chmod a+rwxt "$ROOT"/tmp && ln -s usr/{bin,sbin,lib} "$ROOT" || exit 1
577++mkdir -p "$ROOT/etc" "$ROOT/tmp" "$ROOT/proc" "$ROOT/sys" "$ROOT/dev" \
578++ "$ROOT/home" "$ROOT/mnt" "$ROOT/root" "$ROOT/usr/bin" "$ROOT/usr/sbin" \
579++ "$ROOT/usr/lib" "$ROOT/var"
580++chmod a+rwxt "$ROOT"/tmp && ln -s usr/bin usr/sbin usr/lib "$ROOT" || exit 1
581+
582+ # Write init script. Runs as pid 1 from initramfs to set up and hand off system.
583+ cat > "$ROOT"/init << 'EOF' &&
584+@@ -114,7 +116,7 @@
585+ guest:x:500:500:guest:/home/guest:/bin/sh
586+ nobody:x:65534:65534:nobody:/proc/self:/dev/null
587+ EOF
588+-echo -e 'root:x:0:\nguest:x:500:\nnobody:x:65534:' > "$ROOT"/etc/group || exit 1
589++printf 'root:x:0:\nguest:x:500:\nnobody:x:65534:\n' > "$ROOT"/etc/group || exit 1
590+
591+ # Build static toybox with existing .config if there is one, else defconfig+sh
592+ announce toybox
593+@@ -133,7 +135,7 @@
594+ else
595+ # Which architecture are we building a kernel for?
596+ LINUX="$(realpath "$LINUX")"
597+- [ -z "$TARGET" ] && TARGET="${CROSS_BASE/-*/}"
598++ [ -z "$TARGET" ] && TARGET="${CROSS_BASE%%-*/}"
599+ [ -z "$TARGET" ] && TARGET="$(uname -m)"
600+
601+ # Target-specific info in an (alphabetical order) if/else staircase
602+@@ -140,6 +142,6 @@
603+ # Each target needs board config, serial console, RTC, ethernet, block device.
604+
605+- if [ "$TARGET" == armv5l ]; then
606++ if [ "$TARGET" = armv5l ]; then
607+ # This could use the same VIRT board as armv7, but let's demonstrate a
608+ # different one requiring a separate device tree binary.
609+ QEMU="arm -M versatilepb -net nic,model=rtl8139 -net user"
610+@@ -147,8 +149,8 @@
611+ KCONF=CPU_ARM926T,MMU,VFP,ARM_THUMB,AEABI,ARCH_VERSATILE,ATAGS,DEPRECATED_PARAM_STRUCT,ARM_ATAG_DTB_COMPAT,ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND,SERIAL_AMBA_PL011,SERIAL_AMBA_PL011_CONSOLE,RTC_CLASS,RTC_DRV_PL031,RTC_HCTOSYS,PCI,PCI_VERSATILE,BLK_DEV_SD,SCSI,SCSI_LOWLEVEL,SCSI_SYM53C8XX_2,SCSI_SYM53C8XX_MMIO,NET_VENDOR_REALTEK,8139CP
612+ KERNEL_CONFIG="CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0"
613+ DTB=arch/arm/boot/dts/versatile-pb.dtb
614+- elif [ "$TARGET" == armv7l ] || [ "$TARGET" == aarch64 ]; then
615+- if [ "$TARGET" == aarch64 ]; then
616++ elif [ "$TARGET" = armv7l ] || [ "$TARGET" = aarch64 ]; then
617++ if [ "$TARGET" = aarch64 ]; then
618+ QEMU="aarch64 -M virt -cpu cortex-a57"
619+ KARCH=arm64 VMLINUX=arch/arm64/boot/Image
620+ else
621+@@ -156,11 +158,11 @@
622+ fi
623+ KARGS=ttyAMA0
624+ KCONF=MMU,ARCH_MULTI_V7,ARCH_VIRT,SOC_DRA7XX,ARCH_OMAP2PLUS_TYPICAL,ARCH_ALPINE,ARM_THUMB,VDSO,CPU_IDLE,ARM_CPUIDLE,KERNEL_MODE_NEON,SERIAL_AMBA_PL011,SERIAL_AMBA_PL011_CONSOLE,RTC_CLASS,RTC_HCTOSYS,RTC_DRV_PL031,NET_CORE,VIRTIO_MENU,VIRTIO_NET,PCI,PCI_HOST_GENERIC,VIRTIO_BLK,VIRTIO_PCI,VIRTIO_MMIO,ATA,ATA_SFF,ATA_BMDMA,ATA_PIIX,PATA_PLATFORM,PATA_OF_PLATFORM,ATA_GENERIC
625+- elif [ "$TARGET" == i486 ] || [ "$TARGET" == i686 ] ||
626+- [ "$TARGET" == x86_64 ] || [ "$TARGET" == x32 ]; then
627+- if [ "$TARGET" == i486 ]; then
628++ elif [ "$TARGET" = i486 ] || [ "$TARGET" = i686 ] ||
629++ [ "$TARGET" = x86_64 ] || [ "$TARGET" = x32 ]; then
630++ if [ "$TARGET" = i486 ]; then
631+ QEMU="i386 -cpu 486 -global fw_cfg.dma_enabled=false" KCONF=M486
632+- elif [ "$TARGET" == i686 ]; then
633++ elif [ "$TARGET" = i686 ]; then
634+ QEMU="i386 -cpu pentium3" KCONF=MPENTIUMII
635+ else
636+ QEMU=x86_64 KCONF=64BIT
637+@@ -167,4 +169,4 @@
638+- [ "$TARGET" == x32 ] && KCONF=X86_X32
639++ [ "$TARGET" = x32 ] && KCONF=X86_X32
640+ fi
641+ KARCH=x86 KARGS=ttyS0 VMLINUX=arch/x86/boot/bzImage
642+ KCONF=$KCONF,UNWINDER_FRAME_POINTER,PCI,BLK_DEV_SD,ATA,ATA_SFF,ATA_BMDMA,ATA_PIIX,NET_VENDOR_INTEL,E1000,SERIAL_8250,SERIAL_8250_CONSOLE,RTC_CLASS
643+@@ -171,15 +173,15 @@
644+- elif [ "$TARGET" == m68k ]; then
645++ elif [ "$TARGET" = m68k ]; then
646+ QEMU="m68k -M q800" KARCH=m68k KARGS=ttyS0 VMLINUX=vmlinux
647+ KCONF=MMU,M68040,M68KFPU_EMU,MAC,SCSI_MAC_ESP,MACINTOSH_DRIVERS,ADB,ADB_MACII,NET_CORE,MACSONIC,SERIAL_PMACZILOG,SERIAL_PMACZILOG_TTYS,SERIAL_PMACZILOG_CONSOLE
648+- elif [ "$TARGET" == mips ] || [ "$TARGET" == mipsel ]; then
649++ elif [ "$TARGET" = mips ] || [ "$TARGET" = mipsel ]; then
650+ QEMU="mips -M malta" KARCH=mips KARGS=ttyS0 VMLINUX=vmlinux
651+ KCONF=MIPS_MALTA,CPU_MIPS32_R2,SERIAL_8250,SERIAL_8250_CONSOLE,PCI,BLK_DEV_SD,ATA,ATA_SFF,ATA_BMDMA,ATA_PIIX,NET_VENDOR_AMD,PCNET32,POWER_RESET,POWER_RESET_SYSCON
652+- [ "$TARGET" == mipsel ] && KCONF=$KCONF,CPU_LITTLE_ENDIAN &&
653++ [ "$TARGET" = mipsel ] && KCONF=$KCONF,CPU_LITTLE_ENDIAN &&
654+ QEMU="mipsel -M malta"
655+- elif [ "$TARGET" == powerpc ]; then
656++ elif [ "$TARGET" = powerpc ]; then
657+ KARCH=powerpc QEMU="ppc -M g3beige" KARGS=ttyS0 VMLINUX=vmlinux
658+ KCONF=ALTIVEC,PPC_PMAC,PPC_OF_BOOT_TRAMPOLINE,IDE,IDE_GD,IDE_GD_ATA,BLK_DEV_IDE_PMAC,BLK_DEV_IDE_PMAC_ATA100FIRST,MACINTOSH_DRIVERS,ADB,ADB_CUDA,NET_VENDOR_NATSEMI,NET_VENDOR_8390,NE2K_PCI,SERIO,SERIAL_PMACZILOG,SERIAL_PMACZILOG_TTYS,SERIAL_PMACZILOG_CONSOLE,BOOTX_TEXT
659+- elif [ "$TARGET" == powerpc64le ]; then
660++ elif [ "$TARGET" = powerpc64le ]; then
661+ KARCH=powerpc QEMU="ppc64 -M pseries -vga none" KARGS=hvc0
662+ VMLINUX=vmlinux
663+ KCONF=PPC64,PPC_PSERIES,CPU_LITTLE_ENDIAN,PPC_OF_BOOT_TRAMPOLINE,BLK_DEV_SD,SCSI_LOWLEVEL,SCSI_IBMVSCSI,ATA,NET_VENDOR_IBM,IBMVETH,HVC_CONSOLE,PPC_TRANSACTIONAL_MEM,PPC_DISABLE_WERROR,SECTION_MISMATCH_WARN_ONLY
664+@@ -186,7 +188,7 @@
665+ elif [ "$TARGET" = s390x ]; then
666+ QEMU="s390x" KARCH=s390 VMLINUX=arch/s390/boot/bzImage
667+ KCONF=MARCH_Z900,PACK_STACK,NET_CORE,VIRTIO_NET,VIRTIO_BLK,SCLP_TTY,SCLP_CONSOLE,SCLP_VT220_TTY,SCLP_VT220_CONSOLE,S390_GUEST
668+- elif [ "$TARGET" == sh2eb ]; then
669++ elif [ "$TARGET" = sh2eb ]; then
670+ KARCH=sh VMLINUX=vmlinux KERNEL_CONFIG='CONFIG_MEMORY_START=0x10000000
671+ CONFIG_CMDLINE="console=ttyUL0 earlycon"' BUILTIN=1
672+ KCONF=CPU_SUBTYPE_J2,CPU_BIG_ENDIAN,SH_JCORE_SOC,SMP,BINFMT_ELF_FDPIC,JCORE_EMAC,SERIAL_UARTLITE,SERIAL_UARTLITE_CONSOLE,HZ_100,CMDLINE_OVERWRITE,SPI,SPI_JCORE,MMC,PWRSEQ_SIMPLE,MMC_BLOCK,MMC_SPI
673+@@ -193,4 +195,4 @@
674+- elif [ "$TARGET" == sh4 ]; then
675++ elif [ "$TARGET" = sh4 ]; then
676+ QEMU="sh4 -M r2d -serial null -serial mon:stdio" KARCH=sh
677+ KARGS="ttySC1 noiotrap" VMLINUX=arch/sh/boot/zImage
678+ KERNEL_CONFIG="CONFIG_MEMORY_START=0x0c000000"
679+@@ -205,7 +207,7 @@
680+ echo qemu-system-"$QEMU" '"$@"' $QEMU_MORE -nographic -no-reboot -m 256 \
681+ -kernel $(basename $VMLINUX) $INITRD \
682+ "-append \"panic=1 HOST=$TARGET console=$KARGS \$KARGS\"" \
683+- ${DTB:+-dtb "$(basename "$DTB")"} ";echo -e '\e[?7h'" \
684++ ${DTB:+-dtb "$(basename "$DTB")"} ";printf '\033[?7h\n'" \
685+ > "$OUTPUT/qemu-$TARGET.sh" &&
686+ chmod +x "$OUTPUT/qemu-$TARGET.sh" || exit 1
687+ fi
688+@@ -212,7 +214,8 @@
689+
690+ announce "linux-$KARCH"
691+- pushd "$LINUX" && make distclean && popd &&
692+- cp -sfR "$LINUX" "$MYBUILD/linux" && pushd "$MYBUILD/linux" &&
693++ dir="$PWD"
694++ cd "$LINUX" && make distclean && cd "$dir" &&
695++ cp -sfR "$LINUX" "$MYBUILD/linux" && cd "$MYBUILD/linux" &&
696+
697+ # Write miniconfig
698+ { echo "# make ARCH=$KARCH allnoconfig KCONFIG_ALLCONFIG=$TARGET.miniconf"
699+@@ -219,4 +222,4 @@
700+- echo -e "# make ARCH=$KARCH -j \$(nproc)\n# boot $VMLINUX\n\n"
701++ printf "# make ARCH=%s -j \$(nproc)\n# boot %s\n\n\n" "$KARCH" "$VMLINUX"
702+ echo "# CONFIG_EMBEDDED is not set"
703+
704+ # Expand list of =y symbols, first generic then architecture-specific
705+@@ -223,6 +226,6 @@
706+ for i in BINFMT_ELF,BINFMT_SCRIPT,NO_HZ,HIGH_RES_TIMERS,BLK_DEV,BLK_DEV_INITRD,RD_GZIP,BLK_DEV_LOOP,EXT4_FS,EXT4_USE_FOR_EXT2,VFAT_FS,FAT_DEFAULT_UTF8,MISC_FILESYSTEMS,SQUASHFS,SQUASHFS_XATTR,SQUASHFS_ZLIB,DEVTMPFS,DEVTMPFS_MOUNT,TMPFS,TMPFS_POSIX_ACL,NET,PACKET,UNIX,INET,IPV6,NETDEVICES,NET_CORE,NETCONSOLE,ETHERNET,COMPAT_32BIT_TIME,EARLY_PRINTK,IKCONFIG,IKCONFIG_PROC $KCONF ; do
707+ echo "# architecture ${X:-independent}"
708+- sed -E '/^$/d;s/([^,]*)($|,)/CONFIG_\1=y\n/g' <<< "$i"
709++ echo "$i" | sed -E '/^$/d;s/([^,]*)($|,)/CONFIG_\1=y\n/g'
710+ X=specific
711+ done
712+ [ ! -z "$BUILTIN" ] && echo -e CONFIG_INITRAMFS_SOURCE="\"$OUTPUT/fs\""
713+@@ -232,9 +235,10 @@
714+
715+ # Second config pass to remove stupid kernel defaults
716+ # See http://lkml.iu.edu/hypermail/linux/kernel/1912.3/03493.html
717+- sed -e 's/# CONFIG_EXPERT .*/CONFIG_EXPERT=y/' -e "$(sed -E -e '/^$/d' \
718+- -e 's@([^,]*)($|,)@/^CONFIG_\1=y/d;$a# CONFIG_\1 is not set/\n@g' \
719+- <<< VT,SCHED_DEBUG,DEBUG_MISC,X86_DEBUG_FPU)" -i .config &&
720++ sed -e 's/# CONFIG_EXPERT .*/CONFIG_EXPERT=y/' -e "$(echo \
721++ 'VT,SCHED_DEBUG,DEBUG_MISC,X86_DEBUG_FPU' | sed -E -e '/^$/d' \
722++ -e 's@([^,]*)($|,)@/^CONFIG_\1=y/d;$a# CONFIG_\1 is not set/\n@g')" \
723++ -i .config &&
724+ yes "" | make ARCH=$KARCH oldconfig > /dev/null &&
725+
726+ # Build kernel. Copy config, device tree binary, and kernel binary to output
727+@@ -241,7 +245,7 @@
728+ make ARCH=$KARCH CROSS_COMPILE="$CROSS_COMPILE" -j $(nproc) &&
729+ cp .config "$OUTPUT/linux-fullconfig" || exit 1
730+ [ ! -z "$DTB" ] && { cp "$DTB" "$OUTPUT" || exit 1 ;}
731+- cp "$VMLINUX" "$OUTPUT" && cd .. && rm -rf linux && popd || exit 1
732++ cp "$VMLINUX" "$OUTPUT" && cd .. && rm -rf linux && "$dir" || exit 1
733+ fi
734+
735+ # clean up and package root filesystem for initramfs.