install-build-deps-android.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash -e
  2. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Script to install everything needed to build chromium on android that
  6. # requires sudo privileges.
  7. # See http://code.google.com/p/chromium/wiki/AndroidBuildInstructions
  8. # This script installs the sun-java6 packages (bin, jre and jdk). Sun requires
  9. # a license agreement, so upon installation it will prompt the user. To get
  10. # past the curses-based dialog press TAB <ret> TAB <ret> to agree.
  11. if ! uname -m | egrep -q "i686|x86_64"; then
  12. echo "Only x86 architectures are currently supported" >&2
  13. exit
  14. fi
  15. if [ "x$(id -u)" != x0 ]; then
  16. echo "Running as non-root user."
  17. echo "You might have to enter your password one or more times for 'sudo'."
  18. echo
  19. fi
  20. # The temporary directory used to store output of update-java-alternatives
  21. TEMPDIR=$(mktemp -d)
  22. cleanup() {
  23. local status=${?}
  24. trap - EXIT
  25. rm -rf "${TEMPDIR}"
  26. exit ${status}
  27. }
  28. trap cleanup EXIT
  29. sudo apt-get update
  30. # Fix deps
  31. sudo apt-get -f install
  32. # Install deps
  33. # This step differs depending on what Ubuntu release we are running
  34. # on since the package names are different, and Sun's Java must
  35. # be installed manually on late-model versions.
  36. # common
  37. sudo apt-get -y install python-pexpect xvfb x11-utils
  38. if /usr/bin/lsb_release -r -s | grep -q "12."; then
  39. # Ubuntu 12.x
  40. sudo apt-get -y install ant
  41. # Java can not be installed via ppa on Ubuntu 12.04+ so we'll
  42. # simply check to see if it has been setup properly -- if not
  43. # let the user know.
  44. if ! java -version 2>&1 | grep -q "Java(TM)"; then
  45. echo "****************************************************************"
  46. echo "You need to install the Oracle Java SDK from http://goo.gl/uPRSq"
  47. echo "and configure it as the default command-line Java environment."
  48. echo "****************************************************************"
  49. exit
  50. fi
  51. else
  52. # Ubuntu 10.x
  53. sudo apt-get -y install ant1.8
  54. # Install sun-java6 stuff
  55. sudo apt-get -y install sun-java6-bin sun-java6-jre sun-java6-jdk
  56. # Switch version of Java to java-6-sun
  57. # Sun's java is missing certain Java plugins (e.g. for firefox, mozilla).
  58. # These are not required to build, and thus are treated only as warnings.
  59. # Any errors in updating java alternatives which are not '*-javaplugin.so'
  60. # will cause errors and stop the script from completing successfully.
  61. if ! sudo update-java-alternatives -s java-6-sun \
  62. >& "${TEMPDIR}"/update-java-alternatives.out
  63. then
  64. # Check that there are the expected javaplugin.so errors for the update
  65. if grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out >& \
  66. /dev/null
  67. then
  68. # Print as warnings all the javaplugin.so errors
  69. echo 'WARNING: java-6-sun has no alternatives for the following plugins:'
  70. grep 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out
  71. fi
  72. # Check if there are any errors that are not javaplugin.so
  73. if grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out \
  74. >& /dev/null
  75. then
  76. # If there are non-javaplugin.so errors, treat as errors and exit
  77. echo 'ERRORS: Failed to update alternatives for java-6-sun:'
  78. grep -v 'javaplugin.so' "${TEMPDIR}"/update-java-alternatives.out
  79. exit 1
  80. fi
  81. fi
  82. fi
  83. echo "install-build-deps-android.sh complete."