http://blog.csdn.net/andyhuabing/article/details/6645992
由于Android自带的toolbox(位于/system/bin中)也太简略了点,有些命令如find,Android并不支持或者支持得不好。所以有必要为Android加入busybox工具,通过编译得到一个可以在Android里面运行的busybox工具,我们就可以使用众多常见的linux命令了,如find,touch等。
1、下载busybox源码或者从厂商给的SDK中获取到
2、下载交叉编译器或者使用SDK工具链,保证与平台使用的一致即可,否则arch或version不同导致命令执行失败
3、开始编译,进入busybox源码目录.
先执行make menuconfig命令对编译过程进行配置. 过程如下:
Busybox Settings -> Build Options ->
[*] Build BusyBox as a static binary (no shared libs) 这个要选上,因上这样子编译出来的busyBox才是可以独立运行的。
(/home/jo/tool/arm-2008q3/bin/arm-none-linux-gnueabi-) Cross Compiler prefex 这是交叉编译器的"路径+前缀",要根据具体的情况来设置。
Busybox Settings -> Installation Options->
[*] Don’t use /usr 这样子编译出来的busybox才不会安装到你主机的/usr目录下。一定要选上。
make install 可生成默认为./_install目录下面
4、安装busybox
一般将busybox下面的命令放在out....下面的system目录下,注意busybox中很多命令都是软链接的,所以不要使用window的copy命令,使用linux cp -fR命令,如果一定要在window下使用先在linux下打包再解包使用。
如下所示:
lrwxrwxrwx 1 root root 7 05-25 13:59 time -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 timeout -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 top -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 touch -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 tr -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 traceroute -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 traceroute6 -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 true -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 tty -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 ttysize -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 udpsvd -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 umount -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 uname -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 uncompress -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 unexpand -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 uniq -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 unix2dos -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 unlzma -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 unlzop -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 unzip -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 uptime -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 usleep -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 uudecode -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 uuencode -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 vi -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 vlock -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 volname -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 wall -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 watch -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 wc -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 wget -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 which -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 who -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 whoami -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 xargs -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 yes -> busybox
lrwxrwxrwx 1 root root 7 05-25 13:59 zcat -> busybox
如果不是这样子的就是错的或者其大文件size为0也是错的。
5、使用 修改/init.rc文件设置环境变量
要提醒的是, 修改PATH环境变量的时候, 应该把busybox常用命令的路径"/system/busybox/bin"放在Android的常用命令路径"/system/bin"的前面, 否则, 先查找得到的将不是busybox的命令, 可以这样设置:
export PATH/system/busybox/bin:/system/busybox/sbin: /sbin:/system/sbin:/system/bin:/s