[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
[email protected] | aac39c9 | 2012-02-08 18:39:53 | [diff] [blame] | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | e46cdae | 2009-08-25 20:59:27 | [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] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 7 | # Script to install everything needed to build chromium (well, ideally, anyway) |
mostynb | df175a8 | 2016-02-08 23:27:20 | [diff] [blame] | 8 | # See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 9 | |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 10 | usage() { |
| 11 | echo "Usage: $0 [--options]" |
| 12 | echo "Options:" |
| 13 | echo "--[no-]syms: enable or disable installation of debugging symbols" |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 14 | echo "--lib32: enable installation of 32-bit libraries, e.g. for V8 snapshot" |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 15 | echo "--[no-]arm: enable or disable installation of arm cross toolchain" |
[email protected] | bd29cdd | 2013-02-22 03:49:20 | [diff] [blame] | 16 | echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\ |
| 17 | "fonts" |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 18 | echo "--[no-]nacl: enable or disable installation of prerequisites for"\ |
| 19 | "building standalone NaCl and all its toolchains" |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 20 | echo "--no-prompt: silently select standard options/defaults" |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 21 | echo "--quick-check: quickly try to determine if dependencies are installed" |
| 22 | echo " (this avoids interactive prompts and sudo commands," |
| 23 | echo " so might not be 100% accurate)" |
| 24 | echo "--unsupported: attempt installation even on unsupported systems" |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 25 | echo "Script will prompt interactively if options not given." |
| 26 | exit 1 |
| 27 | } |
| 28 | |
thomasanderson | 4e3d30fe | 2016-12-07 18:58:34 | [diff] [blame] | 29 | # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is |
| 30 | # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has |
| 31 | # been provided to yes_no(), the function also accepts RETURN as a user input. |
| 32 | # The parameter specifies the exit code that should be returned in that case. |
| 33 | # The function will echo the user's selection followed by a newline character. |
| 34 | # Users can abort the function by pressing CTRL-C. This will call "exit 1". |
| 35 | yes_no() { |
| 36 | if [ 0 -ne "${do_default-0}" ] ; then |
| 37 | [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 38 | return $1 |
| 39 | fi |
| 40 | local c |
| 41 | while :; do |
| 42 | c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT |
| 43 | stty -echo iuclc -icanon 2>/dev/null |
| 44 | dd count=1 bs=1 2>/dev/null | od -An -tx1)" |
| 45 | case "$c" in |
| 46 | " 0a") if [ -n "$1" ]; then |
| 47 | [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 48 | return $1 |
| 49 | fi |
| 50 | ;; |
| 51 | " 79") echo "Y" |
| 52 | return 0 |
| 53 | ;; |
| 54 | " 6e") echo "N" |
| 55 | return 1 |
| 56 | ;; |
| 57 | "") echo "Aborted" >&2 |
| 58 | exit 1 |
| 59 | ;; |
| 60 | *) # The user pressed an unrecognized key. As we are not echoing |
| 61 | # any incorrect user input, alert the user by ringing the bell. |
| 62 | (tput bel) 2>/dev/null |
| 63 | ;; |
| 64 | esac |
| 65 | done |
| 66 | } |
| 67 | |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 68 | # Checks whether a particular package is available in the repos. |
| 69 | # USAGE: $ package_exists <package name> |
| 70 | package_exists() { |
thomasanderson | b4a2bca | 2016-12-08 06:46:05 | [diff] [blame^] | 71 | [ ! -z "`apt-cache search --names-only "$1"`" ] |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 72 | } |
| 73 | |
[email protected] | fbeddf2 | 2014-01-17 23:59:01 | [diff] [blame] | 74 | # These default to on because (some) bots need them and it keeps things |
| 75 | # simple for the bot setup if all bots just run the script in its default |
| 76 | # mode. Developers who don't want stuff they don't need installed on their |
| 77 | # own workstations can pass --no-arm --no-nacl when running the script. |
| 78 | do_inst_arm=1 |
| 79 | do_inst_nacl=1 |
| 80 | |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 81 | while test "$1" != "" |
| 82 | do |
| 83 | case "$1" in |
[email protected] | ce77464 | 2011-09-12 23:21:39 | [diff] [blame] | 84 | --syms) do_inst_syms=1;; |
| 85 | --no-syms) do_inst_syms=0;; |
[email protected] | ce77464 | 2011-09-12 23:21:39 | [diff] [blame] | 86 | --lib32) do_inst_lib32=1;; |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 87 | --arm) do_inst_arm=1;; |
| 88 | --no-arm) do_inst_arm=0;; |
[email protected] | bd29cdd | 2013-02-22 03:49:20 | [diff] [blame] | 89 | --chromeos-fonts) do_inst_chromeos_fonts=1;; |
| 90 | --no-chromeos-fonts) do_inst_chromeos_fonts=0;; |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 91 | --nacl) do_inst_nacl=1;; |
| 92 | --no-nacl) do_inst_nacl=0;; |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 93 | --no-prompt) do_default=1 |
| 94 | do_quietly="-qq --assume-yes" |
| 95 | ;; |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 96 | --quick-check) do_quick_check=1;; |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 97 | --unsupported) do_unsupported=1;; |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 98 | *) usage;; |
| 99 | esac |
| 100 | shift |
| 101 | done |
| 102 | |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 103 | if test "$do_inst_arm" = "1"; then |
| 104 | do_inst_lib32=1 |
| 105 | fi |
| 106 | |
[email protected] | 0febc9b | 2014-05-22 20:07:19 | [diff] [blame] | 107 | # Check for lsb_release command in $PATH |
| 108 | if ! which lsb_release > /dev/null; then |
| 109 | echo "ERROR: lsb_release not found in \$PATH" >&2 |
| 110 | exit 1; |
| 111 | fi |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 112 | |
[email protected] | 0febc9b | 2014-05-22 20:07:19 | [diff] [blame] | 113 | lsb_release=$(lsb_release --codename --short) |
thomasanderson | b4a2bca | 2016-12-08 06:46:05 | [diff] [blame^] | 114 | supported_releases="(precise|trusty|utopic|vivid|wily|xenial|jessie)" |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 115 | if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then |
thomasanderson | b4a2bca | 2016-12-08 06:46:05 | [diff] [blame^] | 116 | if [[ ! $lsb_release =~ $supported_releases ]]; then |
anthonyvd | 2ae919e5 | 2016-11-21 19:47:12 | [diff] [blame] | 117 | echo "ERROR: Only Ubuntu 12.04 (precise), 14.04 (trusty), " \ |
thomasanderson | b4a2bca | 2016-12-08 06:46:05 | [diff] [blame^] | 118 | "14.10 (utopic), 15.04 (vivid), 15.10 (wily) and 16.04 (xenial), " \ |
| 119 | "and Debian 8 (jessie) are currently supported" >&2 |
anthonyvd | 2ae919e5 | 2016-11-21 19:47:12 | [diff] [blame] | 120 | exit 1 |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 121 | fi |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 122 | |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 123 | if ! uname -m | egrep -q "i686|x86_64"; then |
anthonyvd | 2ae919e5 | 2016-11-21 19:47:12 | [diff] [blame] | 124 | echo "Only x86 architectures are currently supported" >&2 |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 125 | exit |
| 126 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 127 | fi |
| 128 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 129 | if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 130 | echo "Running as non-root user." |
| 131 | echo "You might have to enter your password one or more times for 'sudo'." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 132 | echo |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 133 | fi |
| 134 | |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 135 | # Packages needed for chromeos only |
dnj | 6a8491d1 | 2015-05-26 21:08:12 | [diff] [blame] | 136 | chromeos_dev_list="libbluetooth-dev libxkbcommon-dev realpath" |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 137 | |
[email protected] | b61f688 | 2013-11-14 20:41:41 | [diff] [blame] | 138 | # Packages needed for development |
halton.huo | 3e728c4 | 2016-01-20 05:12:23 | [diff] [blame] | 139 | dev_list="bison cdbs curl dpkg-dev elfutils devscripts fakeroot |
jack | f3d9888 | 2016-11-21 19:33:58 | [diff] [blame] | 140 | flex fonts-ipafont fonts-thai-tlwg g++ git-core git-svn gperf |
thomasanderson | 5ef5c3d | 2016-12-08 01:59:19 | [diff] [blame] | 141 | libasound2-dev libbrlapi-dev libav-tools libbz2-dev libcairo2-dev |
| 142 | libcap-dev libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev |
| 143 | libffi-dev libgconf2-dev libglib2.0-dev libglu1-mesa-dev |
| 144 | libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev |
| 145 | libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev |
| 146 | libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl |
| 147 | libxslt1-dev libxss-dev libxt-dev libxtst-dev openbox patch perl |
| 148 | pkg-config python python-cherrypy3 python-crypto python-dev |
| 149 | python-numpy python-opencv python-openssl python-psutil python-yaml |
| 150 | rpm ruby subversion ttf-dejavu-core wdiff xcompmgr zip |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 151 | $chromeos_dev_list" |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 152 | |
[email protected] | f16aabf | 2012-08-15 21:00:14 | [diff] [blame] | 153 | # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built |
[email protected] | f8ceadb | 2014-08-18 12:30:23 | [diff] [blame] | 154 | # NaCl binaries. |
ki.stfu | 0a79d699 | 2015-09-17 07:27:12 | [diff] [blame] | 155 | if file -L /sbin/init | grep -q 'ELF 64-bit'; then |
[email protected] | d93d68b1 | 2012-10-15 06:39:53 | [diff] [blame] | 156 | dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6" |
[email protected] | f16aabf | 2012-08-15 21:00:14 | [diff] [blame] | 157 | fi |
| 158 | |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 159 | # Run-time libraries required by chromeos only |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 160 | chromeos_lib_list="libpulse0 libbz2-1.0" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 161 | |
| 162 | # Full list of required run-time libraries |
[email protected] | d8f5232 | 2013-10-29 05:50:38 | [diff] [blame] | 163 | lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1 |
tommycli | cd96b6f | 2016-03-14 23:56:56 | [diff] [blame] | 164 | libffi6 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 |
| 165 | libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0 |
thomasanderson | 41f9e395 | 2016-08-05 00:50:43 | [diff] [blame] | 166 | libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6 libx11-xcb1 |
| 167 | libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 |
| 168 | libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 |
| 169 | libxtst6 zlib1g $chromeos_lib_list" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 170 | |
| 171 | # Debugging symbols for all of the run-time libraries |
reveman | dd26069a | 2015-11-09 21:39:21 | [diff] [blame] | 172 | dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libffi6-dbg libfontconfig1-dbg |
[email protected] | 6ffd19f35 | 2012-10-23 02:00:41 | [diff] [blame] | 173 | libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg |
thomasanderson | 41f9e395 | 2016-08-05 00:50:43 | [diff] [blame] | 174 | libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libx11-xcb1-dbg |
| 175 | libxau6-dbg libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg |
| 176 | libxdamage1-dbg libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg |
| 177 | libxinerama1-dbg libxrandr2-dbg libxrender1-dbg libxtst6-dbg |
| 178 | zlib1g-dbg" |
lfg | ad917d1 | 2015-03-17 23:28:00 | [diff] [blame] | 179 | |
| 180 | # Find the proper version of libstdc++6-4.x-dbg. |
| 181 | if [ "x$lsb_release" = "xprecise" ]; then |
| 182 | dbg_list="${dbg_list} libstdc++6-4.6-dbg" |
| 183 | elif [ "x$lsb_release" = "xtrusty" ]; then |
| 184 | dbg_list="${dbg_list} libstdc++6-4.8-dbg" |
| 185 | else |
| 186 | dbg_list="${dbg_list} libstdc++6-4.9-dbg" |
| 187 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 188 | |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 189 | # 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf |
| 190 | lib32_list="linux-libc-dev:i386" |
| 191 | |
[email protected] | 3f85dac3 | 2013-10-29 02:38:46 | [diff] [blame] | 192 | # arm cross toolchain packages needed to build chrome on armhf |
thomasanderson | 4e3d30fe | 2016-12-07 18:58:34 | [diff] [blame] | 193 | EM_REPO="deb http://emdebian.org/tools/debian/ jessie main" |
| 194 | EM_SOURCE=$(cat <<EOF |
| 195 | # Repo added by Chromium $0 |
| 196 | ${EM_REPO} |
| 197 | # deb-src http://emdebian.org/tools/debian/ jessie main |
| 198 | EOF |
| 199 | ) |
| 200 | EM_ARCHIVE_KEY_FINGER="084C6C6F39159EDB67969AA87DE089671804772E" |
| 201 | GPP_ARM_PACKAGE="g++-arm-linux-gnueabihf" |
| 202 | case $lsb_release in |
| 203 | "jessie") |
| 204 | eval $(apt-config shell APT_SOURCESDIR 'Dir::Etc::sourceparts/d') |
| 205 | CROSSTOOLS_LIST="${APT_SOURCESDIR}/crosstools.list" |
| 206 | arm_list="libc6-dev:armhf |
| 207 | linux-libc-dev:armhf" |
| 208 | if test "$do_inst_arm" = "1"; then |
| 209 | if $(dpkg-query -W ${GPP_ARM_PACKAGE} &>/dev/null); then |
| 210 | arm_list+=" ${GPP_ARM_PACKAGE}" |
| 211 | else |
| 212 | echo "The Debian Cross-toolchains repository is necessary to" |
| 213 | echo "cross-compile Chromium for arm." |
| 214 | echo -n "Do you want me to add it for you (y/N) " |
| 215 | if yes_no 1; then |
| 216 | gpg --keyserver pgp.mit.edu --recv-keys ${EM_ARCHIVE_KEY_FINGER} |
| 217 | gpg -a --export ${EM_ARCHIVE_KEY_FINGER} | sudo apt-key add - |
| 218 | if ! grep "^${EM_REPO}" "${CROSSTOOLS_LIST}" &>/dev/null; then |
| 219 | echo "${EM_SOURCE}" | sudo tee -a "${CROSSTOOLS_LIST}" >/dev/null |
| 220 | fi |
| 221 | arm_list+=" ${GPP_ARM_PACKAGE}" |
| 222 | fi |
| 223 | fi |
| 224 | fi |
| 225 | ;; |
| 226 | *) |
| 227 | arm_list="libc6-dev-armhf-cross |
| 228 | linux-libc-dev-armhf-cross |
| 229 | ${GPP_ARM_PACKAGE}" |
| 230 | ;; |
| 231 | esac |
[email protected] | 31a60553 | 2011-08-23 22:27:35 | [diff] [blame] | 232 | |
sbc | b5d4ded | 2015-04-01 17:49:03 | [diff] [blame] | 233 | # Work around for dependency issue Ubuntu/Trusty: http://crbug.com/435056 |
friedman | bf8b90a | 2016-04-21 01:15:48 | [diff] [blame] | 234 | case $lsb_release in |
| 235 | trusty) |
| 236 | arm_list+=" g++-4.8-multilib-arm-linux-gnueabihf |
| 237 | gcc-4.8-multilib-arm-linux-gnueabihf" |
| 238 | ;; |
| 239 | wily) |
| 240 | arm_list+=" g++-5-multilib-arm-linux-gnueabihf |
| 241 | gcc-5-multilib-arm-linux-gnueabihf |
| 242 | gcc-arm-linux-gnueabihf" |
| 243 | ;; |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 244 | xenial) |
| 245 | arm_list+=" g++-5-multilib-arm-linux-gnueabihf |
| 246 | gcc-5-multilib-arm-linux-gnueabihf |
| 247 | gcc-arm-linux-gnueabihf" |
| 248 | ;; |
friedman | bf8b90a | 2016-04-21 01:15:48 | [diff] [blame] | 249 | esac |
sbc | b5d4ded | 2015-04-01 17:49:03 | [diff] [blame] | 250 | |
[email protected] | 713eac6 | 2014-06-02 23:10:03 | [diff] [blame] | 251 | # Packages to build NaCl, its toolchains, and its ports. |
Brad Nelson | 5e59c2c | 2014-09-06 06:18:45 | [diff] [blame] | 252 | naclports_list="ant autoconf bison cmake gawk intltool xutils-dev xsltproc" |
| 253 | nacl_list="g++-mingw-w64-i686 lib32z1-dev |
tommycli | cd96b6f | 2016-03-14 23:56:56 | [diff] [blame] | 254 | libasound2:i386 libcap2:i386 libelf-dev:i386 libfontconfig1:i386 |
| 255 | libgconf-2-4:i386 libglib2.0-0:i386 libgpm2:i386 libgtk2.0-0:i386 |
| 256 | libncurses5:i386 lib32ncurses5-dev libnss3:i386 libpango1.0-0:i386 |
sbc | 6ab44c3 | 2015-02-13 23:19:17 | [diff] [blame] | 257 | libssl1.0.0:i386 libtinfo-dev libtinfo-dev:i386 libtool |
[email protected] | 419a9a6 | 2014-06-19 18:26:18 | [diff] [blame] | 258 | libxcomposite1:i386 libxcursor1:i386 libxdamage1:i386 libxi6:i386 |
Brad Nelson | 5e59c2c | 2014-09-06 06:18:45 | [diff] [blame] | 259 | libxrandr2:i386 libxss1:i386 libxtst6:i386 texinfo xvfb |
| 260 | ${naclports_list}" |
[email protected] | 419a9a6 | 2014-06-19 18:26:18 | [diff] [blame] | 261 | |
torne | 8a6eb69 | 2015-11-05 12:43:08 | [diff] [blame] | 262 | # Find the proper version of packages that depend on mesa. Only one -lts variant |
| 263 | # of mesa can be installed and everything that depends on it must match. |
| 264 | |
| 265 | # Query for the name and status of all mesa LTS variants, filter for only |
| 266 | # installed packages, extract just the name, and eliminate duplicates (there can |
| 267 | # be more than one with the same name in the case of multiarch). Expand into an |
| 268 | # array. |
| 269 | mesa_packages=($(dpkg-query -Wf'${package} ${status}\n' \ |
torne | 12cd9f6c | 2016-02-24 18:52:23 | [diff] [blame] | 270 | libgl1-mesa-glx-lts-\* 2>/dev/null | \ |
torne | 8a6eb69 | 2015-11-05 12:43:08 | [diff] [blame] | 271 | grep " ok installed" | cut -d " " -f 1 | sort -u)) |
| 272 | if [ "${#mesa_packages[@]}" -eq 0 ]; then |
| 273 | mesa_variant="" |
| 274 | elif [ "${#mesa_packages[@]}" -eq 1 ]; then |
| 275 | # Strip the base package name and leave just "-lts-whatever" |
| 276 | mesa_variant="${mesa_packages[0]#libgl1-mesa-glx}" |
| 277 | else |
| 278 | echo "ERROR: unable to determine which libgl1-mesa-glx variant is installed." |
| 279 | exit 1 |
| 280 | fi |
[email protected] | 3a4bd5d | 2014-06-25 23:55:04 | [diff] [blame] | 281 | dev_list="${dev_list} libgbm-dev${mesa_variant} |
vabr | f1e8b17f | 2015-03-17 10:56:37 | [diff] [blame] | 282 | libgles2-mesa-dev${mesa_variant} libgl1-mesa-dev${mesa_variant} |
| 283 | mesa-common-dev${mesa_variant}" |
[email protected] | 419a9a6 | 2014-06-19 18:26:18 | [diff] [blame] | 284 | nacl_list="${nacl_list} libgl1-mesa-glx${mesa_variant}:i386" |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 285 | |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 286 | # Some package names have changed over time |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 287 | if package_exists libnspr4-dbg; then |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame] | 288 | dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg" |
| 289 | lib_list="${lib_list} libnspr4 libnss3" |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 290 | else |
| 291 | dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg" |
| 292 | lib_list="${lib_list} libnspr4-0d libnss3-1d" |
| 293 | fi |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 294 | if package_exists libjpeg-dev; then |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 295 | dev_list="${dev_list} libjpeg-dev" |
[email protected] | b11411c | 2012-03-21 22:09:41 | [diff] [blame] | 296 | else |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 297 | dev_list="${dev_list} libjpeg62-dev" |
[email protected] | b11411c | 2012-03-21 22:09:41 | [diff] [blame] | 298 | fi |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 299 | if package_exists libudev1; then |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 300 | dev_list="${dev_list} libudev1" |
[email protected] | ab9e6908 | 2014-06-05 15:28:52 | [diff] [blame] | 301 | nacl_list="${nacl_list} libudev1:i386" |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 302 | else |
| 303 | dev_list="${dev_list} libudev0" |
[email protected] | ab9e6908 | 2014-06-05 15:28:52 | [diff] [blame] | 304 | nacl_list="${nacl_list} libudev0:i386" |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 305 | fi |
[email protected] | 3ea4291 | 2013-09-06 06:23:57 | [diff] [blame] | 306 | if package_exists libbrlapi0.6; then |
| 307 | dev_list="${dev_list} libbrlapi0.6" |
| 308 | else |
| 309 | dev_list="${dev_list} libbrlapi0.5" |
| 310 | fi |
halton.huo | 3e728c4 | 2016-01-20 05:12:23 | [diff] [blame] | 311 | if package_exists apache2-bin; then |
| 312 | dev_list="${dev_list} apache2-bin" |
| 313 | else |
| 314 | dev_list="${dev_list} apache2.2-bin" |
| 315 | fi |
vadimsh | 278ff066 | 2016-05-19 00:06:28 | [diff] [blame] | 316 | if package_exists xfonts-mathml; then |
halton.huo | 3e728c4 | 2016-01-20 05:12:23 | [diff] [blame] | 317 | dev_list="${dev_list} xfonts-mathml" |
| 318 | fi |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 319 | if package_exists fonts-indic; then |
vadimsh | 278ff066 | 2016-05-19 00:06:28 | [diff] [blame] | 320 | dev_list="${dev_list} fonts-indic" |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 321 | else |
vadimsh | 278ff066 | 2016-05-19 00:06:28 | [diff] [blame] | 322 | dev_list="${dev_list} ttf-indic-fonts" |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 323 | fi |
| 324 | if package_exists php7.0-cgi; then |
vadimsh | 278ff066 | 2016-05-19 00:06:28 | [diff] [blame] | 325 | dev_list="${dev_list} php7.0-cgi libapache2-mod-php7.0" |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 326 | else |
vadimsh | 278ff066 | 2016-05-19 00:06:28 | [diff] [blame] | 327 | dev_list="${dev_list} php5-cgi libapache2-mod-php5" |
krasin | eef3d4b | 2016-04-22 00:52:18 | [diff] [blame] | 328 | fi |
thomasanderson | b4a2bca | 2016-12-08 06:46:05 | [diff] [blame^] | 329 | # ttf-mscorefonts-installer is in the Debian contrib repo, which has |
| 330 | # dependencies on non-free software. Install it only if the user has already |
| 331 | # enabled contrib. |
| 332 | if package_exists ttf-mscorefonts-installer; then |
| 333 | dev_list="${dev_list} ttf-mscorefonts-installer" |
| 334 | elif package_exists msttcorefonts; then |
| 335 | dev_list="${dev_list} msttcorefonts" |
| 336 | fi |
horo | 233d31c | 2016-11-16 03:43:00 | [diff] [blame] | 337 | # Ubuntu 16.04 has this package deleted. |
| 338 | if package_exists ttf-kochi-gothic; then |
| 339 | dev_list="${dev_list} ttf-kochi-gothic" |
| 340 | fi |
| 341 | # Ubuntu 16.04 has this package deleted. |
| 342 | if package_exists ttf-kochi-mincho; then |
| 343 | dev_list="${dev_list} ttf-kochi-mincho" |
| 344 | fi |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 345 | |
[email protected] | dc09977 | 2013-09-30 22:06:58 | [diff] [blame] | 346 | # Some packages are only needed if the distribution actually supports |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 347 | # installing them. |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 348 | if package_exists appmenu-gtk; then |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 349 | lib_list="$lib_list appmenu-gtk" |
[email protected] | 4da8fad | 2011-04-11 18:42:42 | [diff] [blame] | 350 | fi |
| 351 | |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 352 | # When cross building for arm/Android on 64-bit systems the host binaries |
| 353 | # that are part of v8 need to be compiled with -m32 which means |
| 354 | # that basic multilib support is needed. |
ki.stfu | 0a79d699 | 2015-09-17 07:27:12 | [diff] [blame] | 355 | if file -L /sbin/init | grep -q 'ELF 64-bit'; then |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 356 | # gcc-multilib conflicts with the arm cross compiler (at least in trusty) but |
| 357 | # g++-X.Y-multilib gives us the 32-bit support that we need. Find out the |
| 358 | # appropriate value of X and Y by seeing what version the current |
| 359 | # distribution's g++-multilib package depends on. |
| 360 | multilib_package=$(apt-cache depends g++-multilib --important | \ |
| 361 | grep -E --color=never --only-matching '\bg\+\+-[0-9.]+-multilib\b') |
| 362 | lib32_list="$lib32_list $multilib_package" |
| 363 | fi |
| 364 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 365 | if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0} |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 366 | then |
| 367 | echo "This script installs all tools and libraries needed to build Chromium." |
| 368 | echo "" |
| 369 | echo "For most of the libraries, it can also install debugging symbols, which" |
| 370 | echo "will allow you to debug code in the system libraries. Most developers" |
| 371 | echo "won't need these symbols." |
| 372 | echo -n "Do you want me to install them for you (y/N) " |
| 373 | if yes_no 1; then |
| 374 | do_inst_syms=1 |
| 375 | fi |
| 376 | fi |
| 377 | if test "$do_inst_syms" = "1"; then |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 378 | echo "Including debugging symbols." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 379 | else |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 380 | echo "Skipping debugging symbols." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 381 | dbg_list= |
| 382 | fi |
| 383 | |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 384 | if test "$do_inst_lib32" = "1" ; then |
| 385 | echo "Including 32-bit libraries for ARM/Android." |
| 386 | else |
| 387 | echo "Skipping 32-bit libraries for ARM/Android." |
| 388 | lib32_list= |
[email protected] | 9f28a9cf | 2012-12-17 23:31:40 | [diff] [blame] | 389 | fi |
| 390 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 391 | if test "$do_inst_arm" = "1" ; then |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 392 | echo "Including ARM cross toolchain." |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 393 | else |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 394 | echo "Skipping ARM cross toolchain." |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 395 | arm_list= |
| 396 | fi |
| 397 | |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 398 | if test "$do_inst_nacl" = "1"; then |
[email protected] | 713eac6 | 2014-06-02 23:10:03 | [diff] [blame] | 399 | echo "Including NaCl, NaCl toolchain, NaCl ports dependencies." |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 400 | else |
[email protected] | 713eac6 | 2014-06-02 23:10:03 | [diff] [blame] | 401 | echo "Skipping NaCl, NaCl toolchain, NaCl ports dependencies." |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 402 | nacl_list= |
| 403 | fi |
| 404 | |
johnme | 4bd1030 | 2015-01-06 11:25:52 | [diff] [blame] | 405 | # The `sort -r -s -t: -k2` sorts all the :i386 packages to the front, to avoid |
| 406 | # confusing dpkg-query (crbug.com/446172). |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 407 | packages="$( |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 408 | echo "${dev_list} ${lib_list} ${dbg_list} ${lib32_list} ${arm_list}"\ |
johnme | 4bd1030 | 2015-01-06 11:25:52 | [diff] [blame] | 409 | "${nacl_list}" | tr " " "\n" | sort -u | sort -r -s -t: -k2 | tr "\n" " " |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 410 | )" |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 411 | |
| 412 | if [ 1 -eq "${do_quick_check-0}" ] ; then |
thomasanderson | 73b3a441 | 2016-11-18 23:16:07 | [diff] [blame] | 413 | if ! missing_packages="$(dpkg-query -W -f ' ' ${packages} 2>&1)"; then |
| 414 | # Distinguish between packages that actually aren't available to the |
| 415 | # system (i.e. not in any repo) and packages that just aren't known to |
| 416 | # dpkg (i.e. managed by apt). |
| 417 | missing_packages="$(echo "${missing_packages}" | awk '{print $NF}')" |
| 418 | not_installed="" |
| 419 | unknown="" |
| 420 | for p in ${missing_packages}; do |
| 421 | if apt-cache show ${p} > /dev/null 2>&1; then |
| 422 | not_installed="${p}\n${not_installed}" |
| 423 | else |
| 424 | unknown="${p}\n${unknown}" |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 425 | fi |
thomasanderson | 73b3a441 | 2016-11-18 23:16:07 | [diff] [blame] | 426 | done |
| 427 | if [ -n "${not_installed}" ]; then |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 428 | echo "WARNING: The following packages are not installed:" |
thomasanderson | 73b3a441 | 2016-11-18 23:16:07 | [diff] [blame] | 429 | echo -e "${not_installed}" | sed -e "s/^/ /" |
| 430 | fi |
| 431 | if [ -n "${unknown}" ]; then |
| 432 | echo "WARNING: The following packages are unknown to your system" |
| 433 | echo "(maybe missing a repo or need to 'sudo apt-get update'):" |
| 434 | echo -e "${unknown}" | sed -e "s/^/ /" |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 435 | fi |
| 436 | exit 1 |
| 437 | fi |
| 438 | exit 0 |
| 439 | fi |
| 440 | |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 441 | if test "$do_inst_lib32" = "1" || test "$do_inst_nacl" = "1"; then |
thestig | 83d0350 | 2015-03-20 08:06:12 | [diff] [blame] | 442 | if [[ ! $lsb_release =~ (precise) ]]; then |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 443 | sudo dpkg --add-architecture i386 |
| 444 | fi |
thomasanderson | 4e3d30fe | 2016-12-07 18:58:34 | [diff] [blame] | 445 | if [[ $lsb_release = "jessie" ]]; then |
| 446 | sudo dpkg --add-architecture armhf |
| 447 | fi |
johnme | 49bb458a | 2014-11-27 15:45:31 | [diff] [blame] | 448 | fi |
sbc | 4256409 | 2015-04-01 01:01:28 | [diff] [blame] | 449 | sudo apt-get update |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 450 | |
| 451 | # We initially run "apt-get" with the --reinstall option and parse its output. |
| 452 | # This way, we can find all the packages that need to be newly installed |
| 453 | # without accidentally promoting any packages from "auto" to "manual". |
| 454 | # We then re-run "apt-get" with just the list of missing packages. |
| 455 | echo "Finding missing packages..." |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 456 | # Intentionally leaving $packages unquoted so it's more readable. |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 457 | echo "Packages required: " $packages |
| 458 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 459 | new_list_cmd="sudo apt-get install --reinstall $(echo $packages)" |
[email protected] | c3d8b15 | 2013-05-10 10:10:03 | [diff] [blame] | 460 | if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 461 | # We probably never hit this following line. |
thakis | 3e861de | 2016-06-14 14:24:01 | [diff] [blame] | 462 | echo "No missing packages, and the packages are up to date." |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 463 | elif [ $? -eq 1 ]; then |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 464 | # We expect apt-get to have exit status of 1. |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 465 | # This indicates that we cancelled the install with "yes n|". |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 466 | new_list=$(echo "$new_list" | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 467 | sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d') |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 468 | new_list=$(echo "$new_list" | sed 's/ *$//') |
| 469 | if [ -z "$new_list" ] ; then |
thakis | 3e861de | 2016-06-14 14:24:01 | [diff] [blame] | 470 | echo "No missing packages, and the packages are up to date." |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 471 | else |
| 472 | echo "Installing missing packages: $new_list." |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 473 | sudo apt-get install ${do_quietly-} ${new_list} |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 474 | fi |
| 475 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 476 | else |
| 477 | # An apt-get exit status of 100 indicates that a real error has occurred. |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 478 | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 479 | # I am intentionally leaving out the '"'s around new_list_cmd, |
| 480 | # as this makes it easier to cut and paste the output |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 481 | echo "The following command failed: " ${new_list_cmd} |
| 482 | echo |
| 483 | echo "It produces the following output:" |
| 484 | yes n | $new_list_cmd || true |
| 485 | echo |
| 486 | echo "You will have to install the above packages yourself." |
| 487 | echo |
| 488 | exit 100 |
| 489 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 490 | |
[email protected] | d96cc347 | 2013-09-19 00:53:30 | [diff] [blame] | 491 | # Install the Chrome OS default fonts. This must go after running |
| 492 | # apt-get, since install-chromeos-fonts depends on curl. |
| 493 | if test "$do_inst_chromeos_fonts" != "0"; then |
| 494 | echo |
| 495 | echo "Installing Chrome OS fonts." |
| 496 | dir=`echo $0 | sed -r -e 's/\/[^/]+$//'` |
| 497 | if ! sudo $dir/linux/install-chromeos-fonts.py; then |
| 498 | echo "ERROR: The installation of the Chrome OS default fonts failed." |
| 499 | if [ `stat -f -c %T $dir` == "nfs" ]; then |
| 500 | echo "The reason is that your repo is installed on a remote file system." |
| 501 | else |
| 502 | echo "This is expected if your repo is installed on a remote file system." |
| 503 | fi |
| 504 | echo "It is recommended to install your repo on a local file system." |
| 505 | echo "You can skip the installation of the Chrome OS default founts with" |
| 506 | echo "the command line option: --no-chromeos-fonts." |
| 507 | exit 1 |
| 508 | fi |
| 509 | else |
| 510 | echo "Skipping installation of Chrome OS fonts." |
| 511 | fi |
| 512 | |
sbc | 6ab44c3 | 2015-02-13 23:19:17 | [diff] [blame] | 513 | # $1 - target name |
| 514 | # $2 - link name |
| 515 | create_library_symlink() { |
| 516 | target=$1 |
| 517 | linkname=$2 |
| 518 | if [ -L $linkname ]; then |
| 519 | if [ "$(basename $(readlink $linkname))" != "$(basename $target)" ]; then |
| 520 | sudo rm $linkname |
| 521 | fi |
| 522 | fi |
| 523 | if [ ! -r $linkname ]; then |
| 524 | echo "Creating link: $linkname" |
| 525 | sudo ln -fs $target $linkname |
| 526 | fi |
| 527 | } |
| 528 | |
[email protected] | 713eac6 | 2014-06-02 23:10:03 | [diff] [blame] | 529 | if test "$do_inst_nacl" = "1"; then |
| 530 | echo "Installing symbolic links for NaCl." |
sbc | 6ab44c3 | 2015-02-13 23:19:17 | [diff] [blame] | 531 | # naclports needs to cross build python for i386, but libssl1.0.0:i386 |
| 532 | # only contains libcrypto.so.1.0.0 and not the symlink needed for |
| 533 | # linking (libcrypto.so). |
| 534 | create_library_symlink /lib/i386-linux-gnu/libcrypto.so.1.0.0 \ |
| 535 | /usr/lib/i386-linux-gnu/libcrypto.so |
| 536 | |
| 537 | create_library_symlink /lib/i386-linux-gnu/libssl.so.1.0.0 \ |
| 538 | /usr/lib/i386-linux-gnu/libssl.so |
[email protected] | 713eac6 | 2014-06-02 23:10:03 | [diff] [blame] | 539 | else |
| 540 | echo "Skipping symbolic links for NaCl." |
| 541 | fi |
thomasanderson | 5ef5c3d | 2016-12-08 01:59:19 | [diff] [blame] | 542 | |
| 543 | echo "Installing locales." |
| 544 | CHROMIUM_LOCALES="da_DK.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 zh_TW.UTF-8" |
| 545 | LOCALE_GEN=/etc/locale.gen |
| 546 | if [ -e ${LOCALE_GEN} ]; then |
| 547 | OLD_LOCALE_GEN="$(cat /etc/locale.gen)" |
| 548 | for CHROMIUM_LOCALE in ${CHROMIUM_LOCALES}; do |
| 549 | sudo sed -i "s/^# ${CHROMIUM_LOCALE}/${CHROMIUM_LOCALE}/" ${LOCALE_GEN} |
| 550 | done |
| 551 | # Regenerating locales can take a while, so only do it if we need to. |
| 552 | if (echo "${OLD_LOCALE_GEN}" | cmp -s ${LOCALE_GEN}); then |
| 553 | echo "Locales already up-to-date." |
| 554 | else |
| 555 | sudo locale-gen |
| 556 | fi |
| 557 | else |
| 558 | for CHROMIUM_LOCALE in ${CHROMIUM_LOCALES}; do |
| 559 | sudo locale-gen ${CHROMIUM_LOCALE} |
| 560 | done |
| 561 | fi |