michael@0: #!/bin/bash -e michael@0: michael@0: # Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: # Script to install everything needed to build chromium on android that michael@0: # requires sudo privileges. michael@0: # See http://code.google.com/p/chromium/wiki/AndroidBuildInstructions michael@0: michael@0: # This script installs the sun-java6 packages (bin, jre and jdk). Sun requires michael@0: # a license agreement, so upon installation it will prompt the user. To get michael@0: # past the curses-based dialog press TAB TAB to agree. michael@0: michael@0: if ! uname -m | egrep -q "i686|x86_64"; then michael@0: echo "Only x86 architectures are currently supported" >&2 michael@0: exit michael@0: fi michael@0: michael@0: if [ "x$(id -u)" != x0 ]; then michael@0: echo "Running as non-root user." michael@0: echo "You might have to enter your password one or more times for 'sudo'." michael@0: echo michael@0: fi michael@0: michael@0: # The temporary directory used to store output of update-java-alternatives michael@0: TEMPDIR=$(mktemp -d) michael@0: cleanup() { michael@0: local status=${?} michael@0: trap - EXIT michael@0: rm -rf "${TEMPDIR}" michael@0: exit ${status} michael@0: } michael@0: trap cleanup EXIT michael@0: michael@0: sudo apt-get update michael@0: michael@0: # Fix deps michael@0: sudo apt-get -f install michael@0: michael@0: # Install deps michael@0: # This step differs depending on what Ubuntu release we are running michael@0: # on since the package names are different, and Sun's Java must michael@0: # be installed manually on late-model versions. michael@0: michael@0: # common michael@0: sudo apt-get -y install python-pexpect xvfb x11-utils michael@0: michael@0: if /usr/bin/lsb_release -r -s | grep -q "12."; then michael@0: # Ubuntu 12.x michael@0: sudo apt-get -y install ant michael@0: michael@0: # Java can not be installed via ppa on Ubuntu 12.04+ so we'll michael@0: # simply check to see if it has been setup properly -- if not michael@0: # let the user know. michael@0: michael@0: if ! java -version 2>&1 | grep -q "Java(TM)"; then michael@0: echo "****************************************************************" michael@0: echo "You need to install the Oracle Java SDK from http://goo.gl/uPRSq" michael@0: echo "and configure it as the default command-line Java environment." michael@0: echo "****************************************************************" michael@0: exit michael@0: fi michael@0: michael@0: else michael@0: # Ubuntu 10.x michael@0: michael@0: sudo apt-get -y install ant1.8 michael@0: michael@0: # Install sun-java6 stuff michael@0: sudo apt-get -y install sun-java6-bin sun-java6-jre sun-java6-jdk michael@0: michael@0: # Switch version of Java to java-6-sun michael@0: # Sun's java is missing certain Java plugins (e.g. for firefox, mozilla). michael@0: # These are not required to build, and thus are treated only as warnings. michael@0: # Any errors in updating java alternatives which are not '*-javaplugin.so' michael@0: # will cause errors and stop the script from completing successfully. michael@0: if ! sudo update-java-alternatives -s java-6-sun \ michael@0: >& "${TEMPDIR}"/update-java-alternatives.out michael@0: then michael@0: # Check that there are the expected javaplugin.so errors for the update michael@0: if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \ michael@0: /dev/null michael@0: then michael@0: # Print as warnings all the javaplugin.so errors michael@0: echo 'WARNING: java-6-sun has no alternatives for the following plugins:' michael@0: grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out michael@0: fi michael@0: # Check if there are any errors that are not javaplugin.so michael@0: if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \ michael@0: >& /dev/null michael@0: then michael@0: # If there are non-javaplugin.so errors, treat as errors and exit michael@0: echo 'ERRORS: Failed to update alternatives for java-6-sun:' michael@0: grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out michael@0: exit 1 michael@0: fi michael@0: fi michael@0: fi michael@0: michael@0: echo "install-build-deps-android.sh complete."