[email protected] | c4fabbc3 | 2012-03-07 02:22:18 | [diff] [blame] | 1 | #!/bin/bash -e |
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 2 | |
[email protected] | 2a89cd9 | 2012-02-18 01:58:43 | [diff] [blame] | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style license that can be |
5 | # found in the LICENSE file. | ||||
6 | |||||
[email protected] | c4fabbc3 | 2012-03-07 02:22:18 | [diff] [blame] | 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 | ||||
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 10 | |
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 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. | ||||
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 14 | |
[email protected] | c4fabbc3 | 2012-03-07 02:22:18 | [diff] [blame] | 15 | if ! uname -m | egrep -q "i686|x86_64"; then |
16 | echo "Only x86 architectures are currently supported" >&2 | ||||
17 | exit | ||||
18 | fi | ||||
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 19 | |
[email protected] | c4fabbc3 | 2012-03-07 02:22:18 | [diff] [blame] | 20 | if [ "x$(id -u)" != x0 ]; then |
21 | echo "Running as non-root user." | ||||
22 | echo "You might have to enter your password one or more times for 'sudo'." | ||||
23 | echo | ||||
24 | fi | ||||
25 | |||||
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 26 | # The temporary directory used to store output of update-java-alternatives |
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 27 | TEMPDIR=$(mktemp -d) |
28 | cleanup() { | ||||
29 | local status=${?} | ||||
30 | trap - EXIT | ||||
31 | rm -rf "${TEMPDIR}" | ||||
32 | exit ${status} | ||||
33 | } | ||||
34 | trap cleanup EXIT | ||||
35 | |||||
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 36 | sudo apt-get update |
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 37 | |
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 38 | # Fix deps |
39 | sudo apt-get -f install | ||||
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 40 | |
[email protected] | 959a0f5c | 2012-06-22 23:58:58 | [diff] [blame] | 41 | # Install deps |
[email protected] | 457088f2 | 2012-09-26 21:47:07 | [diff] [blame] | 42 | # This step differs depending on what Ubuntu release we are running |
43 | # on since the package names are different, and Sun's Java must | ||||
44 | # be installed manually on late-model versions. | ||||
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 45 | |
[email protected] | 758d7708 | 2014-01-08 00:05:19 | [diff] [blame^] | 46 | # common |
47 | sudo apt-get -y install checkstyle lighttpd python-pexpect xvfb x11-utils | ||||
[email protected] | 9f95fb9 | 2011-10-06 18:19:30 | [diff] [blame] | 48 | |
[email protected] | bc3d66a | 2013-08-10 07:29:09 | [diff] [blame] | 49 | # Few binaries in the Android SDK require 32-bit libraries on the host. |
50 | sudo apt-get -y install lib32z1 g++-multilib | ||||
51 | |||||
[email protected] | 5de189ab | 2013-08-29 03:09:45 | [diff] [blame] | 52 | if [ $(/usr/bin/lsb_release -r -s | cut -d"." -f1) -ge 12 ]; then |
53 | # Ubuntu >= 12.x | ||||
[email protected] | 457088f2 | 2012-09-26 21:47:07 | [diff] [blame] | 54 | sudo apt-get -y install ant |
55 | |||||
56 | # Java can not be installed via ppa on Ubuntu 12.04+ so we'll | ||||
57 | # simply check to see if it has been setup properly -- if not | ||||
58 | # let the user know. | ||||
59 | |||||
60 | if ! java -version 2>&1 | grep -q "Java(TM)"; then | ||||
61 | echo "****************************************************************" | ||||
62 | echo "You need to install the Oracle Java SDK from http://goo.gl/uPRSq" | ||||
63 | echo "and configure it as the default command-line Java environment." | ||||
64 | echo "****************************************************************" | ||||
65 | exit | ||||
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 66 | fi |
[email protected] | 457088f2 | 2012-09-26 21:47:07 | [diff] [blame] | 67 | |
68 | else | ||||
69 | # Ubuntu 10.x | ||||
70 | |||||
71 | sudo apt-get -y install ant1.8 | ||||
72 | |||||
73 | # Install sun-java6 stuff | ||||
74 | sudo apt-get -y install sun-java6-bin sun-java6-jre sun-java6-jdk | ||||
75 | |||||
76 | # Switch version of Java to java-6-sun | ||||
77 | # Sun's java is missing certain Java plugins (e.g. for firefox, mozilla). | ||||
78 | # These are not required to build, and thus are treated only as warnings. | ||||
79 | # Any errors in updating java alternatives which are not '*-javaplugin.so' | ||||
80 | # will cause errors and stop the script from completing successfully. | ||||
81 | if ! sudo update-java-alternatives -s java-6-sun \ | ||||
82 | >& "${TEMPDIR}"/update-java-alternatives.out | ||||
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 83 | then |
[email protected] | 457088f2 | 2012-09-26 21:47:07 | [diff] [blame] | 84 | # Check that there are the expected javaplugin.so errors for the update |
85 | if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \ | ||||
86 | /dev/null | ||||
87 | then | ||||
88 | # Print as warnings all the javaplugin.so errors | ||||
89 | echo 'WARNING: java-6-sun has no alternatives for the following plugins:' | ||||
90 | grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out | ||||
91 | fi | ||||
92 | # Check if there are any errors that are not javaplugin.so | ||||
93 | if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \ | ||||
94 | >& /dev/null | ||||
95 | then | ||||
96 | # If there are non-javaplugin.so errors, treat as errors and exit | ||||
97 | echo 'ERRORS: Failed to update alternatives for java-6-sun:' | ||||
98 | grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out | ||||
99 | exit 1 | ||||
100 | fi | ||||
[email protected] | 4ba8681e | 2012-03-14 07:23:30 | [diff] [blame] | 101 | fi |
102 | fi | ||||
103 | |||||
[email protected] | c4fabbc3 | 2012-03-07 02:22:18 | [diff] [blame] | 104 | echo "install-build-deps-android.sh complete." |