view sources/root-filesystem/sbin/record-commands @ 1472:a4673f17b7c0

Add record-commands wrapper and plumbing to target image, so you can record-commands /mnt/init in a native build.
author Rob Landley <rob@landley.net>
date Tue, 06 Dec 2011 21:29:16 -0600
parents
children 7ab15346cbf6
line wrap: on
line source

#!/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"