blob: 5d9043944a0e04c964c7a25a24d0b34c22d3743d [file] [log] [blame]
#!/bin/bash -e
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Script to install everything needed to build chromium on android that
# requires sudo privileges.
# See
# This script installs the sun-java6 packages (bin, jre and jdk). Sun requires
# a license agreement, so upon installation it will prompt the user. To get
# past the curses-based dialog press TAB <ret> TAB <ret> to agree.
if ! uname -m | egrep -q "i686|x86_64"; then
echo "Only x86 architectures are currently supported" >&2
if [ "x$(id -u)" != x0 ]; then
echo "Running as non-root user."
echo "You might have to enter your password one or more times for 'sudo'."
# The temporary directory used to store output of update-java-alternatives
TEMPDIR=$(mktemp -d)
cleanup() {
local status=${?}
trap - EXIT
rm -rf "${TEMPDIR}"
exit ${status}
trap cleanup EXIT
sudo apt-get update
# Fix deps
sudo apt-get -f install
# Install deps
sudo apt-get -y install python-pexpect ant1.8 xvfb x11-utils
# Install sun-java6 stuff
sudo apt-get -y install sun-java6-bin sun-java6-jre sun-java6-jdk
# Switch version of Java to java-6-sun
# Sun's java is missing certain Java plugins (e.g. for firefox, mozilla). These
# are not required to build, and thus are treated only as warnings. Any errors
# in updating java alternatives which are not '*' will cause
# errors and stop the script from completing successfully.
if ! sudo update-java-alternatives -s java-6-sun \
>& "${TEMPDIR}"/update-java-alternatives.out
# Check that there are the expected errors for the update
if grep '' "${TEMPDIR}"/update-java-alternatives.out >& /dev/null
# Print as warnings all the errors
echo 'WARNING: java-6-sun has no alternatives for the following plugins:'
grep '' "${TEMPDIR}"/update-java-alternatives.out
# Check if there are any errors that are not
if grep -v '' "${TEMPDIR}"/update-java-alternatives.out \
>& /dev/null
# If there are errors, treat as errors and exit
echo 'ERRORS: Failed to update alternatives for java-6-sun:'
grep -v '' "${TEMPDIR}"/update-java-alternatives.out
exit 1
echo " complete."