OLD | NEW |
1 #!/bin/bash -e | 1 #!/bin/bash -e |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to install everything needed to build chromium on android that | 7 # Script to install everything needed to build chromium on android that |
8 # requires sudo privileges. | 8 # requires sudo privileges. |
9 # See http://code.google.com/p/chromium/wiki/AndroidBuildInstructions | 9 # See http://code.google.com/p/chromium/wiki/AndroidBuildInstructions |
10 | 10 |
11 DOWNLOAD_URL="http://ftp.us.debian.org/debian/pool/non-free/s/sun-java6" | 11 # This script installs the sun-java6 packages (bin, jre and jdk). Sun requires |
12 | 12 # a license agreement, so upon installation it will prompt the user. To get |
13 BIN_FILE_NAME="sun-java6-bin_6.26-0squeeze1_amd64.deb" | 13 # past the curses-based dialog press TAB <ret> TAB <ret> to agree. |
14 JRE_FILE_NAME="sun-java6-jre_6.26-0squeeze1_all.deb" | |
15 JDK_FILE_NAME="sun-java6-jdk_6.26-0squeeze1_amd64.deb" | |
16 | 14 |
17 if ! uname -m | egrep -q "i686|x86_64"; then | 15 if ! uname -m | egrep -q "i686|x86_64"; then |
18 echo "Only x86 architectures are currently supported" >&2 | 16 echo "Only x86 architectures are currently supported" >&2 |
19 exit | 17 exit |
20 fi | 18 fi |
21 | 19 |
22 if [ "x$(id -u)" != x0 ]; then | 20 if [ "x$(id -u)" != x0 ]; then |
23 echo "Running as non-root user." | 21 echo "Running as non-root user." |
24 echo "You might have to enter your password one or more times for 'sudo'." | 22 echo "You might have to enter your password one or more times for 'sudo'." |
25 echo | 23 echo |
26 fi | 24 fi |
27 | 25 |
28 sudo apt-get update | 26 # The temporary directory used to store output of update-java-alternatives |
29 | |
30 # The temporary directory used to store the downloaded file. | |
31 TEMPDIR=$(mktemp -d) | 27 TEMPDIR=$(mktemp -d) |
32 cleanup() { | 28 cleanup() { |
33 local status=${?} | 29 local status=${?} |
34 trap - EXIT | 30 trap - EXIT |
35 rm -rf "${TEMPDIR}" | 31 rm -rf "${TEMPDIR}" |
36 exit ${status} | 32 exit ${status} |
37 } | 33 } |
38 trap cleanup EXIT | 34 trap cleanup EXIT |
39 | 35 |
40 ########################################################## | 36 sudo apt-get update |
41 # Download (i.e. wget) and install debian package. | |
42 # The current directory is changed in this function. | |
43 # Arguments: | |
44 # file_name | |
45 # Returns: | |
46 # None | |
47 ########################################################## | |
48 install_deb_pkg() { | |
49 local file_name="${1}" | |
50 local download_url="${DOWNLOAD_URL}/${file_name}" | |
51 | 37 |
52 cd "${TEMPDIR}" | 38 # Fix deps |
53 wget "${download_url}" | 39 sudo apt-get -f install |
54 | 40 |
55 echo "Install ${file_name}" | 41 # Install python-pexpect |
56 sudo dpkg -i "${file_name}" | 42 sudo apt-get install python-pexpect |
57 } | |
58 | 43 |
| 44 # Install sun-java6 stuff |
| 45 sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk |
| 46 |
| 47 # Switch version of Java to java-6-sun |
| 48 # Sun's java is missing certain Java plugins (e.g. for firefox, mozilla). These |
| 49 # are not required to build, and thus are treated only as warnings. Any errors |
| 50 # in updating java alternatives which are not '*-javaplugin.so' will cause |
| 51 # errors and stop the script from completing successfully. |
| 52 if ! sudo update-java-alternatives -s java-6-sun \ |
| 53 >& "${TEMPDIR}"/update-java-alternatives.out |
| 54 then |
| 55 # Check that there are the expected javaplugin.so errors for the update |
| 56 if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& /dev/null |
| 57 then |
| 58 # Print as warnings all the javaplugin.so errors |
| 59 echo 'WARNING: java-6-sun has no alternatives for the following plugins:' |
| 60 grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out |
| 61 fi |
| 62 # Check if there are any errors that are not javaplugin.so |
| 63 if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \ |
| 64 >& /dev/null |
| 65 then |
| 66 # If there are non-javaplugin.so errors, treat as errors and exit |
| 67 echo 'ERRORS: Failed to update alternatives for java-6-sun:' |
| 68 grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out |
| 69 exit 1 |
| 70 fi |
| 71 fi |
59 | 72 |
60 # Install ant | 73 # Install ant |
61 sudo apt-get install python-pexpect ant | 74 sudo apt-get install ant |
62 | |
63 # Install sun-java6-bin | |
64 install_deb_pkg "${BIN_FILE_NAME}" | |
65 | |
66 # Install sun-java6-jre | |
67 install_deb_pkg "${JRE_FILE_NAME}" | |
68 | |
69 # Install sun-java6-jdk | |
70 install_deb_pkg "${JDK_FILE_NAME}" | |
71 | |
72 # Switch version of Java to java-6-sun | |
73 sudo update-java-alternatives -s java-6-sun | |
74 | 75 |
75 echo "install-build-deps-android.sh complete." | 76 echo "install-build-deps-android.sh complete." |
OLD | NEW |