[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" |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 15 | echo "--[no-]lib32: enable or disable installation of 32 bit libraries" |
[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;; |
| 49 | --no-lib32) do_inst_lib32=0;; |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 50 | --arm) do_inst_arm=1;; |
| 51 | --no-arm) do_inst_arm=0;; |
[email protected] | bd29cdd | 2013-02-22 03:49:20 | [diff] [blame] | 52 | --chromeos-fonts) do_inst_chromeos_fonts=1;; |
| 53 | --no-chromeos-fonts) do_inst_chromeos_fonts=0;; |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 54 | --nacl) do_inst_nacl=1;; |
| 55 | --no-nacl) do_inst_nacl=0;; |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 56 | --no-prompt) do_default=1 |
| 57 | do_quietly="-qq --assume-yes" |
| 58 | ;; |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 59 | --quick-check) do_quick_check=1;; |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 60 | --unsupported) do_unsupported=1;; |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 61 | *) usage;; |
| 62 | esac |
| 63 | shift |
| 64 | done |
| 65 | |
[email protected] | 2028814 | 2014-01-08 06:38:01 | [diff] [blame] | 66 | ubuntu_versions="12\.04|12\.10|13\.04|13\.10" |
| 67 | ubuntu_codenames="precise|quantal|raring|saucy" |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 68 | ubuntu_issue="Ubuntu ($ubuntu_versions|$ubuntu_codenames)" |
| 69 | # GCEL is an Ubuntu-derived VM image used on Google Compute Engine; /etc/issue |
| 70 | # doesn't contain a version number so just trust that the user knows what |
| 71 | # they're doing. |
| 72 | gcel_issue="^GCEL" |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 73 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 74 | if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 75 | if ! egrep -q "($ubuntu_issue|$gcel_issue)" /etc/issue; then |
[email protected] | 2028814 | 2014-01-08 06:38:01 | [diff] [blame] | 76 | echo "ERROR: Only Ubuntu 12.04 (precise) through 13.10 (saucy) are"\ |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 77 | "currently supported" >&2 |
| 78 | exit 1 |
| 79 | fi |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 80 | |
[email protected] | fe63a02 | 2013-01-15 22:11:47 | [diff] [blame] | 81 | if ! uname -m | egrep -q "i686|x86_64"; then |
| 82 | echo "Only x86 architectures are currently supported" >&2 |
| 83 | exit |
| 84 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 85 | fi |
| 86 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 87 | if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 88 | echo "Running as non-root user." |
| 89 | 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] | 90 | echo |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 91 | fi |
| 92 | |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 93 | # Packages needed for chromeos only |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 94 | chromeos_dev_list="libbluetooth-dev" |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 95 | |
[email protected] | b61f688 | 2013-11-14 20:41:41 | [diff] [blame] | 96 | # Packages needed for development |
[email protected] | 2022c6b | 2013-12-17 12:03:26 | [diff] [blame] | 97 | dev_list="apache2.2-bin bison curl dpkg-dev elfutils fakeroot flex g++ git-core |
| 98 | gperf language-pack-da language-pack-fr language-pack-he |
[email protected] | b7b53280 | 2013-11-23 01:37:49 | [diff] [blame] | 99 | language-pack-zh-hant libapache2-mod-php5 libasound2-dev libbrlapi-dev |
[email protected] | b61f688 | 2013-11-14 20:41:41 | [diff] [blame] | 100 | libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev |
| 101 | libdrm-dev libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev |
| 102 | libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev |
| 103 | libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev |
| 104 | libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev |
| 105 | libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev |
[email protected] | d8f5232 | 2013-10-29 05:50:38 | [diff] [blame] | 106 | mesa-common-dev openbox patch perl php5-cgi pkg-config python |
| 107 | python-cherrypy3 python-dev python-psutil rpm ruby subversion |
| 108 | ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho |
[email protected] | 2028814 | 2014-01-08 06:38:01 | [diff] [blame] | 109 | wdiff xfonts-mathml $chromeos_dev_list" |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 110 | |
[email protected] | f16aabf | 2012-08-15 21:00:14 | [diff] [blame] | 111 | # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built |
[email protected] | d93d68b1 | 2012-10-15 06:39:53 | [diff] [blame] | 112 | # NaCl binaries. These are always needed, regardless of whether or not we want |
[email protected] | f16aabf | 2012-08-15 21:00:14 | [diff] [blame] | 113 | # the full 32-bit "cross-compile" support (--lib32). |
[email protected] | 9161abe | 2013-10-31 15:15:49 | [diff] [blame] | 114 | if file /sbin/init | grep -q 'ELF 64-bit'; then |
[email protected] | d93d68b1 | 2012-10-15 06:39:53 | [diff] [blame] | 115 | dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6" |
[email protected] | f16aabf | 2012-08-15 21:00:14 | [diff] [blame] | 116 | fi |
| 117 | |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 118 | # Run-time libraries required by chromeos only |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 119 | chromeos_lib_list="libpulse0 libbz2-1.0" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 120 | |
| 121 | # Full list of required run-time libraries |
[email protected] | d8f5232 | 2013-10-29 05:50:38 | [diff] [blame] | 122 | lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1 |
[email protected] | 6ffd19f35 | 2012-10-23 02:00:41 | [diff] [blame] | 123 | libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 |
[email protected] | ca3a1d26 | 2012-10-30 22:33:20 | [diff] [blame] | 124 | libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0 |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 125 | libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6 |
[email protected] | 8190b88 | 2012-12-05 19:40:34 | [diff] [blame] | 126 | libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 |
| 127 | libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 |
| 128 | libxtst6 zlib1g $chromeos_lib_list" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 129 | |
| 130 | # Debugging symbols for all of the run-time libraries |
[email protected] | 6ffd19f35 | 2012-10-23 02:00:41 | [diff] [blame] | 131 | dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg |
| 132 | libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg |
| 133 | libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg |
| 134 | libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg |
| 135 | libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg |
[email protected] | 36219623 | 2013-11-10 00:43:40 | [diff] [blame] | 136 | libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg |
| 137 | libstdc++6-4.6-dbg" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 138 | |
[email protected] | 3f85dac3 | 2013-10-29 02:38:46 | [diff] [blame] | 139 | # arm cross toolchain packages needed to build chrome on armhf |
| 140 | arm_list="libc6-armhf-cross libc6-dev-armhf-cross libgcc1-armhf-cross |
| 141 | libgomp1-armhf-cross linux-libc-dev-armhf-cross |
| 142 | libgcc1-dbg-armhf-cross libgomp1-dbg-armhf-cross |
| 143 | binutils-arm-linux-gnueabihf cpp-arm-linux-gnueabihf |
| 144 | gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf |
| 145 | libmudflap0-dbg-armhf-cross" |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 146 | |
[email protected] | 3f85dac3 | 2013-10-29 02:38:46 | [diff] [blame] | 147 | # Old armel cross toolchain packages |
| 148 | armel_list="libc6-armel-cross libc6-dev-armel-cross libgcc1-armel-cross |
| 149 | libgomp1-armel-cross linux-libc-dev-armel-cross |
| 150 | libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross |
| 151 | binutils-arm-linux-gnueabi cpp-arm-linux-gnueabi |
| 152 | gcc-arm-linux-gnueabi g++-arm-linux-gnueabi |
| 153 | libmudflap0-dbg-armel-cross" |
| 154 | |
| 155 | # TODO(sbc): remove armel once the armhf transition is complete |
| 156 | arm_list="$arm_list $armel_list" |
[email protected] | 31a60553 | 2011-08-23 22:27:35 | [diff] [blame] | 157 | |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 158 | # Packages to build standalone NaCl and all its toolchains. |
[email protected] | 4ef4dcc | 2014-01-17 22:19:28 | [diff] [blame] | 159 | nacl_list="g++-mingw-w64-i686 libtinfo-dev:i386" |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 160 | |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 161 | # Some package names have changed over time |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 162 | if package_exists ttf-mscorefonts-installer; then |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 163 | dev_list="${dev_list} ttf-mscorefonts-installer" |
[email protected] | b11411c | 2012-03-21 22:09:41 | [diff] [blame] | 164 | else |
| 165 | dev_list="${dev_list} msttcorefonts" |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 166 | fi |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 167 | if package_exists libnspr4-dbg; then |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame] | 168 | dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg" |
| 169 | lib_list="${lib_list} libnspr4 libnss3" |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 170 | else |
| 171 | dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg" |
| 172 | lib_list="${lib_list} libnspr4-0d libnss3-1d" |
| 173 | fi |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 174 | if package_exists libjpeg-dev; then |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 175 | dev_list="${dev_list} libjpeg-dev" |
[email protected] | b11411c | 2012-03-21 22:09:41 | [diff] [blame] | 176 | else |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 177 | dev_list="${dev_list} libjpeg62-dev" |
[email protected] | b11411c | 2012-03-21 22:09:41 | [diff] [blame] | 178 | fi |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 179 | if package_exists libudev1; then |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 180 | dev_list="${dev_list} libudev1" |
| 181 | else |
| 182 | dev_list="${dev_list} libudev0" |
| 183 | fi |
[email protected] | 3ea4291 | 2013-09-06 06:23:57 | [diff] [blame] | 184 | if package_exists libbrlapi0.6; then |
| 185 | dev_list="${dev_list} libbrlapi0.6" |
| 186 | else |
| 187 | dev_list="${dev_list} libbrlapi0.5" |
| 188 | fi |
[email protected] | 9e89596 | 2013-05-21 08:26:42 | [diff] [blame] | 189 | |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 190 | |
[email protected] | dc09977 | 2013-09-30 22:06:58 | [diff] [blame] | 191 | # Some packages are only needed if the distribution actually supports |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 192 | # installing them. |
[email protected] | 4fc0071 | 2013-05-29 23:11:20 | [diff] [blame] | 193 | if package_exists appmenu-gtk; then |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 194 | lib_list="$lib_list appmenu-gtk" |
[email protected] | 4da8fad | 2011-04-11 18:42:42 | [diff] [blame] | 195 | fi |
| 196 | |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 197 | # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is |
| 198 | # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has |
| 199 | # been provided to yes_no(), the function also accepts RETURN as a user input. |
| 200 | # The parameter specifies the exit code that should be returned in that case. |
| 201 | # The function will echo the user's selection followed by a newline character. |
| 202 | # Users can abort the function by pressing CTRL-C. This will call "exit 1". |
| 203 | yes_no() { |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 204 | if [ 0 -ne "${do_default-0}" ] ; then |
[email protected] | dc09977 | 2013-09-30 22:06:58 | [diff] [blame] | 205 | [ $1 -eq 0 ] && echo "Y" || echo "N" |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 206 | return $1 |
| 207 | fi |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 208 | local c |
| 209 | while :; do |
| 210 | c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT |
| 211 | stty -echo iuclc -icanon 2>/dev/null |
| 212 | dd count=1 bs=1 2>/dev/null | od -An -tx1)" |
| 213 | case "$c" in |
| 214 | " 0a") if [ -n "$1" ]; then |
| 215 | [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 216 | return $1 |
| 217 | fi |
| 218 | ;; |
| 219 | " 79") echo "Y" |
| 220 | return 0 |
| 221 | ;; |
| 222 | " 6e") echo "N" |
| 223 | return 1 |
| 224 | ;; |
| 225 | "") echo "Aborted" >&2 |
| 226 | exit 1 |
| 227 | ;; |
| 228 | *) # The user pressed an unrecognized key. As we are not echoing |
| 229 | # any incorrect user input, alert the user by ringing the bell. |
| 230 | (tput bel) 2>/dev/null |
| 231 | ;; |
| 232 | esac |
| 233 | done |
| 234 | } |
| 235 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 236 | if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0} |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 237 | then |
| 238 | echo "This script installs all tools and libraries needed to build Chromium." |
| 239 | echo "" |
| 240 | echo "For most of the libraries, it can also install debugging symbols, which" |
| 241 | echo "will allow you to debug code in the system libraries. Most developers" |
| 242 | echo "won't need these symbols." |
| 243 | echo -n "Do you want me to install them for you (y/N) " |
| 244 | if yes_no 1; then |
| 245 | do_inst_syms=1 |
| 246 | fi |
| 247 | fi |
| 248 | if test "$do_inst_syms" = "1"; then |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 249 | echo "Including debugging symbols." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 250 | else |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 251 | echo "Skipping debugging symbols." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 252 | dbg_list= |
| 253 | fi |
| 254 | |
[email protected] | 9f28a9cf | 2012-12-17 23:31:40 | [diff] [blame] | 255 | # When cross building for arm on 64-bit systems the host binaries |
| 256 | # that are part of v8 need to be compiled with -m32 which means |
| 257 | # that basic multilib support is needed. |
[email protected] | 9161abe | 2013-10-31 15:15:49 | [diff] [blame] | 258 | if file /sbin/init | grep -q 'ELF 64-bit'; then |
[email protected] | 9f28a9cf | 2012-12-17 23:31:40 | [diff] [blame] | 259 | arm_list="$arm_list g++-multilib" |
| 260 | fi |
| 261 | |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 262 | if test "$do_inst_arm" = "1" ; then |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 263 | echo "Including ARM cross toolchain." |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 264 | else |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 265 | echo "Skipping ARM cross toolchain." |
[email protected] | f2826b6a | 2012-11-15 01:06:26 | [diff] [blame] | 266 | arm_list= |
| 267 | fi |
| 268 | |
[email protected] | 56541636 | 2014-01-16 21:26:47 | [diff] [blame] | 269 | if test "$do_inst_nacl" = "1"; then |
| 270 | echo "Including standalone NaCl dependencies." |
| 271 | else |
| 272 | echo "Skipping standalone NaCl dependencies." |
| 273 | nacl_list= |
| 274 | fi |
| 275 | |
| 276 | packages="$( |
| 277 | echo "${dev_list} ${lib_list} ${dbg_list} ${arm_list} ${nacl_list}" | |
| 278 | tr " " "\n" | sort -u | tr "\n" " " |
| 279 | )" |
[email protected] | ba48c4ca | 2013-10-25 16:11:46 | [diff] [blame] | 280 | |
| 281 | if [ 1 -eq "${do_quick_check-0}" ] ; then |
| 282 | failed_check="$(dpkg-query -W -f '${PackageSpec}:${Status}\n' \ |
| 283 | ${packages} 2>&1 | grep -v "ok installed" || :)" |
| 284 | if [ -n "${failed_check}" ]; then |
| 285 | echo |
| 286 | nomatch="$(echo "${failed_check}" | \ |
| 287 | sed -e "s/^No packages found matching \(.*\).$/\1/;t;d")" |
| 288 | missing="$(echo "${failed_check}" | \ |
| 289 | sed -e "/^No packages found matching/d;s/^\(.*\):.*$/\1/")" |
| 290 | if [ "$nomatch" ]; then |
| 291 | # Distinguish between packages that actually aren't available to the |
| 292 | # system (i.e. not in any repo) and packages that just aren't known to |
| 293 | # dpkg (i.e. managed by apt). |
| 294 | unknown="" |
| 295 | for p in ${nomatch}; do |
| 296 | if apt-cache show ${p} > /dev/null 2>&1; then |
| 297 | missing="${p}\n${missing}" |
| 298 | else |
| 299 | unknown="${p}\n${unknown}" |
| 300 | fi |
| 301 | done |
| 302 | if [ -n "${unknown}" ]; then |
| 303 | echo "WARNING: The following packages are unknown to your system" |
| 304 | echo "(maybe missing a repo or need to 'sudo apt-get update'):" |
| 305 | echo -e "${unknown}" | sed -e "s/^/ /" |
| 306 | fi |
| 307 | fi |
| 308 | if [ -n "${missing}" ]; then |
| 309 | echo "WARNING: The following packages are not installed:" |
| 310 | echo -e "${missing}" | sed -e "s/^/ /" |
| 311 | fi |
| 312 | exit 1 |
| 313 | fi |
| 314 | exit 0 |
| 315 | fi |
| 316 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 317 | sudo apt-get update |
| 318 | |
| 319 | # We initially run "apt-get" with the --reinstall option and parse its output. |
| 320 | # This way, we can find all the packages that need to be newly installed |
| 321 | # without accidentally promoting any packages from "auto" to "manual". |
| 322 | # We then re-run "apt-get" with just the list of missing packages. |
| 323 | echo "Finding missing packages..." |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 324 | # Intentionally leaving $packages unquoted so it's more readable. |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 325 | echo "Packages required: " $packages |
| 326 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 327 | new_list_cmd="sudo apt-get install --reinstall $(echo $packages)" |
[email protected] | c3d8b15 | 2013-05-10 10:10:03 | [diff] [blame] | 328 | if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 329 | # We probably never hit this following line. |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 330 | echo "No missing packages, and the packages are up-to-date." |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 331 | elif [ $? -eq 1 ]; then |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 332 | # We expect apt-get to have exit status of 1. |
[email protected] | 757c296 | 2012-03-15 19:05:18 | [diff] [blame] | 333 | # This indicates that we cancelled the install with "yes n|". |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 334 | new_list=$(echo "$new_list" | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 335 | 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] | 336 | new_list=$(echo "$new_list" | sed 's/ *$//') |
| 337 | if [ -z "$new_list" ] ; then |
| 338 | echo "No missing packages, and the packages are up-to-date." |
| 339 | else |
| 340 | echo "Installing missing packages: $new_list." |
[email protected] | e2544ed4 | 2012-04-23 04:48:31 | [diff] [blame] | 341 | sudo apt-get install ${do_quietly-} ${new_list} |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 342 | fi |
| 343 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 344 | else |
| 345 | # 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] | 346 | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 347 | # I am intentionally leaving out the '"'s around new_list_cmd, |
| 348 | # as this makes it easier to cut and paste the output |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 349 | echo "The following command failed: " ${new_list_cmd} |
| 350 | echo |
| 351 | echo "It produces the following output:" |
| 352 | yes n | $new_list_cmd || true |
| 353 | echo |
| 354 | echo "You will have to install the above packages yourself." |
| 355 | echo |
| 356 | exit 100 |
| 357 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 358 | |
[email protected] | d96cc347 | 2013-09-19 00:53:30 | [diff] [blame] | 359 | # Install the Chrome OS default fonts. This must go after running |
| 360 | # apt-get, since install-chromeos-fonts depends on curl. |
| 361 | if test "$do_inst_chromeos_fonts" != "0"; then |
| 362 | echo |
| 363 | echo "Installing Chrome OS fonts." |
| 364 | dir=`echo $0 | sed -r -e 's/\/[^/]+$//'` |
| 365 | if ! sudo $dir/linux/install-chromeos-fonts.py; then |
| 366 | echo "ERROR: The installation of the Chrome OS default fonts failed." |
| 367 | if [ `stat -f -c %T $dir` == "nfs" ]; then |
| 368 | echo "The reason is that your repo is installed on a remote file system." |
| 369 | else |
| 370 | echo "This is expected if your repo is installed on a remote file system." |
| 371 | fi |
| 372 | echo "It is recommended to install your repo on a local file system." |
| 373 | echo "You can skip the installation of the Chrome OS default founts with" |
| 374 | echo "the command line option: --no-chromeos-fonts." |
| 375 | exit 1 |
| 376 | fi |
| 377 | else |
| 378 | echo "Skipping installation of Chrome OS fonts." |
| 379 | fi |
| 380 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 381 | # Install 32bit backwards compatibility support for 64bit systems |
[email protected] | 9161abe | 2013-10-31 15:15:49 | [diff] [blame] | 382 | if file /sbin/init | grep -q 'ELF 64-bit'; then |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 383 | if test "$do_inst_lib32" != "1" |
| 384 | then |
[email protected] | 4a242bea | 2012-11-07 19:31:52 | [diff] [blame] | 385 | echo "NOTE: If you were expecting the option to install 32bit libs," |
| 386 | echo "please run with the --lib32 flag." |
| 387 | echo |
| 388 | echo "Installation complete." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 389 | exit 0 |
[email protected] | f3b3ba7b | 2013-04-24 00:11:27 | [diff] [blame] | 390 | else |
| 391 | # This conditional statement has been added to deprecate and eventually |
| 392 | # remove support for 32bit libraries on 64bit systems. But for the time |
| 393 | # being, we still have to support a few legacy systems (e.g. bots), where |
| 394 | # this feature is needed. |
| 395 | # We only even give the user the option to install these libraries, if |
| 396 | # they explicitly requested doing so by setting the --lib32 command line |
| 397 | # flag. |
| 398 | # And even then, we interactively ask them one more time whether they are |
| 399 | # absolutely sure. |
| 400 | # In order for that to work, we must reset the ${do_inst_lib32} variable. |
| 401 | # There are other ways to achieve the same goal. But resetting the |
| 402 | # variable is the best way to document the intended behavior -- and to |
| 403 | # allow us to gradually deprecate and then remove the obsolete code. |
[email protected] | dc09977 | 2013-09-30 22:06:58 | [diff] [blame] | 404 | if test "${do_default-0}" -ne 1; then |
| 405 | do_inst_lib32= |
| 406 | fi |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 407 | fi |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 408 | |
[email protected] | 4a242bea | 2012-11-07 19:31:52 | [diff] [blame] | 409 | echo "WARNING" |
[email protected] | e76a363 | 2012-03-15 20:56:27 | [diff] [blame] | 410 | echo |
[email protected] | 4a242bea | 2012-11-07 19:31:52 | [diff] [blame] | 411 | echo "We no longer recommend that you use this script to install" |
| 412 | echo "32bit libraries on a 64bit system. Instead, consider using the" |
| 413 | echo "install-chroot.sh script to help you set up a 32bit environment" |
| 414 | echo "for building and testing 32bit versions of Chrome." |
| 415 | echo |
| 416 | echo "The code for installing 32bit libraries on a 64bit system is" |
| 417 | echo "unmaintained and might not work with modern versions of Ubuntu" |
| 418 | echo "or Debian." |
[email protected] | dc09977 | 2013-09-30 22:06:58 | [diff] [blame] | 419 | if test "$do_inst_lib32" != "" ; then |
| 420 | echo |
| 421 | echo -n "Are you sure you want to proceed (y/N) " |
| 422 | if yes_no 1; then |
| 423 | do_inst_lib32=1 |
| 424 | fi |
[email protected] | 4a242bea | 2012-11-07 19:31:52 | [diff] [blame] | 425 | fi |
| 426 | if test "$do_inst_lib32" != "1" |
[email protected] | 796c352 | 2012-11-07 22:56:35 | [diff] [blame] | 427 | then |
[email protected] | 4a242bea | 2012-11-07 19:31:52 | [diff] [blame] | 428 | exit 0 |
| 429 | fi |
[email protected] | e76a363 | 2012-03-15 20:56:27 | [diff] [blame] | 430 | |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 431 | # Standard 32bit compatibility libraries |
| 432 | echo "First, installing the limited existing 32-bit support..." |
[email protected] | 7cf14b37 | 2011-12-08 18:32:52 | [diff] [blame] | 433 | cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1 |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 434 | lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib" |
[email protected] | 7cf14b37 | 2011-12-08 18:32:52 | [diff] [blame] | 435 | if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then |
| 436 | cmp_list="${cmp_list} lib32readline-gplv2-dev" |
| 437 | else |
| 438 | cmp_list="${cmp_list} lib32readline5-dev" |
| 439 | fi |
[email protected] | 221569d3 | 2012-05-20 04:55:48 | [diff] [blame] | 440 | sudo apt-get install ${do_quietly-} $cmp_list |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 441 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 442 | tmp=/tmp/install-32bit.$$ |
| 443 | trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT |
| 444 | mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial" |
| 445 | touch "${tmp}/status" |
| 446 | |
| 447 | [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/" |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 448 | cat >>"${tmp}/apt/apt.conf" <<EOF |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 449 | Apt::Architecture "i386"; |
| 450 | Dir::Cache "${tmp}/cache"; |
| 451 | Dir::Cache::Archives "${tmp}/"; |
| 452 | Dir::State::Lists "${tmp}/apt/lists/"; |
| 453 | Dir::State::status "${tmp}/status"; |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 454 | EOF |
[email protected] | 1bf2ac97 | 2009-06-30 23:57:48 | [diff] [blame] | 455 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 456 | # Download 32bit packages |
| 457 | echo "Computing list of available 32bit packages..." |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 458 | sudo apt-get -c="${tmp}/apt/apt.conf" update |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 459 | |
| 460 | echo "Downloading available 32bit packages..." |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 461 | sudo apt-get -c="${tmp}/apt/apt.conf" \ |
| 462 | --yes --download-only --force-yes --reinstall install \ |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 463 | ${lib_list} ${dbg_list} |
| 464 | |
| 465 | # Open packages, remove everything that is not a library, move the |
| 466 | # library to a lib32 directory and package everything as a *.deb file. |
| 467 | echo "Repackaging and installing 32bit packages for use on 64bit systems..." |
| 468 | for i in ${lib_list} ${dbg_list}; do |
| 469 | orig="$(echo "${tmp}/${i}"_*_i386.deb)" |
| 470 | compat="$(echo "${orig}" | |
| 471 | sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')" |
| 472 | rm -rf "${tmp}/staging" |
| 473 | msg="$(fakeroot -u sh -exc ' |
| 474 | # Unpack 32bit Debian archive |
| 475 | umask 022 |
| 476 | mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN" |
| 477 | cd "'"${tmp}"'/staging" |
| 478 | ar x "'${orig}'" |
[email protected] | 55d1d753 | 2013-03-19 03:06:45 | [diff] [blame] | 479 | tar Cfx dpkg data.tar* |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 480 | tar zCfx dpkg/DEBIAN control.tar.gz |
| 481 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 482 | # Create a posix extended regular expression fragment that will |
| 483 | # recognize the includes which have changed. Should be rare, |
| 484 | # will almost always be empty. |
| 485 | includes=`sed -n -e "s/^[0-9a-z]* //g" \ |
| 486 | -e "\,usr/include/,p" dpkg/DEBIAN/md5sums | |
| 487 | xargs -n 1 -I FILE /bin/sh -c \ |
| 488 | "cmp -s dpkg/FILE /FILE || echo FILE" | |
| 489 | tr "\n" "|" | |
| 490 | sed -e "s,|$,,"` |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 491 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 492 | # If empty, set it to not match anything. |
| 493 | test -z "$includes" && includes="^//" |
| 494 | |
| 495 | # Turn the conflicts into an extended RE for removal from the |
| 496 | # Provides line. |
| 497 | conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \ |
| 498 | dpkg/DEBIAN/control` |
| 499 | |
| 500 | # Rename package, change architecture, remove conflicts and dependencies |
| 501 | sed -r -i \ |
| 502 | -e "/Package/s/$/-ia32/" \ |
| 503 | -e "/Architecture/s/:.*$/: amd64/" \ |
| 504 | -e "/Depends/s/:.*/: ia32-libs/" \ |
| 505 | -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \ |
| 506 | -e "/Recommends/d" \ |
| 507 | -e "/Conflicts/d" \ |
| 508 | dpkg/DEBIAN/control |
| 509 | |
| 510 | # Only keep files that live in "lib" directories or the includes |
| 511 | # that have changed. |
| 512 | sed -r -i \ |
| 513 | -e "/\/lib64\//d" -e "/\/.?bin\//d" \ |
| 514 | -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \ |
| 515 | -e "s, lib/, lib32/,g" \ |
| 516 | -e "s,/lib/,/lib32/,g" \ |
| 517 | -e "t;d" \ |
| 518 | -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \ |
| 519 | dpkg/DEBIAN/md5sums |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 520 | |
| 521 | # Re-run ldconfig after installation/removal |
| 522 | { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \ |
| 523 | >dpkg/DEBIAN/postinst |
| 524 | { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \ |
| 525 | >dpkg/DEBIAN/postrm |
| 526 | chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm |
| 527 | |
| 528 | # Remove any other control files |
| 529 | find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \ |
| 530 | -name postinst -o -name postrm ")" -o -print | |
| 531 | xargs -r rm -rf |
| 532 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 533 | # Remove any files/dirs that live outside of "lib" directories, |
| 534 | # or are not in our list of changed includes. |
| 535 | find dpkg -mindepth 1 -regextype posix-extended \ |
| 536 | "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \ |
| 537 | -prune -o -print | tac | |
| 538 | xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : " |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 539 | find dpkg -name lib64 -o -name bin -o -name "?bin" | |
| 540 | tac | xargs -r rm -rf |
| 541 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 542 | # Remove any symbolic links that were broken by the above steps. |
| 543 | find -L dpkg -type l -print | tac | xargs -r rm -rf |
| 544 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 545 | # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32 |
| 546 | # That is where gdb looks for them. |
| 547 | find dpkg -type d -o -path "*/lib/*" -print | |
| 548 | xargs -r -n 1 sh -c " |
| 549 | i=\$(echo \"\${0}\" | |
| 550 | sed -e s,/lib/,/lib32/,g \ |
| 551 | -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,); |
| 552 | mkdir -p \"\${i%/*}\"; |
| 553 | mv \"\${0}\" \"\${i}\"" |
| 554 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 555 | # Rename include to include32. |
| 556 | [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32" |
| 557 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 558 | # Prune any empty directories |
| 559 | find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || : |
| 560 | |
| 561 | # Create our own Debian package |
| 562 | cd .. |
| 563 | dpkg --build staging/dpkg .' 2>&1)" |
| 564 | compat="$(eval echo $(echo "${compat}" | |
| 565 | sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))" |
| 566 | [ -r "${compat}" ] || { |
| 567 | echo "${msg}" >&2 |
| 568 | echo "Failed to build new Debian archive!" >&2 |
| 569 | exit 1 |
| 570 | } |
| 571 | |
| 572 | msg="$(sudo dpkg -i "${compat}" 2>&1)" && { |
| 573 | echo "Installed ${compat##*/}" |
| 574 | } || { |
| 575 | # echo "${msg}" >&2 |
| 576 | echo "Skipped ${compat##*/}" |
| 577 | } |
| 578 | done |
| 579 | |
| 580 | # Add symbolic links for developing 32bit code |
| 581 | echo "Adding missing symbolic links, enabling 32bit code development..." |
| 582 | for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* | |
| 583 | sed -e 's/[.]so[.][0-9].*/.so/' | |
| 584 | sort -u); do |
| 585 | [ "x${i##*/}" = "xld-linux.so" ] && continue |
| 586 | [ -r "$i" ] && continue |
| 587 | j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | |
| 588 | sort -n | tail -n 1)" |
| 589 | [ -r "$i.$j" ] || continue |
| 590 | sudo ln -s "${i##*/}.$j" "$i" |
| 591 | done |
| 592 | fi |