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