Two changes to record-commands: 1) busybox find doesn't understand commas

in -type so use parentheses and -o, 2) change semantics (sourcing changes
variables) so running with no arguments sets up a persistent wrapper
and outputs an export line to update variables.
This commit is contained in:
Rob Landley 2024-04-20 09:58:06 -05:00
parent 475d3aa857
commit 7c6aecd477
3 changed files with 11 additions and 16 deletions

View File

@ -82,7 +82,7 @@ if [ -z "$NOLOGPATH" ]; then
CROSS_COMPILE=${CROSS_COMPILE##*/}
export WRAPDIR="$BUILD/record-commands" LOGPATH="$LOG"-commands.txt
rm -rf "$WRAPDIR" "$LOGPATH" generated/obj &&
WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 source mkroot/record-commands ||
eval "$(WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 mkroot/record-commands)"||
exit 1
fi

View File

@ -5,23 +5,15 @@
[ -z "$WRAPDIR" ] && WRAPDIR="$PWD"/record-commands && RM=$(which rm)
[ -z "$LOGPATH" ] && export LOGPATH="$PWD"/log.txt
if [ ${#BASH_SOURCE[@]} -lt 2 ] && [ $# -eq 0 ]
then
echo "usage: WRAPDIR=dir LOGPATH=log.txt record-commands COMMAND..."
echo 'Then examine log.txt. "record-commands echo" to just setup $WRAPDIR'
exit 1
fi
if [ ! -x "$WRAPDIR/logpath" ]
then
LOG="$(which logpath)"
mkdir -p "$WRAPDIR" || exit 1
[ -e "$(which logpath)" ] || { cd "$(dirname $0)/.." &&
PREFIX="$WRAPDIR/" scripts/single.sh logpath && LOG=$(readlink -f logpath)||
exit 1; }
cp -H "$LOG" "$WRAPDIR/logpath" || exit 1
[ -e "$LOG" ] && cp -H "$LOG" "$WRAPDIR/logpath" || { cd "$(dirname $0)/.." &&
PREFIX="$WRAPDIR/" scripts/single.sh logpath >/dev/null &&
LOG="$PWD/logpath" || exit 1; }
tr : '\n' <<< "$PATH" | while read i; do
find "$i" -type f,l -maxdepth 1 -executable -exec basename {} \; | \
find "$i" \( -type f -o -type l \) -maxdepth 1 -executable -exec basename {} \; | \
while read FILE; do ln -s logpath "$WRAPDIR/$FILE" 2>/dev/null; done
done
fi
@ -30,13 +22,14 @@ fi
rm -f "$LOGPATH"
# When sourced, set up wrapper for current context.
export PATH="$WRAPDIR:$PATH"
if [ ${#BASH_SOURCE[@]} -lt 2 ]
if [ $# -gt 0 ]
then
"$@"
PATH="$WRAPDIR:$PATH" "$@"
X=$?
[ -n "$RM" ] && "$RM" -rf "$WRAPDIR"
exit $X
else
echo export LOGPATH=${LOGPATH@Q} PATH=${WRAPDIR@Q}:${PATH@Q}
fi

View File

@ -700,5 +700,7 @@
#define USE_TOYBOX_NORECURSE(...)
#define CFG_TOYBOX_DEBUG 0
#define USE_TOYBOX_DEBUG(...)
#define CFG_TOYBOX_UID_SYS 100
#define CFG_TOYBOX_UID_USR 500
#define CFG_TOYBOX_FORCE_NOMMU 0
#define USE_TOYBOX_FORCE_NOMMU(...)