1{stdenv, zlib, fetchurl, unzip}:
2
3stdenv.mkDerivation rec {
4 version = "24.0.2";
5 name = "android-platform-tools-r${version}";
6 src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
7 then fetchurl {
8 url = "https://dl.google.com/android/repository/platform-tools_r${version}-linux.zip";
9 sha256 = "0y36mlwh4kb77d3vcpqxqwkxsadllap6g6jjylf3rb7blh5l4zw6";
10 }
11 else if stdenv.system == "x86_64-darwin" then fetchurl {
12 url = "https://dl.google.com/android/repository/platform-tools_r${version}-macosx.zip";
13 sha256 = "1whfhdwjir2sv2pfypagva813yn0fx8idi6c2mxhddv2mlws6zk4";
14 }
15 else throw "System ${stdenv.system} not supported!";
16
17 buildCommand = ''
18 mkdir -p $out
19 cd $out
20 unzip $src
21 cd platform-tools
22
23 ${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
24 ''
25 for i in adb dmtracedump fastboot hprof-conv sqlite3
26 do
27 patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
28 patchelf --set-rpath ${stdenv.cc.cc.lib}/lib:`pwd`/lib64 $i
29 done
30
31 for i in etc1tool
32 do
33 patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
34 patchelf --set-rpath ${stdenv.cc.cc.lib}/lib:${zlib.out}/lib:`pwd`/lib64 $i
35 done
36 ''}
37
38 mkdir -p $out/bin
39 for i in adb fastboot
40 do
41 ln -sf $out/platform-tools/$i $out/bin/$i
42 done
43 '';
44
45 buildInputs = [ unzip ];
46}