busybox应用于android系统

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目录下。一定要选上。

  如果编译过程中产生无法找到头文件的错误, 可指定交叉编译器用到的头文件所在路径,使用-I 命令即可

  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


Busybox for Android v1.20.2 Stable built by Linus Yang [Aug 12, 2012 Update] - Update to 1.20.2 stable [Features] - Tested on Android 2.1, 2.3, 4.0 and 4.1. Should be capable with all Android devices (Use at your own risk) - ELF armv5te binary (statically linked) - More suitable for Android than the prebuilt ARM binaries from busybox.net - IPv6 support, using own DNS resolver, correct user name display and more improvements for Android [Install] wget http://yangapp.googlecode.com/files/busybox-1.20.2 mv busybox-1.20.2 busybox chmod 755 busybox ./busybox --install [INSTALL_DIR] You can build by yourself from my github's project: (forked from tias/android-busybox-ndk) https://github.com/linusyang/android-busybox-ndk [Information] BusyBox v1.20.2-linusyang (2012-08-12 21:41:27 CST) multi-call binary. Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko and others. Licensed under GPLv2. See source distribution for full notice. Usage: busybox [function] [arguments]... or: busybox --list[-full] or: busybox --install [-s] [DIR] 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: [, [[, acpid, adjtimex, ar, arp, arping, ash, awk, base64, basename, bbconfig, beep, blkid, blockdev, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cttyhack, cut, date, dc, dd, deallocvt, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flash_lock, flash_unlock, flashcp, flock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifup, inetd, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, less, linuxrc, ln, loadkmap, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.minix, mkfs.reiser, mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap, popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev, readlink, readprofile, realpath, reboot, reformime, renice, reset, resize, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run-parts, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setconsole, setkeycodes, setlogcons, setserial, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, smemcap, softlimit, sort, split, start-stop-daemon, stat, strings, stty, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, ttysize, tunctl, tune2fs, ubiattach, ubidetach, ubimkvol, ubirmvol, ubirsvol, ubiupdatevol, udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, volname, watch, watchdog, wc, wget, which, whoami, whois, xargs, xz, xzcat, yes, zcat, zcip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值