[Galaxy Note II, Galaxy S III Developer Discussion ] Edge-Case:
Ah, just a lil' project I decided to torture myself with. It's CyanogenMod with added Linux executables I picked from Kali's and Debian's armhf repos. It requires glibc to be placed in /lib of the Android file system hierarchy, which is normally not there. Also, a few tweaks to file and directory permissions need to be done, with out those tweaks to Android before the build, /lib and everything in it won't be executable and the owner:group gets changed to something like root:shell 644 or something. It has to do with the sticky bit that I am still trying to fully comprehend as Android implements it as a security feature. I heard removing a configuration flag to the kernel when building will get rid of the whole paranoid feature and allow more access to thing like file/socket creation.

Basically, Android with apt, nmap, wireshark-cli, aircranck-ng, tcpdump(which comes from the Android ports), and what ever else anyone wants really, even the whole (what works on arm that is) Kali pentesting suite if desired.

Though one caveat is that both glibc and bionic have to be loaded up into memory (RAM) from what I understand, and the amount of that resource varies, as well as /system storage (which is about 2g on sph-l710), but bind mounting from .img file or extSdCard also works (so long as owner:group and sticky bit has been adjusted correctly before build). Though I am having trouble mounting during init, so I just run a script when I turn my phone on, about to auto script it as a service or just use sl4a's feature. I got one builld that is a bit of a skeloton working, but all my attempts to tweak init.rc to mount what I want have resulted in failure to boot.

I am almosted tempted to take a BSD rootfs and try to hack together something that will boot BSD with Android as the "window server" taking the place of kde4 or gnome2. It would be an endever, maybe I should stick with debian based linux because it alsready runs on Android so long as glibc is available.

Edit: Interestingly enough I found this in FreeBSD's "/usr/ports/devel/android-tools-adb"

jack-o@Green-Goblin:/usr/ports/devel/android-tools-adb$ cat pkg-descr
Android Debug Bridge (adb) is a versatile command line tool that
lets you communicate with an emulator instance or connected
Android-powered device.

WWW: http://developer.android.com/tools/help/adb.html
jack-o@Green-Goblin:/usr/ports/devel/android-tools-adb$

I just got done building openjdk6, I saw bison, gcc, I have git, python27.... hmm....I heard about a Linux compatability layer... It might be more possible than I thought to build on FreeBSD. I searched "Build Android on FreeBSD" and saw some projects such as BroidSD, BSDroid (which looks like its bit rotting), GnatDroid. I think BSDroid even wanted to get Android running on the FreeBSD kernel!

I think watchdog needs to be picked out of NetBSD's arm rootfs though.

edit 2: Taada

root@Green-Goblin:/usr/ports/devel/android-tools-adb #make install
.....
.....
.....
===> Installing for android-tools-adb-4.3
===> Generating temporary packing list
===> Checking if devel/android-tools-adb already installed
install -s -o root -g wheel -m 555 adb /usr/local/bin/
===> Registering installation for android-tools-adb-4.3
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/bin/adb

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://developer.android.com/tools/help/adb.html
root@Green-Goblin:/usr/ports/devel/android-tools-adb #

Not quite a build environment on FreeBSD yet, but hey, adb is a good start. As long as the dependencies are there it should work. I might need to set some enviroment variables if I do try to build on FreeBSD.

root@Green-Goblin:/etc/devd # adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
c90855ae	device

root@Green-Goblin:/etc/devd #

Just make sure to accept the rsa key on the phone/tablet... I almost thought I had more configuration to do but no, it works.

Update: Fri Nov 22, 2013

Well of all the build-tools I have these installed on FreeBSD:

bison, curl, flex, git, gperf, gnugp, open-jdk-6, open-jre-6, pngcrush, squashfs-tools, xsltproc, and zip.​

These I don't have or don't know if I do have and they are named differently:

build-essential, lzop, schedtools, zlib1g-dev, libesd0-dev, libncurses5-dev, libsdl1.2-dev, libwxgtk2.8-dev, libxmil2-utils, g++-multilib, gcc-multilib, lib32ncurses5-dev, lib32readline-gplv2-dev, and lib32z1-dev.​

If anyone has any knowledge they'd like to share regarding the packages I can't find and their possible counterparts for FreeBSD, please do share.

Note: It may be easier to build within a debian chroot/jail. -> ( http://blog.vx.sk/archives/22-Updated-Tutorial-Debian-GNUkFreeBSD-in-a-FreeBSD-jail.html )

BSDeb Chroot notes:

- I couldn't access the internet to apt-get at first in the jail, so I exited and then chrooted back into it and networking worked.

- squeeze's dpkg is old, upgrade to wheezy to get multi-arch support. -> ( http://www.howtoforge.com/how-to-upgrade-debian-squeeze-to-wheezy )

- I ran into this error while upgrading:

[....] Mounting kernel filesystems...mount: fdescfs : No such file or directory
invoke-rc.d: initscript freebsd-utils, action "start" failed.
dpkg: error processing freebsd-utils (--configure):
subprocess installed post-installation script returned error exit status 1
configured to not write apport reports
Errors were encountered while processing:
freebsd-utils
E: Sub-process /usr/bin/dpkg returned an error code (1)

This fixed that:

mount -t fdescfs fdescfs /jail/debian/dev/fd/

Update on FreeBSD Debian chroot:

I couldn't install some packages, with squeeze because dpkg doesn't support multiarch at version 1.5. After upgrading to Wheezy, libc6-dev or libc6-dev:i386 could not be installed, was using libc0.1 for KFreeBSD Debian. Also lib32ncurses5-dev and lib32readline-gplv2-dev could not be installed with Wheezy. Perhaps with Jesse or Sid.

Oh well, enough of that, time to study.