Giter VIP home page Giter VIP logo

android-busybox-ndk's Introduction

The aim is to gather information and patches on how to build busybox using the compilers shipped with the Android NDK.

Currently up-to-date as of busybox 1.26.2, with added patches to avoid constant host warnings if compiling in Cygwin.

Building busybox with the standard Android NDK

[email protected] discovered that a number [1,2] of upstream changes make it possible to build the latest git version of busybox, without requiring any patches:

# get busybox sources
git clone git://busybox.net/busybox.git
# use default upstream config
cp configs/android_ndk_defconfig .config

# add the target NDK cross-compiler to your exported PATH and CROSS_COMPILE prefix
export PATH="/path/to/your/android-ndk/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$PATH"
export CROSS_COMPILE="/path/to/your/android-ndk/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-"

# if android-ndk is not installed in /opt/android-ndk, edit SYSROOT= in .config
# (alternately make all but CFLAGS blank if using standalone cross-compiler)
nano .config

# adjust enabled applets/features (optional)
make menuconfig

# build it!
make ARCH=arm CROSS_COMPILE="$CROSS_COMPILE"

These applets are available without any patches:

[, [[, acpid, adjtimex, ar, arp, 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, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, dpkg-deb, du, dumpkmap, echo, ed, egrep, env, envdir, envuidgid, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flash_lock, flash_unlock, flashcp, flock, fold, free, freeramdisk, fsync, ftpd, ftpget, ftpput, fuser, getopt, grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostname, httpd, hwclock, id, ifconfig, ifdown, ifup, inetd, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, iplink, iptunnel, kbd_mode, kill, killall, killall5, klogd, less, linuxrc, ln, loadkmap, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mesg, mkdir, mkdosfs, mkfifo, mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more, mpstat, mv, nbd-client, nc, netstat, nice, nmeter, nohup, od, openvt, patch, pidof, ping, 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, svc, svlogd, switch_root, sync, sysctl, tac, tail, tar, tcpsvd, tee, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, true, tty, ttysize, tunctl, tune2fs, udhcpc, udpsvd, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, volname, watch, wc, wget, which, whoami, whois, xargs, xz, xzcat, yes, zcat

By applying the included patches to the busybox code-base you additionally get:

arping, blkdiscard, conspy, df, eject, ether-wake, fsck, fsck.minix, hush, ifenslave, ifplugd, ipcrm, ipcs, ipneigh, iproute, iprule, loadfont, logread, microcom, mke2fs, mkfs.ext2, mkfs.minix, mkfs.reiser, mount, mountpoint, nanddump, nandwrite, nameif, nslookup (with own resolver), pgrep, ping6, rfkill, setfont, swapon, swapoff, syslogd, telnet, telnetd, traceroute6, ubi*, udhcpd, umount, watchdog, zcip

(when applying certain patches you should include all patches with a lower number as well, there are often dependencies between them).

The remaining config options of 'make defconfig' do not build properly. See below for the list of config options and corresponding error.

Config options that do not build, code error

These errors indicate bugs (usually in the restricted Android libc library, called bionic), and can often be fixed by adding patches to the busybox code.

  • All of Login/Password Management Utilities, CONFIG_USE_BB_PWD_GRP -- error: 'struct passwd' has no member named 'pw_gecos'
  • disables CONFIG_ADD_SHELL, CONFIG_REMOVE_SHELL, CONFIG_ADDUSER, CONFIG_ADDGROUP, CONFIG_DELUSER, CONFIG_DELGROUP, CONFIG_GETTY, CONFIG_LOGIN, CONFIG_PASSWD, CONFIG_CRYPTPW, CONFIG_CHPASSWD, CONFIG_MKPASSWD, CONFIG_SU, CONFIG_SULOGIN, CONFIG_VLOCK
  • CONFIG_ARPING -- has patch -- networking/arping.c:96: error: invalid use of undefined type 'struct arphdr'
  • CONFIG_BLKDISCARD -- has patch -- util-linux/blkdiscard.c:72:26: error: 'BLKSECDISCARD' undeclared (first use in this function)
  • CONFIG_ETHER_WAKE -- has patch -- networking/ether-wake.c:275: error: 'ETH_ALEN' undeclared (first use in this function)
  • CONFIG_FEATURE_IP_ROUTE, CONFIG_FEATURE_IP_RULE, CONFIG_IP_ROUTE, CONFIG_IPRULE -- has patch -- networking/libiproute/iproute.c:85:9: error: 'RTA_TABLE' undeclared (first use in this function)
  • CONFIG_FEATURE_IPV6 -- has patch -- networking/ifconfig.c:82: error: redefinition of 'struct in6_ifreq'
  • disables CONFIG_PING6, CONFIG_FEATURE_IFUPDOWN_IPV6, CONFIG_TRACEROUTE6
  • CONFIG_FEATURE_UTMP, CONFIG_FEATURE_WTMP -- init/halt.c:86: error: 'RUN_LVL' undeclared (first use in this function)
  • disables CONFIG_WHO, CONFIG_USERS, CONFIG_LAST, CONFIG_RUNLEVEL, CONFIG_WALL
  • CONFIG_FSCK_MINIX, CONFIG_MKFS_MINIX -- has patch -- util-linux/fsck_minix.c:111: error: 'INODE_SIZE1' undeclared here (not in a function)
  • CONFIG_LFS -- on purpose? -- has patch (experimental) -- include/libbb.h:256: error: size of array 'BUG_off_t_size_is_misdetected' is negative
  • CONFIG_LOGGER -- sysklogd/logger.c:36: error: expected ';', ',' or ')' before '*' token
  • CONFIG_NANDDUMP, CONFIG_NANDWRITE -- has patch -- miscutils/nandwrite.c:151:35: error: 'MTD_FILE_MODE_RAW' undeclared (first use in this function)
  • CONFIG_NSLOOKUP -- has patch (with own resolver) -- networking/nslookup.c:126: error: dereferencing pointer to incomplete type
  • CONFIG_SWAPOFF, CONFIG_SWAPON -- has patch -- util-linux/swaponoff.c:96: error: 'MNTOPT_NOAUTO' undeclared (first use in this function)
  • CONFIG_ZCIP -- has patch -- networking/zcip.c:51: error: field 'arp' has incomplete type

Config options that do not build, missing library

These errors indicate that the library is missing from Android's libc implementation.

sys/sem.h -- has patch

  • CONFIG_IPCS -- util-linux/ipcs.c:32:21: error: sys/sem.h: No such file or directory
  • CONFIG_LOGREAD -- sysklogd/logread.c:20:21: error: sys/sem.h: No such file or directory
  • CONFIG_SYSLOGD -- sysklogd/syslogd.c:68:21: error: sys/sem.h: No such file or directory

sys/kd.h -- has patch

  • CONFIG_CONSPY -- miscutils/conspy.c:45:20: error: sys/kd.h: No such file or directory
  • CONFIG_LOADFONT, CONFIG_SETFONT -- console-tools/loadfont.c:33:20: error: sys/kd.h: No such file or directory

arpa/telnet.h -- has patch

  • CONFIG_TELNET -- networking/telnet.c:39:25: error: arpa/telnet.h: No such file or directory
  • CONFIG_TELNETD -- networking/telnetd.c:53:25: error: arpa/telnet.h: No such file or directory

others

  • CONFIG_EJECT -- has patch -- miscutils/eject.c:30:21: error: scsi/sg.h: No such file or directory
  • CONFIG_FEATURE_HAVE_RPC, CONFIG_FEATURE_INETD_RPC -- networking/inetd.c:176:22: error: rpc/rpc.h: No such file or directory
  • CONFIG_FEATURE_IFCONFIG_SLIP -- has patch -- networking/ifconfig.c:59:26: error: net/if_slip.h: No such file or directory
  • CONFIG_FEATURE_SHADOWPASSWDS -- include/libbb.h:61:22: error: shadow.h: No such file or directory
  • CONFIG_USE_BB_PWD_GRP, CONFIG_USE_BB_SHADOW would potentially work around, but there is a code error as listed above
  • CONFIG_HUSH -- has patch -- shell/hush.c:89:18: error: glob.h: No such file or directory
  • CONFIG_I2C* -- miscutils/i2c_tools.c:65:27: error: linux/i2c-dev.h: No such file or directory
  • disables CONFIG_I2CGET, CONFIG_I2CSET, CONFIG_I2CDUMP, CONFIG_I2CDETECT
  • CONFIG_IFENSLAVE -- has patch -- networking/ifenslave.c:132:30: error: linux/if_bonding.h: No such file or directory
  • CONFIG_IFPLUGD -- has patch -- networking/ifplugd.c:38:23: error: linux/mii.h: No such file or directory
  • CONFIG_IPCRM -- has patch -- util-linux/ipcrm.c:25:21: error: sys/shm.h: No such file or directory
  • CONFIG_IPNEIGH -- has patch -- networking/libiproute/ipneigh.c:14:29: fatal error: linux/neighbour.h: No such file or directory
  • CONFIG_LINUX32, CONFIG_LINUX64, CONFIG_SETARCH -- util-linux/setarch.c:23:29: error: sys/personality.h: No such file or directory
  • CONFIG_MT -- miscutils/mt.c:19:22: error: sys/mtio.h: No such file or directory
  • CONFIG_NTPD -- networking/ntpd.c:49:23: error: sys/timex.h: No such file or directory
  • CONFIG_RFKILL -- has patch -- miscutils/rfkill.c:40:26: error: linux/rfkill.h: No such file or directory
  • CONFIG_WATCHDOG -- has patch -- miscutils/watchdog.c:24:28: error: linux/watchdog.h: No such file or directory
  • CONFIG_UBI* -- has patch -- miscutils/ubi_tools.c:67:26: error: mtd/ubi-user.h: No such file or directory
  • disables CONFIG_UBIATTACH, CONFIG_UBIDETACH, CONFIG_UBIMKVOL, CONFIG_UBIRMVOL, CONFIG_UBIRSVOL, CONFIG_UBIUPDATEVOL, CONFIG_UBIRENAME

Config options that give a linking error

Android's libc implementation claims to implement the methods in the error, but surprisingly does not.

  • mntent -- has patch

  • CONFIG_DF -- undefined reference to 'setmntent', 'endmntent'

  • CONFIG_FSCK -- undefined reference to 'setmntent', 'getmntent_r', 'endmntent'

  • CONFIG_MKE2FS -- undefined reference to 'setmntent', 'endmntent'

  • CONFIG_MKFS_EXT2 -- undefined reference to 'setmntent', 'endmntent'

  • CONFIG_MKFS_REISER -- undefined reference to 'setmntent', 'endmntent'

  • CONFIG_MOUNTPOINT -- undefined reference to 'setmntent', 'endmntent'

  • CONFIG_MOUNT -- undefined reference to 'setmntent', 'getmntent_r'

  • CONFIG_UMOUNT -- undefined reference to 'setmntent', 'getmntent_r', 'endmntent'

  • others

  • CONFIG_FEATURE_HTTPD_AUTH_MD5 -- undefined reference to 'crypt'

  • CONFIG_FEATURE_SYNC_FANCY -- undefined reference to 'syncfs'

  • CONFIG_HOSTID -- undefined reference to 'gethostid'

  • CONFIG_LOGNAME -- undefined reference to 'getlogin_r'

  • CONFIG_MDEV -- undefined reference to 'sigtimedwait'

  • CONFIG_MICROCOM -- has patch -- undefined reference to 'cfsetspeed'

  • CONFIG_NAMEIF -- has patch -- undefined reference to 'ether_aton_r'

  • CONFIG_NSENTER -- undefined reference to 'setns'

  • CONFIG_UDHCPD -- has patch -- undefined reference to 'ether_aton_r'

  • CONFIG_UNSHARE -- undefined reference to 'unshare'

android-busybox-ndk's People

Contributors

osm0sis avatar tias avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

silviandevries

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.