blob: 172279b2ecc4bb457517874b137a8999acfb0f2a [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/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, including
8# items requiring sudo privileges.
9# See https://www.chromium.org/developers/how-tos/android-build-instructions
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
15args="$@"
16
17if ! uname -m | egrep -q "i686|x86_64"; then
18 echo "Only x86 architectures are currently supported" >&2
19 exit
20fi
21
22lsb_release=$(lsb_release --codename --short)
23
24case $lsb_release in
25 xenial)
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 ;;
33esac
34
35# Install first the default Linux build deps.
36"$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \
37 --no-syms --lib32 --no-arm --no-chromeos-fonts --no-nacl --no-prompt "${args}"
38
39# The temporary directory used to store output of update-java-alternatives
40TEMPDIR=$(mktemp -d)
41cleanup() {
42 local status=${?}
43 trap - EXIT
44 rm -rf "${TEMPDIR}"
45 exit ${status}
46}
47trap cleanup EXIT
48
49# Fix deps
50sudo apt-get -f install
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
57# common
58sudo apt-get -y install lighttpd python-pexpect xvfb x11-utils
59
60# Some binaries in the Android SDK require 32-bit libraries on the host.
61# See https://developer.android.com/sdk/installing/index.html?pkg=tools
62if [[ $lsb_release == "precise" ]]; then
63 sudo apt-get -y install ia32-libs
64else
65 sudo apt-get -y install libncurses5:i386 libstdc++6:i386 zlib1g:i386
66fi
67
68sudo apt-get -y install ant
69
70# Install openjdk and openjre stuff
71sudo apt-get -y install $java_pkgs
72
73# Switch version of Java to openjdk 7.
74# Some Java plugins (e.g. for firefox, mozilla) are not required to build, and
75# thus are treated only as warnings. Any errors in updating java alternatives
76# which are not '*-javaplugin.so' will cause errors and stop the script from
77# completing successfully.
78if ! sudo update-java-alternatives -s $java_alternative \
79 >& "${TEMPDIR}"/update-java-alternatives.out
80then
81 # Check that there are the expected javaplugin.so errors for the update
82 if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \
83 /dev/null
84 then
85 # Print as warnings all the javaplugin.so errors
86 echo 'WARNING: java-6-sun has no alternatives for the following plugins:'
87 grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out
88 fi
89 # Check if there are any errors that are not javaplugin.so
90 if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \
91 >& /dev/null
92 then
93 # If there are non-javaplugin.so errors, treat as errors and exit
94 echo 'ERRORS: Failed to update alternatives for java-6-sun:'
95 grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out
96 exit 1
97 fi
98fi
99
100echo "install-build-deps-android.sh complete."