OLD | NEW |
---|---|
1 #!/bin/bash -e | 1 #!/bin/bash |
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, including | 7 # Script to install everything needed to build chromium on android, including |
8 # items requiring sudo privileges. | 8 # items requiring sudo privileges. |
9 # See https://www.chromium.org/developers/how-tos/android-build-instructions | 9 # See https://www.chromium.org/developers/how-tos/android-build-instructions |
10 | 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 args="$@" | 11 args="$@" |
16 | 12 |
17 if ! uname -m | egrep -q "i686|x86_64"; then | 13 if ! uname -m | egrep -q "i686|x86_64"; then |
18 echo "Only x86 architectures are currently supported" >&2 | 14 echo "Only x86 architectures are currently supported" >&2 |
19 exit | 15 exit |
20 fi | 16 fi |
21 | 17 |
18 # Exit if any commands fail. | |
19 set -e | |
20 | |
22 lsb_release=$(lsb_release --codename --short) | 21 lsb_release=$(lsb_release --codename --short) |
23 | 22 |
24 case $lsb_release in | |
25 xenial|yakkety) | |
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 ;; | |
33 esac | |
34 | |
35 # Install first the default Linux build deps. | 23 # Install first the default Linux build deps. |
36 "$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \ | 24 "$(dirname "${BASH_SOURCE[0]}")/install-build-deps.sh" \ |
37 --no-syms --lib32 --no-arm --no-chromeos-fonts --no-nacl --no-prompt "${args}" | 25 --no-syms --lib32 --no-arm --no-chromeos-fonts --no-nacl --no-prompt "${args}" |
38 | 26 |
39 # The temporary directory used to store output of update-java-alternatives | |
40 TEMPDIR=$(mktemp -d) | |
41 cleanup() { | |
42 local status=${?} | |
43 trap - EXIT | |
44 rm -rf "${TEMPDIR}" | |
45 exit ${status} | |
46 } | |
47 trap cleanup EXIT | |
48 | |
49 # Fix deps | 27 # Fix deps |
50 sudo apt-get -f install | 28 sudo apt-get -f install |
51 | 29 |
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 | 30 # common |
58 sudo apt-get -y install lib32z1 lighttpd python-pexpect xvfb x11-utils | 31 sudo apt-get -y install lib32z1 lighttpd python-pexpect xvfb x11-utils |
59 | 32 |
60 # Some binaries in the Android SDK require 32-bit libraries on the host. | 33 # 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 | 34 # See https://developer.android.com/sdk/installing/index.html?pkg=tools |
62 if [[ $lsb_release == "precise" ]]; then | 35 if [[ $lsb_release == "precise" ]]; then |
63 sudo apt-get -y install ia32-libs | 36 sudo apt-get -y install ia32-libs |
64 else | 37 else |
65 sudo apt-get -y install libncurses5:i386 libstdc++6:i386 zlib1g:i386 | 38 sudo apt-get -y install libncurses5:i386 libstdc++6:i386 zlib1g:i386 |
66 fi | 39 fi |
67 | 40 |
41 # Required by //components/cronet/tools/generate_javadoc.py | |
42 # TODO(375324): Stop requiring ANT. | |
68 sudo apt-get -y install ant | 43 sudo apt-get -y install ant |
69 | 44 |
70 # Install openjdk and openjre stuff | 45 # Do our own error handling for java. |
71 sudo apt-get -y install $java_pkgs | 46 set +e |
72 | 47 |
73 # Switch version of Java to openjdk 7. | 48 function IsJava8() { |
74 # Some Java plugins (e.g. for firefox, mozilla) are not required to build, and | 49 # Arg is either "java" or "javac" |
75 # thus are treated only as warnings. Any errors in updating java alternatives | 50 $1 -version 2>&1 | grep -q '1\.8' |
76 # which are not '*-javaplugin.so' will cause errors and stop the script from | 51 } |
77 # completing successfully. | 52 |
78 if ! sudo update-java-alternatives -s $java_alternative \ | 53 if ! (IsJava8 java && IsJava8 javac); then |
79 >& "${TEMPDIR}"/update-java-alternatives.out | 54 sudo apt-get -y install openjdk-8-jre openjdk-8-jdk |
80 then | 55 fi |
81 # Check that there are the expected javaplugin.so errors for the update | 56 |
82 if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \ | 57 # There can be several reasons why java8 is not default despite being installed. |
83 /dev/null | 58 # Just show an error and exit. |
84 then | 59 if ! (IsJava8 java && IsJava8 javac); then |
85 # Print as warnings all the javaplugin.so errors | 60 echo |
86 echo 'WARNING: java-6-sun has no alternatives for the following plugins:' | 61 echo "Automatic java installation failed." |
87 grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out | 62 echo '`java -version` reports:' |
88 fi | 63 java -version |
89 # Check if there are any errors that are not javaplugin.so | 64 echo |
90 if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \ | 65 echo '`javac -version` reports:' |
91 >& /dev/null | 66 javac -version |
92 then | 67 echo |
93 # If there are non-javaplugin.so errors, treat as errors and exit | 68 echo "Please ensure that JDK 8 is installed and resolves first in your PATH." |
94 echo 'ERRORS: Failed to update alternatives for java-6-sun:' | 69 echo -n '`which java` reports: ' |
95 grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out | 70 which java |
96 exit 1 | 71 echo -n '`which javac` reports: ' |
97 fi | 72 which javac |
73 echo | |
74 echo "You might also try running:" | |
75 echo " sudo update-java-alternatives -s java-1.8.0-openjdk-amd64" | |
jbudorick
2017/02/01 16:30:39
ah, ok, with this in the error text, I'm ok with r
| |
76 exit 1 | |
98 fi | 77 fi |
99 | 78 |
100 echo "install-build-deps-android.sh complete." | 79 echo "install-build-deps-android.sh complete." |
OLD | NEW |