[BusyBox] bb: generate Config.h entries from compiled busybox help
David Douthitt
ssrat at mailbag.com
Tue Jan 30 18:05:00 UTC 2001
Here is the shell script. It works under ash and bash and ksh; I
don't know about others like lash or sash.
--
David Douthitt
UNIX Systems Administrator
HP-UX, Linux, Unixware
n9ubh at callsign.net
-------------- next part --------------
#!/bin/sh
# Example output:
#
# BusyBox v0.49pre (2001.01.25-21:56+0000) multi-call binary -- GPL2
#
# Usage: busybox [function] [arguments]...
# or: [function] [arguments]...
#
# BusyBox is a multi-call binary that combines many common Unix
# utilities into a single executable. Most people will create a
# link to busybox for each function they wish to use, and BusyBox
# will act like whatever it was invoked as.
#
# Currently defined functions:
# busybox, cat, chgrp, chmod, chown, clear, cp, cut, date, dd, df,
# dmesg, du, dutmp, false, fdflush, find, grep, gunzip, gzip, halt,
# head, hostname, id, init, insmod, kill, killall, ln, loadkmap,
# logger, ls, makedevs, md5sum, mkdir, mkfs.minix, mknod, mktemp,
# more, mount, mv, nslookup, ping, printf, rdate, renice, rm, rmdir,
# rmmod, sort, swapoff, swapon, sync, tail, tar, tee, touch, tr,
# true, umount, uname, uniq, update, uptime, usleep, wc, which,
# whoami, xargs, zcat
BUSYBOX=${1:-$(which busybox)}
if [ -z "$BUSYBOX" ]; then
echo Could not find busybox!
exit 1
elif [ ! -x "$BUSYBOX" ]; then
echo $BUSYBOX not executable!
exit 1
fi
config_out () {
local CMD
# ...this does not work with busybox tr
# CMD=$(echo $1 | tr [:lower:] [:upper:])
CMD=$(echo $1 | tr "abcdefghijklmnopqrstuvwxyz." \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ_")
# The default case is valid though dangerous; we are assuming
# that busybox knows what its programs are. If a program
# is added that is toggled by a "combined" define (with other programs)
# then another special case will need to be added.
case $CMD in
SWAPON|SWAPOFF) echo "#define BB_SWAPONOFF" ;;
TRUE|FALSE) echo "#define BB_TRUE_FALSE" ;;
CHMOD|CHOWN|CHGRP) echo "#define BB_CHMOD_CHOWN_CHGRP" ;;
CP|MV) echo "#define BB_CP_MV" ;;
*) echo "#define BB_$CMD" ;;
esac
}
echo "// "
echo "// Busybox Applications ($(date "+%Y.%m.%d-%H:%M"))"
echo "// "
echo "// Compiled from: $($BUSYBOX 2>&1 | head -n 1)"
echo "// "
bb_apps () {
$BUSYBOX 2>&1 | sed '1,/^Currently/d; s/,//g;'
}
COUNT=$(bb_apps | wc -w | sed 's/^ *//')
( for cmd in $(bb_apps); do
config_out $cmd
done ) | sort | uniq
echo "//"
echo "// End Busybox Applications ($(date "+%Y.%m.%d-%H:%M"))"
echo "//"
echo "// $COUNT applications defined..."
echo "//"
More information about the busybox
mailing list