Mercurial > hg > aboriginal
changeset 608:ab76d4cdd392
Jean Wolter pointed out that running RECORD_COMMANDS=1 twice could create circular symlinks. Hopefully fixed now, and some related cleanups/clarifications.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 03 Feb 2009 01:42:29 -0600 |
parents | c1659b564005 |
children | 3c30ce98c273 |
files | host-tools.sh sources/include.sh |
diffstat | 2 files changed, 31 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/host-tools.sh Mon Feb 02 05:50:02 2009 -0600 +++ b/host-tools.sh Tue Feb 03 01:42:29 2009 -0600 @@ -19,30 +19,33 @@ # If we want to record the host command lines, so we know exactly what commands # the build uses. -if [ ! -z "$RECORD_COMMANDS" ] && [ ! -f "$BUILD/wrapdir/wrappy" ] +if [ ! -z "$RECORD_COMMANDS" ] then - echo setup wrapdir + if [ ! -f "$BUILD/wrapdir/wrappy" ] + then + echo setup wrapdir - # Build the wrapper and install it into build/wrapdir/wrappy - rm -rf "$BUILD/wrapdir" - mkdir "$BUILD/wrapdir" && - $CC -Os "$SOURCES/toys/wrappy.c" -o "$BUILD/wrapdir/wrappy" || dienow + # Build the wrapper and install it into build/wrapdir/wrappy + rm -rf "$BUILD/wrapdir" + mkdir "$BUILD/wrapdir" && + $CC -Os "$SOURCES/toys/wrappy.c" -o "$BUILD/wrapdir/wrappy" || dienow - # Loop through each $PATH element and create a symlink to the wrapper with - # that name. + # Loop through each $PATH element and create a symlink to the wrapper with + # that name. - for i in $(echo $PATH | sed 's/:/ /g') - do - for j in $(ls $i) + for i in $(echo $PATH | sed 's/:/ /g') do - [ -f "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j" + for j in $(ls $i) + do + [ -f "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j" + done done - done + + # Adjust things to use wrapper directory - # Adjust things to use wrapper directory - - export WRAPPY_REALPATH="$PATH" - PATH="$BUILD/wrapdir" + export WRAPPY_REALPATH="$PATH" + PATH="$BUILD/wrapdir" + fi # If we're not recording the host command lines, then populate a directory # with host versions of all the command line utilities we're going to install @@ -73,7 +76,7 @@ for i in ar as nm cc gcc make ld do - [ ! -f "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow) + [ ! -e "${HOSTTOOLS}/$i" ] && (ln -s `which $i` "${HOSTTOOLS}/$i" || dienow) done # Build toybox @@ -175,7 +178,7 @@ # Make sure the host tools we just built are also in wrapdir for j in $(ls "$HOSTTOOLS") do - [ -f "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j" + [ -e "$BUILD/wrapdir/$j" ] || ln -s wrappy "$BUILD/wrapdir/$j" done fi
--- a/sources/include.sh Mon Feb 02 05:50:02 2009 -0600 +++ b/sources/include.sh Tue Feb 03 01:42:29 2009 -0600 @@ -29,7 +29,7 @@ export BUILD="${TOP}/build" export HOSTTOOLS="${BUILD}/host" -[ -z "$WRAPPY_LOGDIR" ] && WRAPPY_LOGDIR="$BUILD" +mkdir -p "${SRCDIR}" || dienow # Adjust $PATH @@ -43,16 +43,21 @@ fi fi +# Setup for $RECORD_COMMANDS + +# WRAPPY_LOGPATH is set unconditionally in case host-tools.sh needs to +# enable wrapping partway through its own build. Extra environment variables +# don't actually affect much, it's changing $PATH that changes behavior. + STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'` +[ -z "$WRAPPY_LOGDIR" ] && WRAPPY_LOGDIR="$BUILD" export WRAPPY_LOGPATH="$WRAPPY_LOGDIR/cmdlines.${STAGE_NAME}.setupfor" -if [ -f "$BUILD/wrapdir/wrappy" ] +if [ ! -z "$RECORD_COMMANDS" ] && [ -f "$BUILD/wrapdir/wrappy" ] then export WRAPPY_REALPATH="$PATH" PATH="$BUILD/wrapdir" fi -mkdir -p "${SRCDIR}" || dienow - # Tell bash not to cache the $PATH because we modify it. Without this, bash # won't find new executables added after startup. set +h