| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash -e |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to install everything needed to build chromium on android, including | 7 # Script to install everything needed to build chromium on android, including |
| 8 # items requiring sudo privileges. | 8 # items requiring sudo privileges. |
| 9 # See https://www.chromium.org/developers/how-tos/android-build-instructions | 9 # See https://www.chromium.org/developers/how-tos/android-build-instructions |
| 10 | 10 |
| 11 # This script installs the sun-java6 packages (bin, jre and jdk). Sun requires |
| 12 # a license agreement, so upon installation it will prompt the user. To get |
| 13 # past the curses-based dialog press TAB <ret> TAB <ret> to agree. |
| 14 |
| 11 args="$@" | 15 args="$@" |
| 12 | 16 |
| 13 if ! uname -m | egrep -q "i686|x86_64"; then | 17 if ! uname -m | egrep -q "i686|x86_64"; then |
| 14 echo "Only x86 architectures are currently supported" >&2 | 18 echo "Only x86 architectures are currently supported" >&2 |
| 15 exit | 19 exit |
| 16 fi | 20 fi |
| 17 | 21 |
| 18 # Exit if any commands fail. | 22 lsb_release=$(lsb_release --codename --short) |
| 19 set -e | |
| 20 | 23 |
| 21 lsb_release=$(lsb_release --codename --short) | 24 case $lsb_release in |
| 25 xenial|yakkety) |
| 26 java_alternative="java-1.8.0-openjdk-amd64" |
| 27 java_pkgs="openjdk-8-jre openjdk-8-jdk" |
| 28 ;; |
| 29 *) |
| 30 java_alternative="java-1.7.0-openjdk-amd64" |
| 31 java_pkgs="openjdk-7-jre openjdk-7-jdk" |
| 32 ;; |
| 33 esac |
| 22 | 34 |
| 23 # Install first the default Linux build deps. | 35 # Install first the default Linux build deps. |
| 24 "$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \ | 36 "$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \ |
| 25 --no-syms --lib32 --no-arm --no-chromeos-fonts --no-nacl --no-prompt "${args}" | 37 --no-syms --lib32 --no-arm --no-chromeos-fonts --no-nacl --no-prompt "${args}" |
| 26 | 38 |
| 39 # The temporary directory used to store output of update-java-alternatives |
| 40 TEMPDIR=$(mktemp -d) |
| 41 cleanup() { |
| 42 local status=${?} |
| 43 trap - EXIT |
| 44 rm -rf "${TEMPDIR}" |
| 45 exit ${status} |
| 46 } |
| 47 trap cleanup EXIT |
| 48 |
| 27 # Fix deps | 49 # Fix deps |
| 28 sudo apt-get -f install | 50 sudo apt-get -f install |
| 29 | 51 |
| 52 # Install deps |
| 53 # This step differs depending on what Ubuntu release we are running |
| 54 # on since the package names are different, and Sun's Java must |
| 55 # be installed manually on late-model versions. |
| 56 |
| 30 # common | 57 # common |
| 31 sudo apt-get -y install lib32z1 lighttpd python-pexpect xvfb x11-utils | 58 sudo apt-get -y install lib32z1 lighttpd python-pexpect xvfb x11-utils |
| 32 | 59 |
| 33 # Some binaries in the Android SDK require 32-bit libraries on the host. | 60 # Some binaries in the Android SDK require 32-bit libraries on the host. |
| 34 # See https://developer.android.com/sdk/installing/index.html?pkg=tools | 61 # See https://developer.android.com/sdk/installing/index.html?pkg=tools |
| 35 if [[ $lsb_release == "precise" ]]; then | 62 if [[ $lsb_release == "precise" ]]; then |
| 36 sudo apt-get -y install ia32-libs | 63 sudo apt-get -y install ia32-libs |
| 37 else | 64 else |
| 38 sudo apt-get -y install libncurses5:i386 libstdc++6:i386 zlib1g:i386 | 65 sudo apt-get -y install libncurses5:i386 libstdc++6:i386 zlib1g:i386 |
| 39 fi | 66 fi |
| 40 | 67 |
| 41 # Required by //components/cronet/tools/generate_javadoc.py | |
| 42 # TODO(375324): Stop requiring ANT. | |
| 43 sudo apt-get -y install ant | 68 sudo apt-get -y install ant |
| 44 | 69 |
| 45 # Required for apk-patch-size-estimator | 70 # Required for apk-patch-size-estimator |
| 46 sudo apt-get -y install bsdiff | 71 sudo apt-get -y install bsdiff |
| 47 | 72 |
| 48 # Do our own error handling for java. | 73 # Install openjdk and openjre stuff |
| 49 set +e | 74 sudo apt-get -y install $java_pkgs |
| 50 | 75 |
| 51 function IsJava8() { | 76 # Switch version of Java to openjdk 7. |
| 52 # Arg is either "java" or "javac" | 77 # Some Java plugins (e.g. for firefox, mozilla) are not required to build, and |
| 53 $1 -version 2>&1 | grep -q '1\.8' | 78 # thus are treated only as warnings. Any errors in updating java alternatives |
| 54 } | 79 # which are not '*-javaplugin.so' will cause errors and stop the script from |
| 55 | 80 # completing successfully. |
| 56 if ! (IsJava8 java && IsJava8 javac); then | 81 if ! sudo update-java-alternatives -s $java_alternative \ |
| 57 sudo apt-get -y install openjdk-8-jre openjdk-8-jdk | 82 >& "${TEMPDIR}"/update-java-alternatives.out |
| 58 fi | 83 then |
| 59 | 84 # Check that there are the expected javaplugin.so errors for the update |
| 60 # There can be several reasons why java8 is not default despite being installed. | 85 if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \ |
| 61 # Just show an error and exit. | 86 /dev/null |
| 62 if ! (IsJava8 java && IsJava8 javac); then | 87 then |
| 63 echo | 88 # Print as warnings all the javaplugin.so errors |
| 64 echo "Automatic java installation failed." | 89 echo 'WARNING: java-6-sun has no alternatives for the following plugins:' |
| 65 echo '`java -version` reports:' | 90 grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out |
| 66 java -version | 91 fi |
| 67 echo | 92 # Check if there are any errors that are not javaplugin.so |
| 68 echo '`javac -version` reports:' | 93 if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \ |
| 69 javac -version | 94 >& /dev/null |
| 70 echo | 95 then |
| 71 echo "Please ensure that JDK 8 is installed and resolves first in your PATH." | 96 # If there are non-javaplugin.so errors, treat as errors and exit |
| 72 echo -n '`which java` reports: ' | 97 echo 'ERRORS: Failed to update alternatives for java-6-sun:' |
| 73 which java | 98 grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out |
| 74 echo -n '`which javac` reports: ' | 99 exit 1 |
| 75 which javac | 100 fi |
| 76 echo | |
| 77 echo "You might also try running:" | |
| 78 echo " sudo update-java-alternatives -s java-1.8.0-openjdk-amd64" | |
| 79 exit 1 | |
| 80 fi | 101 fi |
| 81 | 102 |
| 82 echo "install-build-deps-android.sh complete." | 103 echo "install-build-deps-android.sh complete." |
| OLD | NEW |