Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lidgnulinux/eeb1d1b881edf8a10df7d0861e31eb66 to your computer and use it in GitHub Desktop.
Save lidgnulinux/eeb1d1b881edf8a10df7d0861e31eb66 to your computer and use it in GitHub Desktop.
Running Android Platform Tools on musl.

Running Android Platform Tools on Musl.

Opening

Since I moved to source-based linux distro with musl (Dragora GNU/Linux & LFS Musl), I always wondering about how to run android platform tools on musl. Android platform tools seems built againts glibc so running it on musl is almost impossible. Not until I discovered about patchelf. Turns out, we can use patchelf to make android platform tools binary tool (adb, fastboot, etc) to run on musl, with a bit of trick of course.

What do we need ?

We will need some stuffs like :

  • Android platform tools, grab it here.
  • patchelf, install it using your package manager or just build it yourself !
  • Some glibc's related libraries, you can take it from common distros. The libraries are :
    • ld-linux-x86-64.so.2
    • libc.so.6
    • libdl.so.2
    • libm.so.6
    • libpthread.so.0
    • librt.so.1

Steps.

We need to do some steps, but don't be worry, it's easy !

  1. Extract the android platform tools archive !

    $ unzip platform-tools-latest-linux.zip && cd platform-tools 
    
  2. Copy needed libraries to lib64 directory !

  3. Change / set the interpreter of each tools to lib64/ld-linux-x86-64.so.2 !

    $ for tools in adb \
    	etc1tool \
    	fastboot \
    	hprof-conv \
    	make_f2fs \
    	make_f2fs_casefold \
    	mke2fs \
    	sqlite3; do sudo patchelf --set-interpreter lib64/ld-linux-x86-64.so.2 ${tools[*]}; done 
    
  4. Test / run each tools ! Check if there are no complaints about missing symbol !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment