diff options
author | Rob Landley <rob@landley.net> | 2023-04-16 20:18:02 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2023-04-16 20:18:02 -0500 |
commit | 126c719dd250735f1c9517dfb6dcdfe02f347818 (patch) | |
tree | 8f8dd64c5312eaf627c19651a368f604bb40de31 | |
parent | 8626a6ac7dff93bf97f754c93c3e426ee5c6b1e0 (diff) | |
download | toybox-126c719dd250735f1c9517dfb6dcdfe02f347818.tar.gz |
Move mkroot into its own directory.
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | mkroot/mkroot.sh (renamed from scripts/mkroot.sh) | 9 | ||||
-rwxr-xr-x | mkroot/record-commands (renamed from scripts/record-commands) | 0 | ||||
-rwxr-xr-x | mkroot/root/dropbear (renamed from scripts/root/dropbear) | 2 | ||||
-rwxr-xr-x | mkroot/root/dynamic (renamed from scripts/root/dynamic) | 2 | ||||
-rwxr-xr-x | mkroot/root/overlay | 3 | ||||
-rwxr-xr-x | mkroot/root/plumbing (renamed from scripts/root/plumbing) | 0 | ||||
-rwxr-xr-x | mkroot/root/tests (renamed from scripts/root/tests) | 2 | ||||
-rwxr-xr-x | mkroot/testroot.sh (renamed from scripts/test_mkroot.sh) | 19 | ||||
-rwxr-xr-x | scripts/root/overlay | 3 | ||||
-rwxr-xr-x | www/faq.html | 4 |
11 files changed, 31 insertions, 15 deletions
@@ -77,7 +77,7 @@ tests: toybox scripts/test.sh root: - scripts/mkroot.sh $(MAKEFLAGS) + mkroot/mkroot.sh $(MAKEFLAGS) run_root: cd root/"$${CROSS:-host}" && ./run-qemu.sh diff --git a/scripts/mkroot.sh b/mkroot/mkroot.sh index 60433240..0447b386 100755 --- a/scripts/mkroot.sh +++ b/mkroot/mkroot.sh @@ -6,6 +6,8 @@ [ -z "$NOCLEAR" ] && exec env -i NOCLEAR=1 HOME="$HOME" PATH="$PATH" \ LINUX="$LINUX" CROSS="$CROSS" CROSS_COMPILE="$CROSS_COMPILE" "$0" "$@" +! [ -d mkroot ] && echo "Run mkroot/mkroot.sh from toybox source dir." && exit 1 + # assign command line NAME=VALUE args to env vars, the rest are packages for i in "$@"; do [ "${i/=/}" != "$i" ] && export "$i" || { [ "$i" != -- ] && PKG="$PKG $i"; } @@ -13,9 +15,8 @@ done # Set default directory locations (overrideable from command line) : ${TOP:=$PWD/root} ${BUILD:=$TOP/build} ${LOG:=$BUILD/log} -: ${AIRLOCK:=$BUILD/airlock} ${CCC:=$PWD/ccc} ${PKGDIR:=$PWD/scripts/root} +: ${AIRLOCK:=$BUILD/airlock} ${CCC:=$PWD/ccc} ${PKGDIR:=$PWD/mkroot/root} -# define functions announce() { printf "\033]2;$CROSS $*\007" >/dev/tty; printf "\n=== $*\n";} die() { echo "$@" >&2; exit 1; } @@ -80,7 +81,7 @@ if [ -z "$NOLOGPATH" ]; then CROSS_COMPILE=${CROSS_COMPILE##*/} export WRAPDIR="$BUILD/record-commands" LOGPATH="$LOG/$CROSS-commands.txt" rm -rf "$WRAPDIR" "$LOGPATH" generated/obj && - WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 source scripts/record-commands || + WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 source mkroot/record-commands || exit 1 fi @@ -304,5 +305,5 @@ if [ -z "$BUILTIN" ]; then > "$OUTPUT"/initramfs.cpio.gz || exit 1 fi -mv "$LOG/$CROSS".{n,y} +mv "$LOG/$CROSS".{n,y} && echo "Output is in $OUTPUT" rmdir "$TEMP" "$BUILD" 2>/dev/null || exit 0 # remove if empty, not an error diff --git a/scripts/record-commands b/mkroot/record-commands index d2b779fa..d2b779fa 100755 --- a/scripts/record-commands +++ b/mkroot/record-commands diff --git a/scripts/root/dropbear b/mkroot/root/dropbear index cd0b1578..9a4adcb8 100755 --- a/scripts/root/dropbear +++ b/mkroot/root/dropbear @@ -1,4 +1,4 @@ -#!/bin/echo Try "scripts/mkroot.sh dropbear" +#!/bin/echo Try "mkroot/mkroot.sh dropbear" # Example overlay file, adding dropbear (which requires zlib) diff --git a/scripts/root/dynamic b/mkroot/root/dynamic index c82b1ddb..2ecfbdaa 100755 --- a/scripts/root/dynamic +++ b/mkroot/root/dynamic @@ -1,4 +1,4 @@ -#!/bin/echo Try "scripts/mkroot.sh dynamic" +#!/bin/echo Try "mkroot/mkroot.sh dynamic" # Copy dynamic libraries from cross compiler diff --git a/mkroot/root/overlay b/mkroot/root/overlay new file mode 100755 index 00000000..be0aaede --- /dev/null +++ b/mkroot/root/overlay @@ -0,0 +1,3 @@ +#!/bin/echo Try "mkroot/mkroot.sh overlay" + +cp -a "${OVERLAY:=overlay}"/. "$ROOT"/. diff --git a/scripts/root/plumbing b/mkroot/root/plumbing index e72247c0..e72247c0 100755 --- a/scripts/root/plumbing +++ b/mkroot/root/plumbing diff --git a/scripts/root/tests b/mkroot/root/tests index 89186d83..bca3b40c 100755 --- a/scripts/root/tests +++ b/mkroot/root/tests @@ -1,4 +1,4 @@ -#!/bin/echo Try "scripts/mkroot.sh $0" +#!/bin/echo Try "mkroot/mkroot.sh $0" # Alas http://www.linux-usb.org/usb.ids is not versioned, so... download 36d4e16755502fbc684be75e56841e1014e4a94a \ diff --git a/scripts/test_mkroot.sh b/mkroot/testroot.sh index e2679b1d..0e3f4494 100755 --- a/scripts/test_mkroot.sh +++ b/mkroot/testroot.sh @@ -1,5 +1,20 @@ #!/bin/bash +# usage: mkroot/testroot.sh [TARGET...] +# +# Test system image(s) (by booting qemu with -hda test.img providing /mnt/init) +# and check that: +# +# A) it boots and runs our code (which means /dev/hda works) +# B) the clock is set sanely ("make" is unhappy when source newer than output) +# C) it can talk to the virtual network +# +# Each successful test prints a === line, and all 3 means it passed. +# Writes result into root/build/test/$TARGET-test.txt +# +# With arguments, tests those targets (verbosely). With no arguments, tests +# each target with a linux-kernel (in parallel) and prints pass/fail summary. + die() { echo "$@"; exit 1; } [ -n "$(which toybox)" -a -n "$(which mksquashfs)" ] || @@ -7,7 +22,7 @@ die() { echo "$@"; exit 1; } mkdir -p "${TEST:=$PWD/root/build/test}" && -# Setup test filesystem +# Setup test filesystem and package it into a squashfs. cat > "$TEST"/init << 'EOF' && #!/bin/sh @@ -21,7 +36,7 @@ chmod +x "$TEST"/init && mksquashfs "$TEST"/init configure scripts/ tests/ "$TEST"/init.sqf -noappend -all-root >/dev/null && -# Setup for network smoke test +# Setup server on host's loopback for network smoke test echo === net ok > "$TEST"/index.html || die "smoketest setup" toybox netcat -p 65432 -s 127.0.0.1 -L toybox httpd "$TEST" & trap "kill $!" EXIT diff --git a/scripts/root/overlay b/scripts/root/overlay deleted file mode 100755 index f02f3db0..00000000 --- a/scripts/root/overlay +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/echo Try "scripts/mkroot.sh overlay" - -cp -a "${OVERLAY:=overlay}"/. "$ROOT"/. diff --git a/www/faq.html b/www/faq.html index 79200550..d166bad5 100755 --- a/www/faq.html +++ b/www/faq.html @@ -759,7 +759,7 @@ auditable version of the cmdline portion of that base.</p> <hr /><h2><a name="mkroot" />Q: How do you build a working Linux system with toybox?</h2> -<p>A: Toybox has a built-in <a href=https://github.com/landley/toybox/blob/master/scripts/mkroot.sh>system builder</a>, with the Makefile target "<b>make +<p>A: Toybox has a built-in <a href=https://github.com/landley/toybox/blob/master/mkroot/mkroot.sh>system builder</a> called "<a href=https://github.com/landley/toybox/blob/master/mkroot/README>mkroot</a>", with the Makefile target "<b>make root</b>". To enter the resulting root filesystem, "<b>sudo chroot root/host/fs /init</b>". Type "exit" to get back out.</p> @@ -832,7 +832,7 @@ to the build, by calling the script directly and listing packages on the command line:</p> <blockquote> -<p><b>scripts/mkroot.sh CROSS=all LINUX=~/linux dropbear</b></p> +<p><b>mkroot/mkroot.sh CROSS=all LINUX=~/linux dropbear</b></p> </blockquote> <p>An example package build script (building the dropbear ssh server, adding a |