• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15if ! uname -m | egrep -q "i686|x86_64"; then
16  echo "Only x86 architectures are currently supported" >&2
17  exit
18fi
19
20# Install first the default Linux build deps.
21"$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \
22    --no-syms --no-arm --no-chromeos-fonts --no-nacl --no-prompt
23
24# The temporary directory used to store output of update-java-alternatives
25TEMPDIR=$(mktemp -d)
26cleanup() {
27  local status=${?}
28  trap - EXIT
29  rm -rf "${TEMPDIR}"
30  exit ${status}
31}
32trap cleanup EXIT
33
34sudo apt-get update
35
36# Fix deps
37sudo apt-get -f install
38
39# Install deps
40# This step differs depending on what Ubuntu release we are running
41# on since the package names are different, and Sun's Java must
42# be installed manually on late-model versions.
43
44# common
45sudo apt-get -y install checkstyle lighttpd python-pexpect xvfb x11-utils
46
47# Few binaries in the Android SDK require 32-bit libraries on the host.
48sudo apt-get -y install lib32z1 g++-multilib
49
50sudo apt-get -y install ant
51
52# Install openjdk and openjre 7 stuff
53sudo apt-get -y install openjdk-7-jre openjdk-7-jdk
54
55# Switch version of Java to openjdk 7.
56# Some Java plugins (e.g. for firefox, mozilla) are not required to build, and
57# thus are treated only as warnings. Any errors in updating java alternatives
58# which are not '*-javaplugin.so' will cause errors and stop the script from
59# completing successfully.
60if ! sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 \
61           >& "${TEMPDIR}"/update-java-alternatives.out
62then
63  # Check that there are the expected javaplugin.so errors for the update
64  if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \
65      /dev/null
66  then
67    # Print as warnings all the javaplugin.so errors
68    echo 'WARNING: java-6-sun has no alternatives for the following plugins:'
69    grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out
70  fi
71  # Check if there are any errors that are not javaplugin.so
72  if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \
73      >& /dev/null
74  then
75    # If there are non-javaplugin.so errors, treat as errors and exit
76    echo 'ERRORS: Failed to update alternatives for java-6-sun:'
77    grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out
78    exit 1
79  fi
80fi
81
82echo "install-build-deps-android.sh complete."
83