# HG changeset patch # User Rob Landley # Date 1323228556 21600 # Node ID a4673f17b7c01e96b1a4ca1b7268a6dc3877539a # Parent 9c2b7ec6b0c73575f215d55e94cb2f7df5b2c2c8 Add record-commands wrapper and plumbing to target image, so you can record-commands /mnt/init in a native build. diff -r 9c2b7ec6b0c7 -r a4673f17b7c0 simple-root-filesystem.sh --- a/simple-root-filesystem.sh Tue Dec 06 21:15:59 2011 -0600 +++ b/simple-root-filesystem.sh Tue Dec 06 21:29:16 2011 -0600 @@ -74,6 +74,10 @@ "${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -static -o "$STAGE_DIR/bin/hello-static" || dienow fi +# Debug wrapper for use with /usr/src/record-commands.sh + +"${ARCH}-cc" "$SOURCES/toys/wrappy.c" -Os $CFLAGS -o "$STAGE_DIR/bin/record-commands-wrapper" || dienow + # Do we need shared libraries? if [ "$BUILD_STATIC" != all ] diff -r 9c2b7ec6b0c7 -r a4673f17b7c0 sources/root-filesystem/sbin/record-commands --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/root-filesystem/sbin/record-commands Tue Dec 06 21:29:16 2011 -0600 @@ -0,0 +1,27 @@ +#!/bin/bash + +# Set up command recording wrapper + +[ -z "$WRAPDIR" ] && WRAPDIR=/tmp/record-commands +[ -z "$WRAPPY_LOGPATH" ] && + export WRAPPY_LOGPATH=/tmp/record-commands-log.txt + +if [ $# -eq 0 ] +then + echo "Usage: record-commands command..." + exit 1 +fi + +mkdir -p "$WRAPDIR" && + ln -s $(which record-commands-wrapper) "$WRAPDIR" || exit 1 + +echo "$PATH" | sed 's/:/\n/g' | while read DIR +do + find "$DIR/" -maxdepth 1 -mindepth 1 | sed 's@.*/@@' | while read FILE + do + ln -s record-commands-wrapper "$WRAPDIR/$FILE" 2>/dev/null + done +done + +OLDPATH="$PATH" PATH="$WRAPDIR:$PATH" "$@" +rm -rf "$WRAPDIR"