James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
| 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 |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Script to install everything needed to build chromium on android that |
| 8 | # requires sudo privileges. |
| 9 | # See http://code.google.com/p/chromium/wiki/AndroidBuildInstructions |
| 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 | |
James Robinson | 5e66a79 | 2015-01-21 17:02:08 -0800 | [diff] [blame^] | 15 | args="$@" |
| 16 | if test "$1" = "--skip-sdk-packages"; then |
| 17 | skip_inst_sdk_packages=1 |
| 18 | args="${@:2}" |
| 19 | else |
| 20 | skip_inst_sdk_packages=0 |
| 21 | fi |
| 22 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 23 | if ! uname -m | egrep -q "i686|x86_64"; then |
| 24 | echo "Only x86 architectures are currently supported" >&2 |
| 25 | exit |
| 26 | fi |
| 27 | |
| 28 | # Install first the default Linux build deps. |
| 29 | "$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \ |
James Robinson | 5e66a79 | 2015-01-21 17:02:08 -0800 | [diff] [blame^] | 30 | --no-syms --lib32 --no-arm --no-chromeos-fonts --no-nacl --no-prompt "${args}" |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 31 | |
| 32 | lsb_release=$(lsb_release --codename --short) |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 33 | |
| 34 | # The temporary directory used to store output of update-java-alternatives |
| 35 | TEMPDIR=$(mktemp -d) |
| 36 | cleanup() { |
| 37 | local status=${?} |
| 38 | trap - EXIT |
| 39 | rm -rf "${TEMPDIR}" |
| 40 | exit ${status} |
| 41 | } |
| 42 | trap cleanup EXIT |
| 43 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 44 | # Fix deps |
| 45 | sudo apt-get -f install |
| 46 | |
| 47 | # Install deps |
| 48 | # This step differs depending on what Ubuntu release we are running |
| 49 | # on since the package names are different, and Sun's Java must |
| 50 | # be installed manually on late-model versions. |
| 51 | |
| 52 | # common |
| 53 | sudo apt-get -y install lighttpd python-pexpect xvfb x11-utils |
| 54 | |
James Robinson | 6a64b81 | 2014-12-03 13:38:42 -0800 | [diff] [blame] | 55 | # Some binaries in the Android SDK require 32-bit libraries on the host. |
| 56 | # See https://developer.android.com/sdk/installing/index.html?pkg=tools |
| 57 | if [[ $lsb_release == "precise" ]]; then |
| 58 | sudo apt-get -y install ia32-libs |
| 59 | else |
| 60 | sudo apt-get -y install libncurses5:i386 libstdc++6:i386 zlib1g:i386 |
| 61 | fi |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 62 | |
| 63 | sudo apt-get -y install ant |
| 64 | |
| 65 | # Install openjdk and openjre 7 stuff |
| 66 | sudo apt-get -y install openjdk-7-jre openjdk-7-jdk |
| 67 | |
| 68 | # Switch version of Java to openjdk 7. |
| 69 | # Some Java plugins (e.g. for firefox, mozilla) are not required to build, and |
| 70 | # thus are treated only as warnings. Any errors in updating java alternatives |
| 71 | # which are not '*-javaplugin.so' will cause errors and stop the script from |
| 72 | # completing successfully. |
| 73 | if ! sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 \ |
| 74 | >& "${TEMPDIR}"/update-java-alternatives.out |
| 75 | then |
| 76 | # Check that there are the expected javaplugin.so errors for the update |
| 77 | if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \ |
| 78 | /dev/null |
| 79 | then |
| 80 | # Print as warnings all the javaplugin.so errors |
| 81 | echo 'WARNING: java-6-sun has no alternatives for the following plugins:' |
| 82 | grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out |
| 83 | fi |
| 84 | # Check if there are any errors that are not javaplugin.so |
| 85 | if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \ |
| 86 | >& /dev/null |
| 87 | then |
| 88 | # If there are non-javaplugin.so errors, treat as errors and exit |
| 89 | echo 'ERRORS: Failed to update alternatives for java-6-sun:' |
| 90 | grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out |
| 91 | exit 1 |
| 92 | fi |
| 93 | fi |
| 94 | |
James Robinson | 5e66a79 | 2015-01-21 17:02:08 -0800 | [diff] [blame^] | 95 | if test "$skip_inst_sdk_packages" != 1; then |
| 96 | echo 'checking for sdk packages install' |
| 97 | # Get the SDK extras packages to install from the DEPS file 'sdkextras' hook. |
| 98 | packages="$(python -c 'execfile("./get_sdk_extras_packages.py")')" |
| 99 | # Use absolute path to call 'android' so script can be run from any directory. |
| 100 | cwd=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
| 101 | for package in "${packages}"; do |
| 102 | pkg_id=$(${cwd}/../third_party/android_tools/sdk/tools/android list sdk | \ |
| 103 | grep -i "$package," | \ |
| 104 | awk '/^[ ]*[0-9]*- / {gsub("-",""); print $1}') |
| 105 | if [[ -n ${pkg_id} ]]; then |
| 106 | ${cwd}/../third_party/android_tools/sdk/tools/android update sdk --no-ui \ |
| 107 | --filter ${pkg_id} |
| 108 | fi |
| 109 | done |
| 110 | fi |
James Robinson | d753aca | 2015-01-12 13:07:20 -0800 | [diff] [blame] | 111 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 112 | echo "install-build-deps-android.sh complete." |