本文介绍的是用Android NDK方式去编译busybox, 编译环境: Mac OS X EI 10.11 使用环境:三星N910p、Android 6.0.1、已ROOT。
准备
NDK下载
https://developer.android.com/ndk/downloads/index.html
Busybox的源代码下载
下载最新版 busybox-1.24.2.tar.bz2
编译busybox
解压后进入源码目录
$ cp configs/android_ndk_defconfig .config
修改.config文件内容,修改CONFIG_SYSROOT及CONFIG_PIE
CONFIG_SYSROOT="/Users/kule/android-ndk-r10e/platforms/android-15/arch-arm"
CONFIG_PIE=y
开始编译
# 清空环境变量
$ export CFLAGS=
$ export LDFLAGS=
$ make
其间如果提示找不到相关头文件,则禁用相关功能则可 编译成功后,在根目录下会出现busybox文件
安装busybox
将手机开启debug模式,然后连上电脑
#将busybox push进SD卡
$ adb push busybox /sdcard/
#进入终端
$ adb shell
#取得root权限
$ su
#重新mount使/system可写
$ mount -o remount,rw /dev/block/mtdblock6 /system
#移动busybox
$ mv /sdcard/busybox /system/bin/
#设为可执行
$ chmod 755 /system/bin/busybox
#恢复/system为只读
$ mount -o remount,ro /dev/block/mtdblock6 /system
测试
#进入终端
$ adb shell
#执行busybox
$ busybox
BusyBox v1.24.2 (2016-05-20 03:21:26 CST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
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:
[, [[, ar, arp, awk, base64, basename, bbconfig, beep, blkid, blockdev,
bootchartd, 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, dc, dd, deallocvt, depmod, devmem,
diff, dirname, dmesg, dnsd, dos2unix, dpkg, dpkg-deb, du, dumpkmap,
echo, ed, egrep, env, envdir, envuidgid, expand, expr, fakeidentd,
false, fatattr, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole,
fgrep, find, findfs, flash_lock, flash_unlock, flashcp, flock, fold,
free, freeramdisk, fstrim, fsync, ftpd, ftpget, ftpput, fuser, getopt,
grep, gunzip, gzip, halt, hd, hdparm, head, hexdump, httpd, hwclock,
ifconfig, ifdown, ifup, init, inotifyd, insmod, install, iostat, ip,
ipaddr, ipcalc, iplink, iproute, iprule, iptunnel, klogd, less,
linuxrc, ln, loadkmap, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof,
lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man,
md5sum, mesg, mkdir, mkfifo, mknod, mkswap, mktemp, modinfo, modprobe,
more, mpstat, mv, nanddump, nbd-client, nc, netstat, nice, nmeter,
nohup, od, openvt, patch, pidof, ping, pipe_progress, pmap, popmaildir,
poweroff, powertop, printenv, printf, ps, pscan, pstree, pwd, pwdx,
raidautorun, 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, sha1sum, sha256sum, sha3sum, sha512sum, showkey, shuf,
sleep, smemcap, softlimit, sort, split, start-stop-daemon, strings,
stty, sum, sv, svlogd, switch_root, sync, sysctl, tac, tail, tar,
tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top,
touch, tr, traceroute, true, truncate, ttysize, tunctl, tune2fs,
udhcpc, udpsvd, uevent, uname, uncompress, unexpand, uniq, unix2dos,
unlink, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode,
uuencode, vconfig, vi, volname, watch, wc, wget, which, whoami, whois,
xargs, xz, xzcat, yes, zcat
有类似以上内容输出,表示安装成功.
No comments:
Post a Comment