2016-09-13 21:39:20 +01:00
|
|
|
{stdenv, stdenv_32bit, fetchurl, unzip, zlib_32bit, ncurses_32bit, file, zlib, ncurses}:
|
2013-07-31 15:00:57 +01:00
|
|
|
|
2015-05-02 14:15:29 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2016-09-13 21:39:20 +01:00
|
|
|
version = "24.0.2";
|
2015-05-02 14:15:29 +01:00
|
|
|
name = "android-build-tools-r${version}";
|
2013-07-31 15:00:57 +01:00
|
|
|
src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
then fetchurl {
|
2015-10-06 13:27:49 +01:00
|
|
|
url = "https://dl.google.com/android/repository/build-tools_r${version}-linux.zip";
|
2016-09-13 21:39:20 +01:00
|
|
|
sha256 = "15bxk03m1r1i74idydgqsrz1k7qczi8f9sj4kl8vvbw9l6w2jklj";
|
2013-07-31 15:00:57 +01:00
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-darwin" then fetchurl {
|
2015-10-06 13:27:49 +01:00
|
|
|
url = "https://dl.google.com/android/repository/build-tools_r${version}-macosx.zip";
|
2016-09-13 21:39:20 +01:00
|
|
|
sha256 = "0h71bv8rdkssn7a17vj3r7jl5jwsxbwpg3sig0k9a7yfwyfc71s8";
|
2013-07-31 15:00:57 +01:00
|
|
|
}
|
|
|
|
else throw "System ${stdenv.system} not supported!";
|
2014-12-16 07:22:55 +00:00
|
|
|
|
2013-07-31 15:00:57 +01:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/build-tools
|
|
|
|
cd $out/build-tools
|
|
|
|
unzip $src
|
2016-01-17 23:42:54 +00:00
|
|
|
mv android-* ${version}
|
2013-07-31 15:00:57 +01:00
|
|
|
|
|
|
|
${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
''
|
2016-01-17 23:42:54 +00:00
|
|
|
cd ${version}
|
2014-09-01 07:37:43 +01:00
|
|
|
|
2016-09-13 21:39:20 +01:00
|
|
|
ln -s ${ncurses.out}/lib/libncurses.so.5 `pwd`/lib64/libtinfo.so.5
|
|
|
|
|
|
|
|
find . -type f -print0 | while IFS= read -r -d "" file
|
2013-07-31 15:00:57 +01:00
|
|
|
do
|
2016-09-13 21:39:20 +01:00
|
|
|
type=$(file "$file")
|
|
|
|
## Patch 64-bit binaries
|
|
|
|
if grep -q "ELF 64-bit" <<< "$type"
|
|
|
|
then
|
|
|
|
if grep -q "interpreter" <<< "$type"
|
|
|
|
then
|
|
|
|
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 "$file"
|
|
|
|
fi
|
|
|
|
patchelf --set-rpath `pwd`/lib64:${stdenv.cc.cc.lib.out}/lib:${zlib.out}/lib:${ncurses.out}/lib "$file"
|
|
|
|
## Patch 32-bit binaries
|
|
|
|
elif grep -q "ELF 32-bit" <<< "$type"
|
|
|
|
then
|
|
|
|
if grep -q "interpreter" <<< "$type"
|
|
|
|
then
|
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 "$file"
|
|
|
|
fi
|
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib.out}/lib:${zlib_32bit.out}/lib:${ncurses_32bit.out}/lib "$file"
|
|
|
|
fi
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
2016-09-13 21:39:20 +01:00
|
|
|
buildInputs = [ unzip file ];
|
2013-07-31 15:00:57 +01:00
|
|
|
}
|