I'm trying to install some commands on an android device (namely file
and a better version of ls
), and I'm looking for the ARM binaries for it (namely the 5TE architecture) but I'm unable to find a place to download them. Googling things like "arm ls binary" or "ls binary" are giving me everything but what I want.
Is there a single place to find the binaries?
Best Answer
The least painful way to install Linux utilities on an Android device is to install a whole distribution in a subdirectory. “Normal” distributions (Debian, Arch, Fedora, etc.) provide binaries that are dynamically linked with Glibc, which Android doesn't provide. They need to be executed with the loader (
/lib/ld-linux*.so
) of Glibc.A simple way to set up such a system is to use Debian's deboostrap to build an initial Debian directory tree, transfer it to the Android device, and from then on install packages with
apt-get
and other standard Debian tools. There are a couple of pages on the topic on the Debian wiki: ChrootOnAndroid, HotwoDebianInAndroid.First, install Debootstrap. On Debian or derivative, just install the
debootstrap
package. On some other Linux or other Unix variant, just grab the debootstrap source tarball or check it out from Git: it's only a shell script and supporting data files.Determine whether your device supports hardware floating point. If it doesn't, replace
armhf
byarmel
below. You can tell by checking/proc/cpuinfo
under Android (or anything else using a Linux kernel): you must have ARMv7 (or ARMv8) with the featuresthumbee
andvfpv3
.If you don't already have it, install BusyBox on the Android device. While it isn't strictly necessary, it'll come handy below. You can retrieve the
busybox-static
Debian binary package, extract the BusyBox executable withar p busybox-static_*_armhf.deb data.tar.gz | tar -xzf - ./bin/busybox
, and transfer thebusybox
binary to the Android device. Below, I assume that BusyBox is located at/vendor/bin/busybox
.If your Android device is capable of mounting an SD card that's formatted as ext2/ext3/ext4 (or any other filesystem that supports unix permissions, i.e. not FAT), mount the SD card on your Unix PC and run the following command as root:
If not, run the following command as root (or under fakeroot, if you have it):
Now you need to transfer
/tmp/debian.tar.gz
to your Android device. You can do it over adb (adb push /tmp/debian.tar.gz /
) or any other way that works for you, then unpack the tarball (use the BusyBoxtar
):Set up a comfortable environment to run Linux programs. The easy way is to run them in a chroot. I assume that the Debian system is located at
/media/sdcard/debian
and that you have BusyBox. Create a shell script:Make this script executable and put it in
/vendor/bin
or anywhere else on the Android PATH. Before you can fully enjoy the Linux installation, you need to finish debootstrap's job: in the chroot, run