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