changeset 357:5c61d556fe0c

Make forkbomb.sh --fork work with RECORD_COMMANDS.
author Rob Landley <rob@landley.net>
date Sun, 06 Jul 2008 04:51:05 -0500
parents 25b18621de1b
children 9829e6cc8637
files forkbomb.sh include.sh
diffstat 2 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/forkbomb.sh	Sat Jul 05 23:34:01 2008 -0500
+++ b/forkbomb.sh	Sun Jul 06 04:51:05 2008 -0500
@@ -19,6 +19,12 @@
   if [ $# -ne 0 ]
   then
 
+     if [ ! -z "$RECORD_COMMANDS" ]
+     then
+       mkdir -p build/cmdlines-host &&
+       export WRAPPY_LOGDIR=`pwd`/build/cmdlines-host
+     fi
+
     # The first thing we need to do is download the source, build the host
     # tools, and extract the source packages.  This is only done once (not
     # repeated for each architecure), so we do it up front here.  Doing this
@@ -47,31 +53,27 @@
      # we piped the output of the subshell to tee, we can't get the exit code
      # of the subshell.  So we use a sentinel file: if it wasn't deleted, the
      # build went "boing" and should stop now.
+
      rm .kthxbye 2>/dev/null && exit 1
-
-     # If we're using host tools and logging the commands run, save the logs
-     # into a subdirectory.
-     if [ ! -z "$RECORD_COMMANDS" ]
-     then
-       mkdir -p build/cmdlines-host &&
-       mv build/cmdlines.* build/cmdlines-host || exit 1
-     fi
   fi
 
   # Loop through each architecture and call "buildarch" as appropriate.
 
   for i in `cd sources/configs; ls`
   do
+
+    if [ ! -z "$RECORD_COMMANDS" ]
+    then
+      mkdir -p build/cmdlines-$i || exit 1
+      export WRAPPY_LOGDIR=`pwd`/build/cmdlines-host
+    fi
+
+
     # Build sequentially.
 
     if [ "$1" == "--nofork" ]
     then
       buildarch $i 2>&1 | tee out-$i.txt || exit 1
-      if [ ! -z "$RECORD_COMMANDS" ]
-      then
-        mkdir -p build/cmdlines-$i &&
-        mv build/cmdlines.* build/cmdlines-$i || exit 1
-      fi
 
     # Build in parallel
 
--- a/include.sh	Sat Jul 05 23:34:01 2008 -0500
+++ b/include.sh	Sun Jul 06 04:51:05 2008 -0500
@@ -44,6 +44,8 @@
 export BUILD="${TOP}/build"
 export HOSTTOOLS="${BUILD}/host"
 
+[ -z "$WRAPPY_LOGDIR" ] && WRAPPY_LOGDIR="$BUILD"
+
 # Adjust $PATH
 
 if [ "$PATH" != "$HOSTTOOLS" ]
@@ -57,7 +59,7 @@
 fi
 
 STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
-export WRAPPY_LOGPATH="$BUILD/cmdlines.${STAGE_NAME}.setupfor"
+export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.setupfor"
 if [ -f "$BUILD/wrapdir/wrappy" ]
 then
   export WRAPPY_REALPATH="$PATH"
@@ -300,7 +302,7 @@
 
 function setupfor()
 {
-  export WRAPPY_LOGPATH="$BUILD/cmdlines.${STAGE_NAME}.setupfor"
+  export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.setupfor"
 
   # Make sure the source is already extracted and up-to-date.
   cd "${SRCDIR}" &&
@@ -335,5 +337,5 @@
     mkdir -p "$2" &&
     cd "$2" || dienow
   fi
-  export WRAPPY_LOGPATH="$BUILD/cmdlines.${STAGE_NAME}.$1"
+  export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.$1"
 }