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 compiler shipped with the android NDK.

Patches and relevant pointers more than welcome, fork me or mail me: [email protected]

Building busybox with the standard android NDK

I recently 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 arm-linux-androideabi-* to your PATH
export PATH="$PATH:/path/to/your/android-ndk/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/"
# if android-ndk is not installed in /opt/android-ndk, edit SYSROOT= in .config
xdg-open .config

# build it!
make

This creates a busybox with the following applets:

[, [[, ar, arp, awk, base64, basename, 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, 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, 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, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, mkdir, mkfifo, mknod, mkswap, mktemp, modinfo, modprobe, more, mpstat, mv, 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, sha512sum, showkey, 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, 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

Using file android_ndk_defconfigPlus you additionally get following applets that are by default enabled for 'make defconfig':

acpid, ash, groups, id, mkdosfs, mkfs.vfat, nandump, nandwrite, sh, slattach, tty

By applying the included patches to the busybox code-base (and config android_ndk_config-w-patches), you additionally get:

adjtimex, arping, bbconfig, brctl, date, df, ether-wake, fsck, fsck.minix, hostname, hush, inetd, ionice, ipcrm, ipcs, kbd_mode, kill, killall, killall5, logread, microcom, mke2fs, mkfs.ext2, mkfs.minix, mkfs.reiser, mount, mountpoint, nameif, nslookup (with own resolver), pgrep, ping6, pivot_root, pkill, rdate, stat, swapon, swapoff, syslogd, traceroute6, ubi*, udhcpd, umount, watchdog, zcip

(when cherry-picking certain patches you have to include all patches with a lower number as well, there are dependencies between them except for 050 and 051).

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

The config android_ndk_stericson-like is a config similar to the one shipped by android-busybox (by stericson). You can download a binary built with this config (md5sum ab9f5cd5032af9fa7c20c2e9d0ec047d).

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 -- 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_SU, CONFIG_SULOGIN, CONFIG_VLOCK
  • CONFIG_ARPING -- has patch -- networking/arping.c:96: error: invalid use of undefined type 'struct arphdr'
  • CONFIG_BRCTL -- has patch -- networking/brctl.c:70: error: conflicting types for 'strtotimeval'
  • CONFIG_ETHER_WAKE -- has patch -- networking/ether-wake.c:275: error: 'ETH_ALEN' 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_INETD -- has patch -- /opt/android-ndk/platforms/android-9/arch-arm/usr/include/linux/un.h:18: error: expected specifier-qualifier-list before 'sa_family_t' and networking/inetd.c:562: error: 'struct sockaddr_un' has no member named 'sun_path'
  • CONFIG_IONICE -- has patch -- miscutils/ionice.c:23: error: 'SYS_ioprio_set' undeclared (first use in this function)
  • CONFIG_LFS -- on purpose? -- 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_NSLOOKUP -- has patch (with own resolver) -- networking/nslookup.c:126: error: dereferencing pointer to incomplete type
  • CONFIG_SWAPONOFF -- 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 androids 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

  • 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

  • others

  • CONFIG_EJECT -- 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 -- networking/ifconfig.c:59:26: error: net/if_slip.h: No such file or directory

  • CONFIG_FEATURE_SHADOWPASSWDS, CONFIG_USE_BB_SHADOW -- include/libbb.h:61:22: error: shadow.h: No such file or directory

  • CONFIG_HUSH -- has patch -- shell/hush.c:89:18: error: glob.h: No such file or directory

  • CONFIG_IFENSLAVE -- networking/ifenslave.c:132:30: error: linux/if_bonding.h: No such file or directory

  • CONFIG_IFPLUGD -- 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_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_SETARCH -- util-linux/setarch.c:23:29: error: sys/personality.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 options that give a linking error

Androids 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_MKFS_EXT2 -- 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'

  • getsid -- has patch

  • CONFIG_KILL -- undefined reference to 'getsid'

  • CONFIG_KILLALL -- undefined reference to 'getsid'

  • CONFIG_KILLALL5 -- undefined reference to 'getsid'

  • CONFIG_PGREP -- undefined reference to 'getsid'

  • CONFIG_PKILL -- undefined reference to 'getsid'

  • stime -- has patch

  • CONFIG_DATE -- undefined reference to 'stime'

  • CONFIG_RDATE -- undefined reference to 'stime'

  • others

  • CONFIG_ADJTIMEX -- has patch -- undefined reference to 'adjtimex'

  • CONFIG_FEATURE_HTTPD_AUTH_MD5 -- undefined reference to 'crypt'

  • CONFIG_HOSTID -- undefined reference to 'gethostid'

  • CONFIG_HOSTNAME -- has patch -- undefined reference to 'sethostname'

  • CONFIG_LOGNAME -- undefined reference to 'getlogin_r'

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

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

  • CONFIG_PIVOT_ROOT -- has patch -- undefined reference to 'pivot_root'

  • CONFIG_STAT -- has patch -- undefined reference to 'S_TYPEISMQ', 'S_TYPEISSEM', 'S_TYPEISSHM'

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

android-busybox-ndk's People

Contributors

tias avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.