Mercurial > hg > aboriginal
changeset 1544:e2f722cc97a6
Make busybox build by default, switch override knob to BUSYBOX=1 to use defconfig busybox, always use toybox for oneit, cleanup/fix record-commands logic.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 06 Sep 2012 05:11:25 -0500 |
parents | ff7f43a0bee0 |
children | 49be0eeedda9 |
files | config host-tools.sh more/record-commands.sh simple-root-filesystem.sh sources/include.sh sources/sections/busybox.build sources/sections/toybox.build sources/toys/oneit.c |
diffstat | 8 files changed, 19 insertions(+), 126 deletions(-) [+] |
line wrap: on
line diff
--- a/config Thu Sep 06 05:07:23 2012 -0500 +++ b/config Thu Sep 06 05:11:25 2012 -0500 @@ -130,15 +130,9 @@ # export HOST_EXTRA="lex yacc" -# Get your commands, for both host-tools and simple-root-filesystem, from: -# -# busybox - busybox configured with with sources/baseconfig-busybox -# busybox_defconfig - busybox configured with defconfig -# toybox - toybox defconfig (plus busybox with baseconfig-toybox-todo) -# -# Default is "busybox". +# Build with busybox defconfig instead of toybox. -# export TOYBOX=busybox +# export BUSYBOX=1 # Set this to continue despite failed patches.
--- a/host-tools.sh Thu Sep 06 05:07:23 2012 -0500 +++ b/host-tools.sh Thu Sep 06 05:11:25 2012 -0500 @@ -58,7 +58,7 @@ # Use the new tools we build preferentially, as soon as they become # available. -PATH="$STAGE_DIR:$PATH" +PATH="$(hosttools_path):$PATH" # Sanity test for the host supporting static linking. @@ -82,7 +82,7 @@ # thing. [ ! -f "$STAGE_DIR/busybox" ] && build_section busybox -[ "$TOYBOX" == toybox ] && [ ! -f "$STAGE_DIR/toybox" ] && build_section toybox +[ ! -f "$STAGE_DIR/toybox" ] && build_section toybox # Create symlinks to the host toolchain. We need a usable existing host # toolchain in order to build anything else (even a new host toolchain),
--- a/more/record-commands.sh Thu Sep 06 05:07:23 2012 -0500 +++ b/more/record-commands.sh Thu Sep 06 05:11:25 2012 -0500 @@ -11,7 +11,7 @@ echo "=== Setting up command recording wrapper" [ -f "$WRAPDIR/wrappy" ] && PATH="$OLDPATH" -[ -f "$HOSTTOOLS/busybox" ] && PATH="$HOSTTOOLS" +[ -f "$HOSTTOOLS/busybox" ] && PATH="$(hosttools_path)" blank_tempdir "$WRAPDIR" # Populate a directory of symlinks with every command in the $PATH.
--- a/simple-root-filesystem.sh Thu Sep 06 05:07:23 2012 -0500 +++ b/simple-root-filesystem.sh Thu Sep 06 05:11:25 2012 -0500 @@ -54,19 +54,7 @@ STAGE_DIR="$STAGE_USR" build_section busybox cp "$WORK"/config-busybox "$STAGE_USR"/src || dienow - -if [ "$TOYBOX" == toybox ] -then - build_section toybox -fi - -# Build the world's simplest init program: spawns one task with a controlling -# TTY, waits (reaping zombies) until it exits, then shuts down the system. - -TEMP= -[ "$BUILD_STATIC" == all ] && TEMP=--static -${ARCH}-cc "$SOURCES/toys/oneit.c" -Os $CFLAGS $TEMP \ - -o "$STAGE_USR/sbin/oneit" || dienow +build_section toybox # Put statically and dynamically linked hello world programs on there for # test purposes.
--- a/sources/include.sh Thu Sep 06 05:07:23 2012 -0500 +++ b/sources/include.sh Thu Sep 06 05:11:25 2012 -0500 @@ -62,7 +62,7 @@ export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'` [ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1" -export_if_blank BUILD_STATIC=busybox,binutils,gcc-core,gcc-g++,make +export_if_blank BUILD_STATIC=busybox,toybox,binutils,gcc-core,gcc-g++,make # Adjust $PATH @@ -81,10 +81,10 @@ OLDPATH="$PATH" mkdir -p "$BUILD/logs" [ $? -ne 0 ] && echo "Bad $WRAPDIR" >&2 && dienow - export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early" PATH="$WRAPDIR" fi fi +export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early" # Create files with known permissions umask 022
--- a/sources/sections/busybox.build Thu Sep 06 05:07:23 2012 -0500 +++ b/sources/sections/busybox.build Thu Sep 06 05:11:25 2012 -0500 @@ -4,19 +4,14 @@ # Build busybox -if [ "$TOYBOX" == busybox_defconfig ] +if [ ! -z "$BUSYBOX" ] then make defconfig && # breaks on ubuntu 11.10 sed -i -e 's/^\(CONFIG_UBI.*\)=y/# \1 is not set/' .config && cp .config "$WORK"/config-busybox || dienow else - if [ "$TOYBOX" == toybox ] - then - getconfig busybox | sed '/toybox/q' > "$WORK/config-busybox" || dienow - else - getconfig busybox > "$WORK/config-busybox" || dienow - fi + getconfig busybox | sed '/toybox/,$d' > "$WORK/config-busybox" && make allnoconfig KCONFIG_ALLCONFIG="$WORK/config-busybox" || dienow fi
--- a/sources/sections/toybox.build Thu Sep 06 05:07:23 2012 -0500 +++ b/sources/sections/toybox.build Thu Sep 06 05:11:25 2012 -0500 @@ -4,13 +4,21 @@ # Build toybox -for i in defconfig toybox install$([ -z "$ARCH" ] && echo _flat) +for i in defconfig toybox \ + $( [ -z "$BUSYBOX" ] && echo install$([ -z "$ARCH" ] && echo _flat) ) do PREFIX="$STAGE_DIR" CFLAGS="$CFLAGS $STATIC_FLAGS" CC= STRIP= \ CROSS_COMPILE=${ARCH:+${ARCH}-} make -j $CPUS $VERBOSITY $i || dienow done cp .config "$WORK"/config-toybox || dienow +# We always need at least oneit + +if [ ! -z "$BUSYBOX" ] +then + ln -sf toybox "$STAGE_DIR/${ARCH:+sbin/}oneit" || dienow +fi + if [ ! -z "$SKIP_STRIP" ] then cp toybox_unstripped "$INSTDIR/toybox" || dienow
--- a/sources/toys/oneit.c Thu Sep 06 05:07:23 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* vi: set sw=4 ts=4: - * - * oneit.c, tiny one-process init replacement. - * - * Copyright 2005, 2010 by Rob Landley <rob@landley.net>. - */ - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> -#include <sys/reboot.h> - -char *console; -int poweroff; - -// The minimum amount of work necessary to get ctrl-c and such to work is: -// -// - Fork a child (PID 1 is special: can't exit, has various signals blocked). -// - Do a setsid() (so we have our own session). -// - In the child, attach stdio to /dev/tty0 (/dev/console is special) -// - Exec the rest of the command line. -// -// PID 1 then reaps zombies until the child process it spawned exits, at which -// point it calls sync() and reboot(). I could stick a kill -1 in there. - - -int main(int argc, char *argv[]) -{ - int i, args; - pid_t pid; - - for (args=1; args<argc; args++) { - if (*argv[args]=='-') switch (argv[args][1]) { - case 'c': - console=argv[++args]; - continue; - case 'p': - poweroff++; - continue; - default: - args=argc; - break; - } - break; - } - if (args>=argc) { - fprintf(stderr, - "usage: oneit [-p] [-c /dev/tty0] command [...]\n\n" - "A simple init program that runs a single supplied command line with a\n" - "controlling tty (so CTRL-C can kill it).\n\n" - "-p\tPower off instead of rebooting when command exits.\n" - "-c\tWhich console device to use.\n\n" - "The oneit command runs the supplied command line as a child process\n" - "(because PID 1 has signals blocked), attached to /dev/tty0, in its\n" - "own session. Then oneit reaps zombies until the child exits, at\n" - "which point it reboots (or with -p, powers off) the system.\n"); - exit(1); - } - - // Create a new child process. - pid = vfork(); - if (pid) { - chdir("/"); - - // pid 1 just reaps zombies until it gets its child, then halts the system. - while (pid!=wait(&i)); - sync(); - - // PID 1 can't call reboot() because that syscall kills the task that calls - // it, which causes the kernel to panic before the actual reboot happens. - if (!vfork()) reboot(poweroff ? RB_POWER_OFF : RB_AUTOBOOT); - sleep(5); - _exit(1); - } - - // Redirect stdio to /dev/tty0, with new session ID, so ctrl-c works. - setsid(); - if (!console) console="/dev/tty0"; - for (i=0; i<3; i++) { - close(i); - if(-1==open(console, O_RDWR)) { - fprintf(stderr, "Can't open '%s'\n", console); - exit(1); - } - } - - execvp(argv[args], argv+args); - _exit(127); -}