diff system-image.sh @ 999:4bd1bc15a744

Move distcc setup to dev-environment.sh. Fix bug where CPUS wasn't defined if distcc wasn't being used (leading to make -j with no limit, and OOM conditions in the emulated system).
author Rob Landley <rob@landley.net>
date Mon, 15 Mar 2010 06:01:36 -0500
parents 30e4bab11f9e
children 6a6a9e8de6ef
line wrap: on
line diff
--- a/system-image.sh	Sun Mar 14 01:18:27 2010 -0600
+++ b/system-image.sh	Mon Mar 15 06:01:36 2010 -0500
@@ -54,8 +54,10 @@
 
 # Build kernel in parallel with initramfs
 
-echo "make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS $VERBOSITY"
-( make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS $VERBOSITY || dienow ) &
+[ ! -e "$STAGE_DIR/zImage-$ARCH" ] &&
+  echo "make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS $VERBOSITY" &&
+  ( make -j $CPUS ARCH=$BOOT_KARCH $DO_CROSS $LINUX_FLAGS $VERBOSITY ||
+    dienow ) &
 
 # Embed an initramfs image in the kernel?
 
@@ -144,8 +146,8 @@
 
 # Install kernel
 
-[ -d "${TOOLS}/src" ] && cp .config "${TOOLS}"/src/config-linux
-cp "${KERNEL_PATH}" "${STAGE_DIR}/zImage-${ARCH}"
+[ -d "$TOOLS/src" ] && cp .config "$TOOLS/src/config-linux"
+cp "$KERNEL_PATH" "$STAGE_DIR/zImage-$ARCH"
 
 cleanup
 
@@ -171,21 +173,12 @@
 # filesystem, kernel, and base kernel command line arguments in case you want
 # to use an emulator other than qemu, but put the default case in qemu_defaults
 
-cat > "$STAGE_DIR/dev-environment.sh" << EOF &&
-#!/bin/sh
-
-# Run the emulator with default values intended for a development environment.
+(echo -e "ARCH=$ARCH\nrun_emulator()\n{" &&
+ emulator_command "$IMAGE" zImage-$ARCH &&
+ echo "}" || dienow) > "$STAGE_DIR/run-emulator.sh"
 
-QEMU_MEMORY=256 HDB=hdb.img HDBMEGS=2048 ./run-emulator.sh
-EOF
-chmod +x "$STAGE_DIR/dev-environment.sh" &&
-cp "$SOURCES/toys/unique-port.sh" "$STAGE_DIR/run-emulator.sh" &&
-sed -e 's/^ARCH=.*/ARCH='"$ARCH"/  "$SOURCES/toys/run-emulator.sh" >> \
-  "$STAGE_DIR/run-emulator.sh" &&
-chmod +x "$STAGE_DIR/run-emulator.sh" &&
-emulator_command "$IMAGE" zImage-$ARCH >> "$STAGE_DIR/run-emulator.sh"
-
-[ $? -ne 0 ] && dienow
+cat "$SOURCES"/toys/{unique-port,dev-environment}.sh >> "$STAGE_DIR/dev-environment.sh" &&
+chmod +x "$STAGE_DIR/dev-environment.sh" || dienow
 
 # Tar it up.