aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-12-13 16:20:04 -0800
committerElliott Hughes <enh@google.com>2021-12-13 16:33:55 -0800
commite3ff87be6fbc2a89011618ba57f7eeb6ca28d9b7 (patch)
treed52b75ace13858a7abc08fa31239b95c5a0538a5 /scripts
parent764350aa10722fc777ef1027df1031660427dd6f (diff)
parentea4748a7cbfa5e2f3ef188f917d4e5aeac70dd0f (diff)
downloadtoybox-e3ff87be6fbc2a89011618ba57f7eeb6ca28d9b7.tar.gz
Upgrade toybox to ea4748a7cbfa5e2f3ef188f917d4e5aeac70dd0f
Test: make Change-Id: I0f170938a0061aef3ca701b4b81775bdfc379007
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mkroot.sh86
-rwxr-xr-xscripts/mkstatus.py10
-rwxr-xr-xscripts/root/dropbear10
3 files changed, 56 insertions, 50 deletions
diff --git a/scripts/mkroot.sh b/scripts/mkroot.sh
index 1829fe31..69246950 100755
--- a/scripts/mkroot.sh
+++ b/scripts/mkroot.sh
@@ -10,53 +10,61 @@ announce() { echo -e "\033]2;$CROSS $*\007\n=== $*"; }
LINUX="$LINUX" CROSS="$CROSS" CROSS_COMPILE="$CROSS_COMPILE" "$0" "$@"
# assign command line NAME=VALUE args to env vars, the rest are packages
-while [ $# -ne 0 ]; do
- [ "${1/=/}" != "$1" ] && export "$1" || { [ "$1" != -- ] && PKG="PKG $1"; }
- shift
+for i in "$@"; do
+ [ "${i/=/}" != "$i" ] && export "$i" || { [ "$i" != -- ] && PKG="$PKG $i"; }
done
-# Create work/output directories (command line can override these)
-mkdir -p ${TOP:=$PWD/root} ${BUILD:=$TOP/build} ${LOG:=$BUILD/log} || exit 1
+# Set default values for directories (overrideable from command line)
+: ${LOG:=${BUILD:=${TOP:=$PWD/root}/build}/log} ${AIRLOCK:=$BUILD/airlock}
+: ${CCC:=$PWD/ccc} ${PKGDIR:=$PWD/scripts/root}
-# ----- Set up for cross compling (optional)
+# ----- Are we cross compiling (via CROSS_COMPILE= or CROSS=)
if [ -n "$CROSS_COMPILE" ]; then
- CROSS_COMPILE="$(realpath -s "$CROSS_COMPILE")" # absolute path for airlock
+ CROSS_COMPILE="$(realpath -s "$CROSS_COMPILE")" # airlock needs absolute path
[ -z "$CROSS" ] && CROSS=${CROSS_COMPILE/*\//} CROSS=${CROSS/-*/}
-elif [ -n "$CROSS" ]; then # CROSS=all, CROSS=target, or list available targets
- [ ! -d "${CCC:=$PWD/ccc}" ] && die "No ccc symlink to compiler directory."
+elif [ -n "$CROSS" ]; then # CROSS=all/allnonstop/$ARCH else list known $ARCHes
+ [ ! -d "$CCC" ] && die "No ccc symlink to compiler directory."
TARGETS="$(ls "$CCC" | sed -n 's/-.*//p' | sort -u)"
- if [ "${CROSS::3}" == all ]; then # loop calling ourselves for each target
- for i in $TARGETS; do
+ if [ "${CROSS::3}" == all ]; then
+ for i in $TARGETS; do # loop calling ourselves for each target
"$0" "$@" CROSS=$i || [ "$CROSS" == allnonstop ] || exit 1
done; exit
- else # Set $CROSS_COMPILE from $CROSS using ccc directory
- CROSS_COMPILE="$(echo "$CCC/$CROSS"-*cross/bin/"$CROSS"*-cc)"
- [ ! -e "$CROSS_COMPILE" ] && echo $TARGETS && exit # list available targets
- CROSS_COMPILE="${CROSS_COMPILE%cc}" # keep prefix, not path to compiler
+ else # Find matching cross compiler under ccc/ else list available targets
+ CROSS_COMPILE="$(echo "$CCC/$CROSS"-*cross/bin/"$CROSS"*-cc)" # wildcard
+ if [ -e "$CROSS_COMPILE" ]; then
+ CROSS_COMPILE="${CROSS_COMPILE%cc}" # keep prefix for cc/ld/as/nm/strip...
+ else
+ echo $TARGETS && exit # list available targets
+ fi
fi
fi
-# Start logging
-rm -f "$LOG/${CROSS:=host}".{n,y}
-[ -z "$NOLOG" ] && exec > >(tee "$LOG/$CROSS.n") 2>&1
-echo "Building for ${CROSS:=host}"
-
-# ----- Build airlock (Optional)
+# Verify compiler works
${CROSS_COMPILE}cc --static -xc - -o /dev/null <<< "int main(void){return 0;}"||
die "${CROSS_COMPILE}cc can't create static binaries"
-if [ -n "$CROSS_COMPILE" ] && [ -z "$NOAIRLOCK" ]; then
- # When cross compiling build under a host toybox with known behavior
- if [ ! -e "${AIRLOCK:=$BUILD/airlock}/toybox" ]; then
- announce "airlock"
- PREFIX="$AIRLOCK" KCONFIG_CONFIG="$BUILD"/.airlock CROSS_COMPILE= \
+# Set CROSS=host if not cross compiling, and create per-target output directory
+: ${CROSS:=host} ${OUTPUT:=$TOP/$CROSS}
+
+# ----- Build airlock (Optional)
+
+if [ -z "$NOAIRLOCK"] && [ -n "$CROSS_COMPILE" ]; then
+ # When cross compiling set host $PATH to binaries with known behavior
+ if [ ! -e "$AIRLOCK/toybox" ]; then
+ announce "airlock" &&
+ PREFIX="$AIRLOCK" KCONFIG_CONFIG=.singleconfig_airlock CROSS_COMPILE= \
make clean defconfig toybox install_airlock &&
- rm "$BUILD"/.airlock || exit 1
+ rm .singleconfig_airlock || exit 1
fi
export PATH="$AIRLOCK"
fi
+# Create per-target work directories
+MYBUILD="$BUILD/${CROSS}-tmp" && rm -rf "$MYBUILD" && mkdir -p "$MYBUILD" &&
+mkdir -p "$OUTPUT" "$LOG" || exit 1
+[ -z "$ROOT" ] && ROOT="$OUTPUT/fs" && rm -rf "$ROOT"
+
# Install command line recording wrapper, logs all commands run from $PATH
if [ -z "$NOLOGPATH" ]; then
# Move cross compiler into $PATH so calls to it get logged
@@ -67,10 +75,10 @@ if [ -z "$NOLOGPATH" ]; then
WRAPDIR="$WRAPDIR" CROSS_COMPILE= source scripts/record-commands || exit 1
fi
-# Create per-target work directories
-MYBUILD="$BUILD/${CROSS}-tmp" && rm -rf "$MYBUILD" && mkdir -p "$MYBUILD" &&
-mkdir -p ${OUTPUT:=$TOP/$CROSS} || exit 1
-[ -z "$ROOT" ] && ROOT="$OUTPUT/fs" && rm -rf "$ROOT"
+# Start logging stdout/stderr
+rm -f "$LOG/$CROSS".{n,y} || exit 1
+[ -z "$NOLOG" ] && exec > >(tee "$LOG/$CROSS.n") 2>&1
+echo "Building for $CROSS"
# ----- Create new root filesystem's directory layout.
@@ -104,7 +112,7 @@ if [ $$ -eq 1 ]; then # Setup networking for QEMU (needs /proc)
[ "$(date +%s)" -lt 10000000 ] && sntp -sq time.google.com
# Run package scripts (if any)
- for i in $(ls -1 /etc/rc 2>/dev/null | sort); do . "$i"; done
+ for i in $(ls -1 /etc/rc 2>/dev/null | sort); do . /etc/rc/"$i"; done
[ -z "$CONSOLE" ] && CONSOLE="$(</sys/class/tty/console/active)"
[ -z "$HANDOFF" ] && HANDOFF=/bin/sh && echo Type exit when done.
@@ -134,10 +142,8 @@ LDFLAGS=--static PREFIX="$ROOT" make clean \
${CONF:-defconfig KCONFIG_ALLCONFIG=<(echo "$XX")} toybox install || exit 1
# Build any packages listed on command line
-for i in $PKG; do
- announce "$i"
- ( PATH="${PKGDIR:=$PWD/scripts/root}:$PATH"; source plumbing; source $i ) ||
- die $i
+for i in ${PKG:+plumbing $PKG}; do
+ announce "$i"; PATH="$PKGDIR:$PATH" source $i || die $i
done
# ----- Build kernel for target
@@ -264,9 +270,11 @@ CONFIG_CMDLINE="console=ttyUL0 earlycon"' BUILTIN=1
fi
# clean up and package root filesystem for initramfs.
-[ -z "$BUILTIN" ] && announce "${CROSS}root.cpio.gz" &&
- (cd "$ROOT" && find . | cpio -o -H newc ${CROSS_COMPILE:+--no-preserve-owner} | gzip) \
- > "$OUTPUT/$CROSS"root.cpio.gz || exit 1
+if [ -z "$BUILTIN" ]; then
+ announce "${CROSS}root.cpio.gz"
+ (cd "$ROOT" && find . | cpio -o -H newc ${CROSS_COMPILE:+--no-preserve-owner}\
+ | gzip) > "$OUTPUT/$CROSS"root.cpio.gz || exit 1
+fi
mv "$LOG/$CROSS".{n,y} #2>/dev/null
rmdir "$MYBUILD" "$BUILD" 2>/dev/null || exit 0 # remove if empty, not an error
diff --git a/scripts/mkstatus.py b/scripts/mkstatus.py
index 5cb6ae77..ed6dd544 100755
--- a/scripts/mkstatus.py
+++ b/scripts/mkstatus.py
@@ -21,15 +21,15 @@ def readit(args, shell=False):
print "Collecting data..."
-stuff,blah=readit(["sed","-n", 's/<span id=\\([a-z_]*\\)>/\\1 /;t good;d;:good;h;:loop;n;s@</span>@@;t out;H;b loop;:out;g;s/\\n/ /g;p', "www/roadmap.html", "www/status.html"])
+stuff,blah=readit(["sed","-n", 's/<span id=\\([a-z_]*\\)>/\\1 /;t good;d;:good;h;:loop;n;s@</span>@@;t out;H;b loop;:out;g;s/\\n/ /g;p', "www/roadmap.html"])
blah,toystuff=readit(["./toybox"])
-blah,pending=readit(["sed", "-n", "s/.*NEWTOY[(]\([^,]*\).*TOYFLAG_NOFORK.*/\1/p", "toys/pending/sh.c"])
+blah,stuff["shell"]=readit(["sed", "-n", "s/.*NEWTOY[(]\\([^,]*\\).*TOYFLAG_NOFORK.*/\\1/p", "toys/pending/sh.c"])
+blah,pending=readit(["/bin/bash", "-c", "sed -n 's/[^ \\t].*TOY(\\([^,]*\\),.*/\\1/p' toys/pending/*.c"])
version=readit(["./toybox","--version"])[-1][-1]
print "Analyzing..."
# Create reverse mappings: reverse["command"] gives list of categories it's in
-
reverse={}
for i in stuff:
for j in stuff[i]:
@@ -58,7 +58,6 @@ conv = [("posix", '<a href="http://pubs.opengroup.org/onlinepubs/9699919799/util
("shell", "", "%%%s%%"),
("request", '<a href="https://man7.org/linux/man-pages/man1/%s.1.html">%%s</a>', '+%s+')]
-
def categorize(reverse, i, skippy=""):
linky = "%s"
out = i
@@ -103,7 +102,7 @@ outfile.write("""<html><head><title>toybox current status</title>
<title>Toybox Status</title>
""");
outfile.write("<h1>Status of toybox %s</h1>\n" % version);
-outfile.write("<h3>Legend: %s <strike>pending</strike></h3>\n"%" ".join(map(lambda i: i[2]%(i[0].split("_")[0]), conv[:-2])))
+outfile.write("<h3>Legend: %s <strike>pending</strike></h3>\n"%" ".join(map(lambda i: i[2]%(i[0].split("_")[0]), conv)))
outfile.write("<a name=done><h2><a href=#done>Completed</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(done))
outfile.write("<a name=part><h2><a href=#part>Partially implemented (in toys/pending)</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pend))
@@ -117,7 +116,6 @@ for i in conv:
todo = []
i=i[0]
- if i=="shell": continue
for j in stuff[i]:
if j in toystuff: continue
if j in pending: todo.append('<strike>%s</strike>' % j)
diff --git a/scripts/root/dropbear b/scripts/root/dropbear
index a2a49ddc..75839c34 100755
--- a/scripts/root/dropbear
+++ b/scripts/root/dropbear
@@ -4,11 +4,11 @@
echo === download source
-download a4d316c404ff54ca545ea71a27af7dbc29817088 \
- http://downloads.sf.net/libpng/zlib-1.2.8.tar.gz
+download e6d119755acdf9104d7ba236b1242696940ed6dd \
+ http://downloads.sf.net/libpng/zlib-1.2.11.tar.gz
-download 820ec2b8c869edbcf5ad1138777fc0f54349505c \
- https://matt.ucc.asn.au/dropbear/releases/dropbear-2019.78.tar.bz2
+download c3d4fe27fa17ec8217dbedbd33dd73a1ca6cda2c \
+ https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2
echo === Native build static zlib
@@ -28,7 +28,7 @@ setupfor dropbear
echo 'echo "$@"' > config.sub &&
ZLIB="$(echo ../zlib*)" &&
CFLAGS="-I $ZLIB -O2" LDFLAGS="-L $ZLIB" ./configure --enable-static \
- --disable-wtmp --host=${CROSS_BASE%-} &&
+ --disable-wtmp --host="$(basename "$CROSS_COMPILE" | sed 's/-$//')" &&
sed -i 's@/usr/bin/dbclient@ssh@' options.h &&
sed -i 's@\(#define NON_INETD_MODE\) 1@\1 0@' default_options.h &&
make -j $(nproc) PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 SCPPROGRESS=1 &&