|
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 |
|
15 if ! uname -m | egrep -q "i686|x86_64"; then |
|
16 echo "Only x86 architectures are currently supported" >&2 |
|
17 exit |
|
18 fi |
|
19 |
|
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 |
|
26 # The temporary directory used to store output of update-java-alternatives |
|
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 |
|
36 sudo apt-get update |
|
37 |
|
38 # Fix deps |
|
39 sudo apt-get -f install |
|
40 |
|
41 # Install deps |
|
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. |
|
45 |
|
46 # common |
|
47 sudo apt-get -y install python-pexpect xvfb x11-utils |
|
48 |
|
49 if /usr/bin/lsb_release -r -s | grep -q "12."; then |
|
50 # Ubuntu 12.x |
|
51 sudo apt-get -y install ant |
|
52 |
|
53 # Java can not be installed via ppa on Ubuntu 12.04+ so we'll |
|
54 # simply check to see if it has been setup properly -- if not |
|
55 # let the user know. |
|
56 |
|
57 if ! java -version 2>&1 | grep -q "Java(TM)"; then |
|
58 echo "****************************************************************" |
|
59 echo "You need to install the Oracle Java SDK from http://goo.gl/uPRSq" |
|
60 echo "and configure it as the default command-line Java environment." |
|
61 echo "****************************************************************" |
|
62 exit |
|
63 fi |
|
64 |
|
65 else |
|
66 # Ubuntu 10.x |
|
67 |
|
68 sudo apt-get -y install ant1.8 |
|
69 |
|
70 # Install sun-java6 stuff |
|
71 sudo apt-get -y install sun-java6-bin sun-java6-jre sun-java6-jdk |
|
72 |
|
73 # Switch version of Java to java-6-sun |
|
74 # Sun's java is missing certain Java plugins (e.g. for firefox, mozilla). |
|
75 # These are not required to build, and thus are treated only as warnings. |
|
76 # Any errors in updating java alternatives which are not '*-javaplugin.so' |
|
77 # will cause errors and stop the script from completing successfully. |
|
78 if ! sudo update-java-alternatives -s java-6-sun \ |
|
79 >& "${TEMPDIR}"/update-java-alternatives.out |
|
80 then |
|
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 |
|
98 fi |
|
99 fi |
|
100 |
|
101 echo "install-build-deps-android.sh complete." |