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