From 487dc80d8aad31b45bf53925074468de5ff0d65d Mon Sep 17 00:00:00 2001 From: Gareth Smith Date: Tue, 3 Mar 2015 14:08:53 +0000 Subject: [PATCH 1/2] Add option to build old androidndk r8e. This version is the one required to build mobile Firefox. See build documentation here: https://wiki.mozilla.org/Mobile/Fennec/Android/Detailed_build_instructions#Install_Android_NDK --- .../mobile/androidenv/androidndk.nix | 30 +++++++++++++------ .../development/mobile/androidenv/default.nix | 8 +++++ .../make-standalone-toolchain_r8e.patch | 13 ++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 pkgs/development/mobile/androidenv/make-standalone-toolchain_r8e.patch diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix index 9f5393949ca7..09c6759d7eaf 100644 --- a/pkgs/development/mobile/androidenv/androidndk.nix +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -1,27 +1,35 @@ { stdenv, fetchurl, zlib, ncurses, p7zip, lib, makeWrapper , coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which -, platformTools +, platformTools , pinToVersion8 ? false }: assert stdenv.isLinux; stdenv.mkDerivation rec { - name = "android-ndk-r10c"; + name = if pinToVersion8 then + "android-ndk-r8e" + else + "android-ndk-r10c"; src = if stdenv.system == "i686-linux" then fetchurl { - url = "http://dl.google.com/android/ndk/${name}-linux-x86.bin"; - sha256 = "0gyq68zrpzj3gkh81czs6r0jmikg5rwzh1bqg4rk16g2nxm4lll3"; + url = if pinToVersion8 then "http://dl.google.com/android/ndk/${name}-linux-x86.tar.bz2" + else "http://dl.google.com/android/ndk/${name}-linux-x86.bin"; + sha256 = if pinToVersion8 then "c2c4e0c8b3037149a0f5dbb08d72f814a52af4da9fff9d80328c675457e95a98" + else "0gyq68zrpzj3gkh81czs6r0jmikg5rwzh1bqg4rk16g2nxm4lll3"; } else if stdenv.system == "x86_64-linux" then fetchurl { - url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.bin"; - sha256 = "126rqzkmf8xz1hqdziwx81yln17hpivs2j45rxhzdr45iw9b758c"; + url = if pinToVersion8 then "http://dl.google.com/android/ndk/${name}-linux-x86_64.tar.bz2" + else "http://dl.google.com/android/ndk/${name}-linux-x86_64.bin"; + sha256 = if pinToVersion8 then "093gf55zbh38p2gk5bdykj1vg9p5l774wjdzw5mhk4144jm1wdq7" + else "126rqzkmf8xz1hqdziwx81yln17hpivs2j45rxhzdr45iw9b758c"; } else throw "platform ${stdenv.system} not supported!"; phases = "buildPhase"; - buildInputs = [ p7zip makeWrapper ]; + buildInputs = if pinToVersion8 then [ makeWrapper ] + else [ p7zip makeWrapper ]; buildCommand = let bin_path = "$out/bin"; @@ -42,13 +50,17 @@ stdenv.mkDerivation rec { set -x mkdir -pv $out/libexec cd $out/libexec - 7z x $src + + ${if pinToVersion8 then "tar -xjf $src" + else "7z x $src"} # so that it doesn't fail because of read-only permissions set cd - patch -p1 \ --no-backup-if-mismatch \ - -d $out/libexec/${name} < ${ ./make-standalone-toolchain.patch } + ${if pinToVersion8 then + "-d $out/libexec/${name} < ${ ./make-standalone-toolchain_r8e.patch }" + else "-d $out/libexec/${name} < ${ ./make-standalone-toolchain.patch }"} cd ${pkg_path} find $out \( \ diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 92259886d697..d870926f2109 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -147,6 +147,14 @@ rec { inherit (pkgs) coreutils file findutils gawk gnugrep gnused jdk which; inherit platformTools; }; + + androidndk_r8e = import ./androidndk.nix { + inherit (pkgs) stdenv fetchurl zlib ncurses p7zip lib makeWrapper; + inherit (pkgs) coreutils file findutils gawk gnugrep gnused jdk which; + inherit platformTools; + pinToVersion8 = true; + }; + buildApp = import ./build-app.nix { inherit (pkgs) stdenv jdk ant gnumake gawk file which; diff --git a/pkgs/development/mobile/androidenv/make-standalone-toolchain_r8e.patch b/pkgs/development/mobile/androidenv/make-standalone-toolchain_r8e.patch new file mode 100644 index 000000000000..4a9f9a4a9dd3 --- /dev/null +++ b/pkgs/development/mobile/androidenv/make-standalone-toolchain_r8e.patch @@ -0,0 +1,13 @@ +diff -ru android-ndk-r8e.old/build/tools/make-standalone-toolchain.sh android-ndk-r8e/build/tools/make-standalone-toolchain.sh +--- android-ndk-r8e.old/build/tools/make-standalone-toolchain.sh 2014-10-16 03:46:32.000000000 +0200 ++++ android-ndk-r8e/build/tools/make-standalone-toolchain.sh 2014-10-24 23:46:22.544928306 +0200 +@@ -194,6 +194,9 @@ + # Now copy the GCC toolchain prebuilt binaries + run copy_directory "$TOOLCHAIN_PATH" "$TMPDIR" + ++# Making it writable again ++chmod -R +w "$TMPDIR" ++ + if [ -n "$LLVM_VERSION" ]; then + # Copy the clang/llvm toolchain prebuilt binaries + run copy_directory "$LLVM_TOOLCHAIN_PATH" "$TMPDIR" From 9d57638439a4ab5222dbd144c4eb5882abbc9edb Mon Sep 17 00:00:00 2001 From: Gareth Smith Date: Tue, 3 Mar 2015 15:31:49 +0000 Subject: [PATCH 2/2] Pulled androidndk_r8e into a separate file. --- .../mobile/androidenv/androidndk.nix | 30 +++---- .../mobile/androidenv/androidndk_r8e.nix | 80 +++++++++++++++++++ .../development/mobile/androidenv/default.nix | 5 +- 3 files changed, 91 insertions(+), 24 deletions(-) create mode 100644 pkgs/development/mobile/androidenv/androidndk_r8e.nix diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix index 09c6759d7eaf..9f5393949ca7 100644 --- a/pkgs/development/mobile/androidenv/androidndk.nix +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -1,35 +1,27 @@ { stdenv, fetchurl, zlib, ncurses, p7zip, lib, makeWrapper , coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which -, platformTools , pinToVersion8 ? false +, platformTools }: assert stdenv.isLinux; stdenv.mkDerivation rec { - name = if pinToVersion8 then - "android-ndk-r8e" - else - "android-ndk-r10c"; + name = "android-ndk-r10c"; src = if stdenv.system == "i686-linux" then fetchurl { - url = if pinToVersion8 then "http://dl.google.com/android/ndk/${name}-linux-x86.tar.bz2" - else "http://dl.google.com/android/ndk/${name}-linux-x86.bin"; - sha256 = if pinToVersion8 then "c2c4e0c8b3037149a0f5dbb08d72f814a52af4da9fff9d80328c675457e95a98" - else "0gyq68zrpzj3gkh81czs6r0jmikg5rwzh1bqg4rk16g2nxm4lll3"; + url = "http://dl.google.com/android/ndk/${name}-linux-x86.bin"; + sha256 = "0gyq68zrpzj3gkh81czs6r0jmikg5rwzh1bqg4rk16g2nxm4lll3"; } else if stdenv.system == "x86_64-linux" then fetchurl { - url = if pinToVersion8 then "http://dl.google.com/android/ndk/${name}-linux-x86_64.tar.bz2" - else "http://dl.google.com/android/ndk/${name}-linux-x86_64.bin"; - sha256 = if pinToVersion8 then "093gf55zbh38p2gk5bdykj1vg9p5l774wjdzw5mhk4144jm1wdq7" - else "126rqzkmf8xz1hqdziwx81yln17hpivs2j45rxhzdr45iw9b758c"; + url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.bin"; + sha256 = "126rqzkmf8xz1hqdziwx81yln17hpivs2j45rxhzdr45iw9b758c"; } else throw "platform ${stdenv.system} not supported!"; phases = "buildPhase"; - buildInputs = if pinToVersion8 then [ makeWrapper ] - else [ p7zip makeWrapper ]; + buildInputs = [ p7zip makeWrapper ]; buildCommand = let bin_path = "$out/bin"; @@ -50,17 +42,13 @@ stdenv.mkDerivation rec { set -x mkdir -pv $out/libexec cd $out/libexec - - ${if pinToVersion8 then "tar -xjf $src" - else "7z x $src"} + 7z x $src # so that it doesn't fail because of read-only permissions set cd - patch -p1 \ --no-backup-if-mismatch \ - ${if pinToVersion8 then - "-d $out/libexec/${name} < ${ ./make-standalone-toolchain_r8e.patch }" - else "-d $out/libexec/${name} < ${ ./make-standalone-toolchain.patch }"} + -d $out/libexec/${name} < ${ ./make-standalone-toolchain.patch } cd ${pkg_path} find $out \( \ diff --git a/pkgs/development/mobile/androidenv/androidndk_r8e.nix b/pkgs/development/mobile/androidenv/androidndk_r8e.nix new file mode 100644 index 000000000000..5e04bbf0116d --- /dev/null +++ b/pkgs/development/mobile/androidenv/androidndk_r8e.nix @@ -0,0 +1,80 @@ +{ stdenv, fetchurl, zlib, ncurses, lib, makeWrapper +, coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which +, platformTools +}: + +assert stdenv.isLinux; + +stdenv.mkDerivation rec { + name = "android-ndk-r8e"; + + src = if stdenv.system == "i686-linux" + then fetchurl { + url = "http://dl.google.com/android/ndk/${name}-linux-x86.tar.bz2"; + sha256 = "c2c4e0c8b3037149a0f5dbb08d72f814a52af4da9fff9d80328c675457e95a98"; + } + else if stdenv.system == "x86_64-linux" then fetchurl { + url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.tar.bz2"; + sha256 = "093gf55zbh38p2gk5bdykj1vg9p5l774wjdzw5mhk4144jm1wdq7"; + } + else throw "platform ${stdenv.system} not supported!"; + + phases = "buildPhase"; + + buildInputs = [ makeWrapper ]; + + buildCommand = let + bin_path = "$out/bin"; + pkg_path = "$out/libexec/${name}"; + sed_script_1 = + "'s|^PROGDIR=`dirname $0`" + + "|PROGDIR=`dirname $(readlink -f $(which $0))`|'"; + sed_script_2 = + "'s|^MYNDKDIR=`dirname $0`" + + "|MYNDKDIR=`dirname $(readlink -f $(which $0))`|'"; + runtime_paths = (lib.makeSearchPath "bin" [ + coreutils file findutils + gawk gnugrep gnused + jdk + which + ]) + ":${platformTools}/platform-tools"; + in '' + set -x + mkdir -pv $out/libexec + cd $out/libexec + tar -xjf $src + + # so that it doesn't fail because of read-only permissions set + cd - + patch -p1 \ + --no-backup-if-mismatch \ + -d $out/libexec/${name} < ${ ./make-standalone-toolchain_r8e.patch } + cd ${pkg_path} + + find $out \( \ + \( -type f -a -name "*.so*" \) -o \ + \( -type f -a -perm /0100 \) \ + \) -exec patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-*so.? \ + --set-rpath ${zlib}/lib:${ncurses}/lib {} \; + # fix ineffective PROGDIR / MYNDKDIR determination + for i in ndk-build ndk-gdb ndk-gdb-py + do + sed -i -e ${sed_script_1} $i + done + sed -i -e ${sed_script_2} ndk-which + # a bash script + patchShebangs ndk-which + # make some executables available in PATH + mkdir -pv ${bin_path} + for i in \ + ndk-build ndk-depends ndk-gdb ndk-gdb-py ndk-gdb.py ndk-stack ndk-which + do + ln -sf ${pkg_path}/$i ${bin_path}/$i + done + # wrap + for i in ndk-build ndk-gdb ndk-gdb-py ndk-which + do + wrapProgram "${bin_path}/$i" --prefix PATH : "${runtime_paths}" + done + ''; +} diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index d870926f2109..e99ab93b7aeb 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -148,11 +148,10 @@ rec { inherit platformTools; }; - androidndk_r8e = import ./androidndk.nix { - inherit (pkgs) stdenv fetchurl zlib ncurses p7zip lib makeWrapper; + androidndk_r8e = import ./androidndk_r8e.nix { + inherit (pkgs) stdenv fetchurl zlib ncurses lib makeWrapper; inherit (pkgs) coreutils file findutils gawk gnugrep gnused jdk which; inherit platformTools; - pinToVersion8 = true; };