# HG changeset patch # User Rob Landley # Date 1255244164 18000 # Node ID 2ca7ea5d3ec15460ba231442f5c32bafe04a6c8c # Parent dee27a32b1600c3bd20e4e9c21f70b2351e0a0f0 New native-static-build.sh to compile static dropbear, strace, and busybox inside the emulator and export 'em out via ftp. diff -r dee27a32b160 -r 2ca7ea5d3ec1 smoketest.sh --- a/smoketest.sh Sat Oct 10 12:08:59 2009 -0500 +++ b/smoketest.sh Sun Oct 11 01:56:04 2009 -0500 @@ -3,31 +3,17 @@ . sources/functions.sh || exit 1 # This script compiles stuff under the final system, using distcc to call out -# to the cross compiler. - -# Set up a timeout. If it doesn't complete in 60 seconds, it failed. - -timeout() -{ - sleep 60 - kill $1 -} - -timeout $$ & -trap "killtree $$" EXIT - -# Call run-from-build with a here document to do stuff. +# to the cross compiler. It calls run-from-build with a here document. # Note that the first line of the script is a few spaces followed by a comment -# character. This gives some harmless data for the linux boot process to -# consume and discard before it gets to the command prompt. I don't know why -# it does this, but it does. The comment character is so you can see how -# much got eaten, generally about 3 characters. +# character. This gives some harmless data for the linux boot process (serial +# initialization) to consume and discard before it gets to the command prompt. +# (The comment character is just so you can see how much got eaten.) # If you cat your own script into emulator-build.sh, you probably also need # to start with a line of spaces like that. Just FYI. -SKIP_HOME=1 ./run-from-build.sh $1 << 'EOF' +SKIP_HOME=1 sources/timeout.sh 60 ./run-from-build.sh $1 << 'EOF' # # Show free space df diff -r dee27a32b160 -r 2ca7ea5d3ec1 sources/more/native-static-build.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/more/native-static-build.sh Sun Oct 11 01:56:04 2009 -0500 @@ -0,0 +1,44 @@ +#!/bin/bash + +. sources/functions.sh || exit 1 + +STAGE_DIR="$(pwd)/build/cron-temp" + +# Create an hdc image with the source code and build script + +sources/more/setup-native-static-build.sh "$STAGE_DIR" + +# Fire off the ftp daemon, making sure it's killed when this script exits + +build/host/netcat -s 127.0.0.1 -p 9876 -L build/host/ftpd -w "$STAGE_DIR" & +trap "kill $(jobs -p)" EXIT +disown $(jobs -p) + +find build -name "hdb.img" | xargs rm + +# Run emulator as a child process, feeding in -hdc and some extra environment +# variables so it auto-launches the build process. + +function do_arch() +{ + set_titlebar "Native build for $1" + HDC="$STAGE_DIR/hdc.sqf" KERNEL_EXTRA="OUTPORT=9876 ARCH=$1" \ + sources/timeout.sh 60 ./run-from-build.sh $1 +} + +# If we have a command line argument, build just that arch, otherwise build +# all arches that managed to create a system image. + +if [ ! -z "$1" ] +then + do_arch "$1" +else + for i in $(ls build/system-image-*.tar.bz2 | sed 's@build/system-image-\(.*\)\.tar\.bz2@\1@') + do + maybe_fork do_arch $i + done + + wait +fi + +echo End of native build diff -r dee27a32b160 -r 2ca7ea5d3ec1 sources/more/setup-native-static-build.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/more/setup-native-static-build.sh Sun Oct 11 01:56:04 2009 -0500 @@ -0,0 +1,73 @@ +#!/bin/bash + +# Create hdc image to build dropbear, strace, and busybox statically. + +. sources/include.sh + +if [ -z "$1" ] +then + print "Need directory name" >&2 + exit 1 +fi + +# Set up working directories + +WORK="$1" +blank_tempdir "$WORK" +WORK="$WORK"/sub +mkdir -p "$WORK" || dienow + +# Extract source code into new image directory + +setupfor dropbear +setupfor strace +setupfor busybox + +cp "$SOURCES"/trimconfig-busybox "$WORK" || dienow + +cat > "$WORK"/init << 'EOF' || dienow +#!/bin/bash + +echo Started second stage init + +cd /home && +mkdir output && + +# Build dropbear + +cp -sfR /mnt/dropbear dropbear && +cd dropbear && +LDFLAGS="--static" ./configure --disable-zlib && +make -j $CPUS PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 SCPPROGRESS=1 && +cp dropbearmulti /home/output && +cd .. && +rm -rf dropbear || exit 1 + +cp -sfR /mnt/strace strace && +cd strace && +CFLAGS="--static" ./configure && +make -j $CPUS && +cp strace /home/output && +cd .. && +rm -rf strace || dienow + +cp -sfR /mnt/busybox busybox && +cd busybox && +make allyesconfig KCONFIG_ALLCONFIG=/mnt/trimconfig-busybox && +LDFLAGS="--static" make -j $CPUS && +cp busybox /home/output && +rm -rf busybox || dienow + +cd /home/output +for i in * +do + ftpput 10.0.2.2 -P $OUTPORT $ARCH-$i $i +done + +sync + +EOF + +chmod +x "$WORK"/init || dienow + +mksquashfs "$WORK" "$WORK"/../hdc.sqf -noappend -all-root diff -r dee27a32b160 -r 2ca7ea5d3ec1 sources/timeout.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/timeout.sh Sun Oct 11 01:56:04 2009 -0500 @@ -0,0 +1,20 @@ +#!/bin/bash + +# Run a command line with a hang timeout, which kills the child process if it +# doesn't produce a new line of output for $1 seconds. + +# This script has to be a separate process (rather than just a shell function) +# so killing it doesn't kill the parent process. + +source sources/functions.sh + +if [ $# -lt 1 ] +then + echo "Need timeout value" >&2 + exit 1 +fi + +trap "killtree $$" EXIT +TIMEOUT="$1" +shift +( "$@" ) | tee >(while read -t "$TIMEOUT" -n 32 i; do true; done; sleep 1; kill -TERM $$ 2>/dev/null ) diff -r dee27a32b160 -r 2ca7ea5d3ec1 sources/toys/run-emulator.sh --- a/sources/toys/run-emulator.sh Sat Oct 10 12:08:59 2009 -0500 +++ b/sources/toys/run-emulator.sh Sun Oct 11 01:56:04 2009 -0500 @@ -12,6 +12,10 @@ then shift HDB="$1" + elif [ "$1" == "--with-hdc" ] + then + shift + HDC="$1" elif [ "$1" == "--with-distcc" ] then DCC="$(which distccd)" @@ -109,6 +113,7 @@ fi [ -e "$HDB" ] && WITH_HDB="-hdb $HDB" +[ -e "$HDC" ] && WITH_HDC="-hdc $HDC" # Kill our child processes on exit.