Mercurial > hg > aboriginal
changeset 306:358ef8a27085
Break up run-$ARCH.sh, move more temp files into temp dir, fix deletion logic.
Now that it's making a qemu-image tarball, the kernel and ext2 image files
are temporary files, so put them in temp-$ARCH. Don't delete temp-$ARCH at the
start of build stages, don't delete old source at start of setupfor (g++ adds
to gcc-core).
Run scripts are now three layers: run-with-distcc.sh, run-with-home.sh, and
run-emulator.sh. Each calls the next after adding some behavior, you can
call later scripts directly if you don't want that behavior. The first enables
distcc, the second provides a second virtual drive (/dev/hdb) with extra
space to build in, and the third fires up qemu.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 27 Feb 2008 22:32:25 -0600 |
parents | 9076557fcf53 |
children | e6a201119439 |
files | include.sh mini-native.sh package-mini-native.sh sources/toys/run-with-distcc.sh sources/toys/run-with-home.sh |
diffstat | 5 files changed, 90 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/include.sh Tue Feb 26 19:11:28 2008 -0600 +++ b/include.sh Wed Feb 27 22:32:25 2008 -0600 @@ -200,7 +200,11 @@ echo "=== Building $1 ($ARCH_NAME)" echo "Snapshot '$1'..." - cd "${WORK}" && + cd "${WORK}" || dienow + if [ $# -lt 3 ] + then + rm -rf "${CURSRC}" || dienow + fi mkdir -p "${CURSRC}" && cp -lfR "${SRCTREE}/$1/"* "${CURSRC}" @@ -265,7 +269,6 @@ # Which platform are we building for? export WORK="${BUILD}/temp-$ARCH" - rm -rf "${WORK}" mkdir -p "${WORK}" # Say "unknown" in two different ways so it doesn't assume we're NOT # cross compiling when the host and target are the same processor. (If host @@ -284,42 +287,6 @@ export CROSS="${BUILD}/cross-compiler-$ARCH" export NATIVE="${BUILD}/mini-native-$ARCH" export PATH="${CROSS}/bin:$PATH" - export IMAGE="${BUILD}/image-${ARCH}.ext2" - - # output run-$ARCH.sh script - - # Start with distcc setup - - cat > "$BUILD/run-$ARCH.sh" << 'EOF' -#!/bin/bash - -if [ "$1" == "--crosspath" ] -then - DCC="$(which distccd)" - [ -z "$DCC" ] && DCC="$2"/host/distcc - PATH="$(readlink -f "$2/distcc")" "$DCC" --listen 127.0.0.1 --log-stderr \ - --log-level error --daemon -a 127.0.0.1 --no-detach & # 2>/dev/null - DCC1=/tools/distcc: - CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+1] - DCC2="DISTCC_HOSTS=10.0.2.2 CPUS=$CPUS" -else - DCC1= - DCC2= - CPUS="CPUS=1" -fi -EOF - - # Call the appropriate emulator - - emulator_command image-$ARCH.ext2 zImage-$ARCH \ - 'rw init=/tools/bin/qemu-setup.sh panic=1 PATH=$DCC1/tools/bin $DCC2' \ - >> "$BUILD/run-$ARCH.sh" && - - # distcc cleanup - - echo -e '\nkill `jobs -p`' >> "$BUILD/run-$ARCH.sh" && - chmod +x "$BUILD/run-$ARCH.sh" - else export WORK="${BUILD}/host-temp" mkdir -p "${WORK}"
--- a/mini-native.sh Tue Feb 26 19:11:28 2008 -0600 +++ b/mini-native.sh Wed Feb 27 22:32:25 2008 -0600 @@ -24,7 +24,7 @@ # build bootable kernel for target make ARCH="${KARCH}" allnoconfig KCONFIG_ALLCONFIG="${WORK}/miniconfig-linux" && make -j $CPUS ARCH="${KARCH}" CROSS_COMPILE="${ARCH}-" && -cp "${KERNEL_PATH}" "${BUILD}/zImage-${ARCH}" && +cp "${KERNEL_PATH}" "${WORK}/zImage-${ARCH}" && cd .. cleanup linux
--- a/package-mini-native.sh Tue Feb 26 19:11:28 2008 -0600 +++ b/package-mini-native.sh Wed Feb 27 22:32:25 2008 -0600 @@ -8,6 +8,8 @@ #("${WORK}/mksquashfs" "${NATIVE}/tools" "${WORK}/tools.sqf" \ # -noappend -all-root -info || dienow) | dotprogress +IMAGE="${WORK}/image-${ARCH}.ext2" + # A 64 meg sparse image rm -f "$IMAGE" dd if=/dev/zero of="$IMAGE" bs=1024 seek=$[64*1024-1] count=1 && @@ -37,11 +39,23 @@ chmod +x ${WORK}/uml-package.sh && linux rootfstype=hostfs rw quiet ARCH=${ARCH} PATH=/bin:/usr/bin:/sbin:/usr/sbin init="${HOSTTOOLS}/oneit -p ${WORK}/uml-package.sh" +# Call the appropriate emulator + +emulator_command image-$ARCH.ext2 zImage-$ARCH \ + 'rw init=/tools/bin/qemu-setup.sh panic=1 PATH=$DISTCC_PATH_PREFIX/tools/bin $DISTCC_VARS' \ + > "$WORK/run-emulator.sh" && + +chmod +x "$WORK/run-emulator.sh" + +# Create qemu-image-$ARCH.tar.bz2 + function shipit() { cd "$WORK" && mkdir qemu-image-$ARCH && - ln "$BUILD"/{image-$ARCH.ext2,zImage-$ARCH,run-$ARCH.sh} qemu-image-$ARCH + ln {image-$ARCH.ext2,zImage-$ARCH,run-*.sh} \ + "$SOURCES"/toys/run-with-{distcc,home}.sh \ + qemu-image-$ARCH && [ $? -ne 0 ] && dienow
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/toys/run-with-distcc.sh Wed Feb 27 22:32:25 2008 -0600 @@ -0,0 +1,37 @@ +#!/bin/bash + +# Wrapper script that sets up distcc on the host and tells the native build +# where to find it, then hands off to run-with-home.sh + +if [ ! -f "$1"/distcc/gcc ] +then + echo "Usage: $0 cross-compiler-path" >&2 + exit 1 +fi + +# Run the distcc daemon on the host system with $PATH restricted to the +# cross compiler's symlinks. + +DCC="$(which distccd)" +if [ -z "$DCC" ] +then + echo 'No distccd in $PATH' + exit 1 +fi + +PATH="$(readlink -f "$1/distcc")" "$DCC" --listen 127.0.0.1 --log-stderr \ + --log-level error --daemon -a 127.0.0.1 2>distccd.log # --no-detach + +# Prepare some environment variables for run-qemu.sh + +export DISTCC_PATH_PREFIX=/tools/distcc: +CPUS=$[$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)+1] +export DISTCC_VARS="DISTCC_HOSTS=10.0.2.2 CPUS=$CPUS" + +# Hand off to run-with-home.sh in the directory this script's running from. + +"$(readlink -f "$(which $0)" | sed -e 's@\(.*/\).*@\1@')"run-with-home.sh + +# Cleanup afterwards: Kill child processes we started (I.E. distccd). + +kill `jobs -p`
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/toys/run-with-home.sh Wed Feb 27 22:32:25 2008 -0600 @@ -0,0 +1,32 @@ +#!/bin/bash + +# Wrapper around run-qemu.sh that sets up an ext3 image as a second virtual +# hard drive, then calls run-qemu.sh + +# Default to image "hdb.img" + +HDB="$1" +[ -z "$HDB" ] && HDB="hdb.img" + +# Default size to create 2 gigabytes + +HDBSIZE="$2" +[ -z "$HDBSIZE" ] && HDBSIZE=2048 + + +# If we don't already have an hdb image, set up a 2 gigabyte sparse file and +# format it ext3. + +if [ ! -e "$HDB" ] +then + dd if=/dev/zero of="$HDB" bs=1024 seek=$[$HDBSIZE*1024-1] count=1 + mke2fs -b 1024 -F "$HDB" + tune2fs -j -c 0 -i 0 "$HDB" +fi + +export WITH_HOME="-hdb $HDB" + +# Find the directory this script's running out of +"$(readlink -f "$(which $0)" | sed -e 's@\(.*/\).*@\1@')"run-qemu.sh + +#qemu -cpu pentium2 -nographic -hda image-i686.ext2 $ADD_HDB -kernel zImage-i686 -append "rw init=/tools/bin/qemu-setup.sh panic=1 PATH=$DISTCC_PATH_PREFIX/tools/bin $DISTCC_VARS root=/dev/hda console=ttyS0"