[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
[email protected] | 4da8fad | 2011-04-11 18:42:42 | [diff] [blame] | 3 | # Copyright (c) 2011 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" |
| 15 | echo "--[no-]gold: enable or disable installation of gold linker" |
| 16 | echo "--[no-]lib32: enable or disable installation of 32 bit libraries" |
| 17 | echo "Script will prompt interactively if options not given." |
| 18 | exit 1 |
| 19 | } |
| 20 | |
| 21 | while test "$1" != "" |
| 22 | do |
| 23 | case "$1" in |
| 24 | --syms) do_inst_syms=1;; |
| 25 | --no-syms) do_inst_syms=0;; |
| 26 | --gold) do_inst_gold=1;; |
| 27 | --no-gold) do_inst_gold=0;; |
| 28 | --lib32) do_inst_lib32=1;; |
| 29 | --no-lib32) do_inst_lib32=0;; |
| 30 | *) usage;; |
| 31 | esac |
| 32 | shift |
| 33 | done |
| 34 | |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 35 | install_gold() { |
| 36 | # Gold is optional; it's a faster replacement for ld, |
| 37 | # and makes life on 2GB machines much more pleasant. |
| 38 | |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 39 | # First make sure root can access this directory, as that's tripped |
| 40 | # up some folks. |
[email protected] | 1bf2ac97 | 2009-06-30 23:57:48 | [diff] [blame] | 41 | if sudo touch xyz.$$ |
| 42 | then |
| 43 | sudo rm xyz.$$ |
| 44 | else |
| 45 | echo root cannot write to the current directory, not installing gold |
| 46 | return |
| 47 | fi |
| 48 | |
[email protected] | b4ce3c22d | 2011-02-23 21:30:17 | [diff] [blame] | 49 | BINUTILS=binutils-2.21 |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 50 | BINUTILS_URL=http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2 |
[email protected] | b4ce3c22d | 2011-02-23 21:30:17 | [diff] [blame] | 51 | BINUTILS_SHA1=ef93235588eb443e4c4a77f229a8d131bccaecc6 |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 52 | |
| 53 | test -f $BINUTILS.tar.bz2 || wget $BINUTILS_URL |
[email protected] | d42915d4 | 2009-11-18 10:36:46 | [diff] [blame] | 54 | if test "`sha1sum $BINUTILS.tar.bz2|cut -d' ' -f1`" != "$BINUTILS_SHA1" |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 55 | then |
| 56 | echo Bad sha1sum for $BINUTILS.tar.bz2 |
| 57 | exit 1 |
| 58 | fi |
[email protected] | 0b53eb0 | 2009-09-23 22:22:47 | [diff] [blame] | 59 | |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 60 | tar -xjvf $BINUTILS.tar.bz2 |
| 61 | cd $BINUTILS |
[email protected] | b4ce3c22d | 2011-02-23 21:30:17 | [diff] [blame] | 62 | patch -p1 <<EOF |
| 63 | diff -u -r1.103 -r1.103.2.1 |
| 64 | --- src/gold/object.h 2010/09/08 23:54:51 1.103 |
| 65 | +++ src/gold/object.h 2011/02/10 01:15:28 1.103.2.1 |
| 66 | @@ -1,6 +1,6 @@ |
| 67 | // object.h -- support for an object file for linking in gold -*- C++ -*- |
| 68 | |
| 69 | -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
| 70 | +// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
| 71 | // Written by Ian Lance Taylor <iant@google.com>. |
| 72 | |
| 73 | // This file is part of gold. |
| 74 | @@ -2165,15 +2165,6 @@ |
| 75 | Output_symtab_xindex*, |
| 76 | Output_symtab_xindex*); |
| 77 | |
| 78 | - // Clear the local symbol information. |
| 79 | - void |
| 80 | - clear_local_symbols() |
| 81 | - { |
| 82 | - this->local_values_.clear(); |
| 83 | - this->local_got_offsets_.clear(); |
| 84 | - this->local_plt_offsets_.clear(); |
| 85 | - } |
| 86 | - |
| 87 | // Record a mapping from discarded section SHNDX to the corresponding |
| 88 | // kept section. |
| 89 | void |
| 90 | diff -u -r1.60 -r1.60.2.1 |
| 91 | --- src/gold/reloc.cc 2010/10/14 22:10:22 1.60 |
| 92 | +++ src/gold/reloc.cc 2011/02/10 01:15:28 1.60.2.1 |
| 93 | @@ -1,6 +1,6 @@ |
| 94 | // reloc.cc -- relocate input files for gold. |
| 95 | |
| 96 | -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
| 97 | +// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
| 98 | // Written by Ian Lance Taylor <iant@google.com>. |
| 99 | |
| 100 | // This file is part of gold. |
| 101 | @@ -685,9 +685,6 @@ |
| 102 | // Write out the local symbols. |
| 103 | this->write_local_symbols(of, layout->sympool(), layout->dynpool(), |
| 104 | layout->symtab_xindex(), layout->dynsym_xindex()); |
| 105 | - |
| 106 | - // We should no longer need the local symbol values. |
| 107 | - this->clear_local_symbols(); |
| 108 | } |
| 109 | |
| 110 | // Sort a Read_multiple vector by file offset. |
| 111 | EOF |
| 112 | ./configure --prefix=/usr/local/gold --enable-gold --enable-threads |
[email protected] | 80e0c630 | 2011-02-11 22:11:31 | [diff] [blame] | 113 | make maybe-all-binutils maybe-all-gold -j4 |
| 114 | if sudo make maybe-install-binutils maybe-install-gold |
[email protected] | 1bf2ac97 | 2009-06-30 23:57:48 | [diff] [blame] | 115 | then |
| 116 | # Still need to figure out graceful way of pointing gyp to use |
| 117 | # /usr/local/gold/bin/ld without requiring him to set environment |
| 118 | # variables. That will go into bootstrap-linux.sh when it's ready. |
| 119 | echo "Installing gold as /usr/bin/ld." |
| 120 | echo "To uninstall, do 'cd /usr/bin; sudo rm ld; sudo mv ld.orig ld'" |
[email protected] | 803c45c5 | 2009-11-18 10:58:00 | [diff] [blame] | 121 | test -f /usr/bin/ld && test ! -f /usr/bin/ld.orig && \ |
| 122 | sudo mv /usr/bin/ld /usr/bin/ld.orig |
[email protected] | b2e24bd | 2009-09-10 17:45:39 | [diff] [blame] | 123 | sudo strip /usr/local/gold/bin/ld |
[email protected] | 1bf2ac97 | 2009-06-30 23:57:48 | [diff] [blame] | 124 | sudo ln -fs /usr/local/gold/bin/ld /usr/bin/ld.gold |
| 125 | sudo ln -fs /usr/bin/ld.gold /usr/bin/ld |
| 126 | else |
| 127 | echo "make install failed, not installing gold" |
| 128 | fi |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 129 | } |
| 130 | |
[email protected] | a51551d | 2010-07-15 22:59:48 | [diff] [blame] | 131 | if ! egrep -q \ |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 132 | 'Ubuntu (10\.04|10\.10|11\.04|lucid|maverick|natty)' \ |
[email protected] | a51551d | 2010-07-15 22:59:48 | [diff] [blame] | 133 | /etc/issue; then |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 134 | echo "Only Ubuntu 10.04 (lucid) through 11.04 (natty) are currently" \ |
[email protected] | a51551d | 2010-07-15 22:59:48 | [diff] [blame] | 135 | "supported" >&2 |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 136 | exit 1 |
| 137 | fi |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 138 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 139 | if ! uname -m | egrep -q "i686|x86_64"; then |
| 140 | echo "Only x86 architectures are currently supported" >&2 |
| 141 | exit |
| 142 | fi |
| 143 | |
| 144 | if [ "x$(id -u)" != x0 ]; then |
| 145 | echo "Running as non-root user." |
| 146 | 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] | 147 | echo |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 148 | fi |
| 149 | |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 150 | # Packages needed for chromeos only |
| 151 | chromeos_dev_list="libpulse-dev" |
| 152 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 153 | # Packages need for development |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 154 | dev_list="apache2.2-bin bison fakeroot flex g++ gperf libapache2-mod-php5 |
| 155 | libasound2-dev libbz2-dev libcairo2-dev |
| 156 | libdbus-glib-1-dev libgconf2-dev |
[email protected] | 4da8fad | 2011-04-11 18:42:42 | [diff] [blame] | 157 | libgl1-mesa-dev libglu1-mesa-dev libglib2.0-dev libgnome-keyring-dev |
| 158 | libgtk2.0-dev libjpeg62-dev libnspr4-dev libnss3-dev libpam0g-dev |
| 159 | libsctp-dev libsqlite3-dev libxslt1-dev libxss-dev libxtst-dev |
| 160 | mesa-common-dev msttcorefonts patch perl php5-cgi pkg-config python |
| 161 | python-dev rpm subversion ttf-dejavu-core ttf-kochi-gothic |
[email protected] | ccd3f34 | 2011-05-03 18:21:48 | [diff] [blame] | 162 | ttf-kochi-mincho wdiff libcurl4-gnutls-dev ttf-indic-fonts |
| 163 | ttf-thai-tlwg |
[email protected] | 9dc4bed | 2010-11-04 19:23:30 | [diff] [blame] | 164 | $chromeos_dev_list" |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 165 | |
| 166 | # Run-time libraries required by chromeos only |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 167 | chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 168 | |
| 169 | # Full list of required run-time libraries |
[email protected] | e3212ba | 2010-03-11 15:27:24 | [diff] [blame] | 170 | lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libdbus-glib-1-2 libexpat1 |
[email protected] | ce940f0 | 2010-06-07 22:34:40 | [diff] [blame] | 171 | libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 libgtk2.0-0 |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 172 | libpam0g libpango1.0-0 libpcre3 libpixman-1-0 |
[email protected] | fd11101b | 2011-02-16 04:46:46 | [diff] [blame] | 173 | libpng12-0 libstdc++6 libsqlite3-0 libx11-6 libxau6 libxcb1 |
| 174 | libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 |
| 175 | libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g |
[email protected] | 9dc4bed | 2010-11-04 19:23:30 | [diff] [blame] | 176 | $chromeos_lib_list" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 177 | |
| 178 | # Debugging symbols for all of the run-time libraries |
[email protected] | 8442146 | 2010-03-11 17:20:25 | [diff] [blame] | 179 | dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 180 | libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg |
| 181 | libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg |
[email protected] | b944e32 | 2011-05-18 20:01:35 | [diff] [blame] | 182 | libsqlite3-0-dbg |
[email protected] | e759c4b | 2010-03-10 19:04:58 | [diff] [blame] | 183 | libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 184 | libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg |
| 185 | libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg |
[email protected] | 9dc4bed | 2010-11-04 19:23:30 | [diff] [blame] | 186 | libxrender1-dbg libxtst6-dbg zlib1g-dbg" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 187 | |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 188 | # Some NSS packages were renamed in Natty. |
| 189 | if egrep -q 'Ubuntu (10\.04|10\.10)' /etc/issue; then |
| 190 | dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg" |
| 191 | lib_list="${lib_list} libnspr4-0d libnss3-1d" |
[email protected] | cd03d82 | 2010-05-13 21:11:20 | [diff] [blame] | 192 | else |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame^] | 193 | dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg" |
| 194 | lib_list="${lib_list} libnspr4 libnss3" |
[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() { |
| 204 | local c |
| 205 | while :; do |
| 206 | c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT |
| 207 | stty -echo iuclc -icanon 2>/dev/null |
| 208 | dd count=1 bs=1 2>/dev/null | od -An -tx1)" |
| 209 | case "$c" in |
| 210 | " 0a") if [ -n "$1" ]; then |
| 211 | [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 212 | return $1 |
| 213 | fi |
| 214 | ;; |
| 215 | " 79") echo "Y" |
| 216 | return 0 |
| 217 | ;; |
| 218 | " 6e") echo "N" |
| 219 | return 1 |
| 220 | ;; |
| 221 | "") echo "Aborted" >&2 |
| 222 | exit 1 |
| 223 | ;; |
| 224 | *) # The user pressed an unrecognized key. As we are not echoing |
| 225 | # any incorrect user input, alert the user by ringing the bell. |
| 226 | (tput bel) 2>/dev/null |
| 227 | ;; |
| 228 | esac |
| 229 | done |
| 230 | } |
| 231 | |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 232 | if test "$do_inst_syms" = "" |
| 233 | then |
| 234 | echo "This script installs all tools and libraries needed to build Chromium." |
| 235 | echo "" |
| 236 | echo "For most of the libraries, it can also install debugging symbols, which" |
| 237 | echo "will allow you to debug code in the system libraries. Most developers" |
| 238 | echo "won't need these symbols." |
| 239 | echo -n "Do you want me to install them for you (y/N) " |
| 240 | if yes_no 1; then |
| 241 | do_inst_syms=1 |
| 242 | fi |
| 243 | fi |
| 244 | if test "$do_inst_syms" = "1"; then |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 245 | echo "Installing debugging symbols." |
| 246 | else |
| 247 | echo "Skipping installation of debugging symbols." |
| 248 | dbg_list= |
| 249 | fi |
| 250 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 251 | sudo apt-get update |
| 252 | |
| 253 | # We initially run "apt-get" with the --reinstall option and parse its output. |
| 254 | # This way, we can find all the packages that need to be newly installed |
| 255 | # without accidentally promoting any packages from "auto" to "manual". |
| 256 | # We then re-run "apt-get" with just the list of missing packages. |
| 257 | echo "Finding missing packages..." |
[email protected] | 12de04f | 2009-08-11 17:30:48 | [diff] [blame] | 258 | packages="${dev_list} ${lib_list} ${dbg_list}" |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 259 | # Intentially leaving $packages unquoted so it's more readable. |
| 260 | echo "Packages required: " $packages |
| 261 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 262 | new_list_cmd="sudo apt-get install --reinstall $(echo $packages)" |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 263 | if new_list="$(yes n | LANG=C $new_list_cmd)"; then |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 264 | # We probably never hit this following line. |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 265 | echo "No missing packages, and the packages are up-to-date." |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 266 | elif [ $? -eq 1 ]; then |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 267 | # We expect apt-get to have exit status of 1. |
| 268 | # This indicates that we canceled the install with "yes n|". |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 269 | new_list=$(echo "$new_list" | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 270 | 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] | 271 | new_list=$(echo "$new_list" | sed 's/ *$//') |
| 272 | if [ -z "$new_list" ] ; then |
| 273 | echo "No missing packages, and the packages are up-to-date." |
| 274 | else |
| 275 | echo "Installing missing packages: $new_list." |
| 276 | sudo apt-get install ${new_list} |
| 277 | fi |
| 278 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 279 | else |
| 280 | # 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] | 281 | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 282 | # I am intentionally leaving out the '"'s around new_list_cmd, |
| 283 | # as this makes it easier to cut and paste the output |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 284 | echo "The following command failed: " ${new_list_cmd} |
| 285 | echo |
| 286 | echo "It produces the following output:" |
| 287 | yes n | $new_list_cmd || true |
| 288 | echo |
| 289 | echo "You will have to install the above packages yourself." |
| 290 | echo |
| 291 | exit 100 |
| 292 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 293 | |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 294 | # Some operating systems already ship gold (on recent Debian and |
| 295 | # Ubuntu you can do "apt-get install binutils-gold" to get it), but |
[email protected] | ae0637b | 2010-06-30 17:07:56 | [diff] [blame] | 296 | # older releases didn't. Additionally, gold 2.20 (included in Ubuntu |
[email protected] | b4ce3c22d | 2011-02-23 21:30:17 | [diff] [blame] | 297 | # Lucid) makes binaries that just segfault, and 2.20.1 does not support |
| 298 | # --map-whole-files. |
[email protected] | ae0637b | 2010-06-30 17:07:56 | [diff] [blame] | 299 | # So install from source if we don't have a good version. |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 300 | |
| 301 | case `ld --version` in |
[email protected] | b4ce3c22d | 2011-02-23 21:30:17 | [diff] [blame] | 302 | *gold*2.2[1-9].*) ;; |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 303 | * ) |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 304 | if test "$do_inst_gold" = "" |
| 305 | then |
| 306 | echo "Gold is a new linker that links Chrome 5x faster than ld." |
| 307 | echo "Don't use it if you need to link other apps (e.g. valgrind, wine)" |
| 308 | echo -n "REPLACE SYSTEM LINKER ld with gold and back up ld? (y/N) " |
| 309 | if yes_no 1; then |
| 310 | do_inst_gold=1 |
| 311 | fi |
| 312 | fi |
| 313 | if test "$do_inst_gold" = "1" |
| 314 | then |
[email protected] | ae0637b | 2010-06-30 17:07:56 | [diff] [blame] | 315 | # If the system provides a good version of gold, just install it. |
[email protected] | b4ce3c22d | 2011-02-23 21:30:17 | [diff] [blame] | 316 | if apt-cache show binutils-gold | grep -Eq 'Version: 2.2[1-9].*'; then |
[email protected] | f9569168 | 2009-11-17 05:19:56 | [diff] [blame] | 317 | echo "Installing binutils-gold. Backing up ld as ld.single." |
| 318 | sudo apt-get install binutils-gold |
| 319 | else |
| 320 | # FIXME: avoid installing as /usr/bin/ld |
| 321 | echo "Building binutils. Backing up ld as ld.orig." |
| 322 | install_gold || exit 99 |
| 323 | fi |
[email protected] | c87aa98 | 2009-06-11 17:44:04 | [diff] [blame] | 324 | else |
| 325 | echo "Not installing gold." |
| 326 | fi |
| 327 | esac |
| 328 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 329 | # Install 32bit backwards compatibility support for 64bit systems |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 330 | if [ "$(uname -m)" = "x86_64" ]; then |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 331 | if test "$do_inst_lib32" = "" |
| 332 | then |
| 333 | echo "Installing 32bit libraries not already provided by the system" |
| 334 | echo |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 335 | echo "This is only needed to build a 32-bit Chrome on your 64-bit system." |
| 336 | echo |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 337 | echo "While we only need to install a relatively small number of library" |
| 338 | echo "files, we temporarily need to download a lot of large *.deb packages" |
| 339 | echo "that contain these files. We will create new *.deb packages that" |
| 340 | echo "include just the 32bit libraries. These files will then be found on" |
| 341 | echo "your system in places like /lib32, /usr/lib32, /usr/lib/debug/lib32," |
| 342 | echo "/usr/lib/debug/usr/lib32. If you ever need to uninstall these files," |
| 343 | echo "look for packages named *-ia32.deb." |
| 344 | echo "Do you want me to download all packages needed to build new 32bit" |
| 345 | echo -n "package files (Y/n) " |
[email protected] | 628b7ca | 2010-01-28 02:44:26 | [diff] [blame] | 346 | if yes_no 0; then |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 347 | do_inst_lib32=1 |
| 348 | fi |
| 349 | fi |
| 350 | if test "$do_inst_lib32" != "1" |
| 351 | then |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 352 | echo "Exiting without installing any 32bit libraries." |
| 353 | exit 0 |
| 354 | fi |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 355 | |
| 356 | # Standard 32bit compatibility libraries |
| 357 | echo "First, installing the limited existing 32-bit support..." |
| 358 | cmp_list="ia32-libs lib32asound2-dev lib32readline5-dev lib32stdc++6 lib32z1 |
| 359 | lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib" |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 360 | sudo apt-get install $cmp_list |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 361 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 362 | tmp=/tmp/install-32bit.$$ |
| 363 | trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT |
| 364 | mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial" |
| 365 | touch "${tmp}/status" |
| 366 | |
| 367 | [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/" |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 368 | cat >>"${tmp}/apt/apt.conf" <<EOF |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 369 | Apt::Architecture "i386"; |
| 370 | Dir::Cache "${tmp}/cache"; |
| 371 | Dir::Cache::Archives "${tmp}/"; |
| 372 | Dir::State::Lists "${tmp}/apt/lists/"; |
| 373 | Dir::State::status "${tmp}/status"; |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 374 | EOF |
[email protected] | 1bf2ac97 | 2009-06-30 23:57:48 | [diff] [blame] | 375 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 376 | # Download 32bit packages |
| 377 | echo "Computing list of available 32bit packages..." |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 378 | sudo apt-get -c="${tmp}/apt/apt.conf" update |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 379 | |
| 380 | echo "Downloading available 32bit packages..." |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 381 | sudo apt-get -c="${tmp}/apt/apt.conf" \ |
| 382 | --yes --download-only --force-yes --reinstall install \ |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 383 | ${lib_list} ${dbg_list} |
| 384 | |
| 385 | # Open packages, remove everything that is not a library, move the |
| 386 | # library to a lib32 directory and package everything as a *.deb file. |
| 387 | echo "Repackaging and installing 32bit packages for use on 64bit systems..." |
| 388 | for i in ${lib_list} ${dbg_list}; do |
| 389 | orig="$(echo "${tmp}/${i}"_*_i386.deb)" |
| 390 | compat="$(echo "${orig}" | |
| 391 | sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')" |
| 392 | rm -rf "${tmp}/staging" |
| 393 | msg="$(fakeroot -u sh -exc ' |
| 394 | # Unpack 32bit Debian archive |
| 395 | umask 022 |
| 396 | mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN" |
| 397 | cd "'"${tmp}"'/staging" |
| 398 | ar x "'${orig}'" |
| 399 | tar zCfx dpkg data.tar.gz |
| 400 | tar zCfx dpkg/DEBIAN control.tar.gz |
| 401 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 402 | # Create a posix extended regular expression fragment that will |
| 403 | # recognize the includes which have changed. Should be rare, |
| 404 | # will almost always be empty. |
| 405 | includes=`sed -n -e "s/^[0-9a-z]* //g" \ |
| 406 | -e "\,usr/include/,p" dpkg/DEBIAN/md5sums | |
| 407 | xargs -n 1 -I FILE /bin/sh -c \ |
| 408 | "cmp -s dpkg/FILE /FILE || echo FILE" | |
| 409 | tr "\n" "|" | |
| 410 | sed -e "s,|$,,"` |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 411 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 412 | # If empty, set it to not match anything. |
| 413 | test -z "$includes" && includes="^//" |
| 414 | |
| 415 | # Turn the conflicts into an extended RE for removal from the |
| 416 | # Provides line. |
| 417 | conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \ |
| 418 | dpkg/DEBIAN/control` |
| 419 | |
| 420 | # Rename package, change architecture, remove conflicts and dependencies |
| 421 | sed -r -i \ |
| 422 | -e "/Package/s/$/-ia32/" \ |
| 423 | -e "/Architecture/s/:.*$/: amd64/" \ |
| 424 | -e "/Depends/s/:.*/: ia32-libs/" \ |
| 425 | -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \ |
| 426 | -e "/Recommends/d" \ |
| 427 | -e "/Conflicts/d" \ |
| 428 | dpkg/DEBIAN/control |
| 429 | |
| 430 | # Only keep files that live in "lib" directories or the includes |
| 431 | # that have changed. |
| 432 | sed -r -i \ |
| 433 | -e "/\/lib64\//d" -e "/\/.?bin\//d" \ |
| 434 | -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \ |
| 435 | -e "s, lib/, lib32/,g" \ |
| 436 | -e "s,/lib/,/lib32/,g" \ |
| 437 | -e "t;d" \ |
| 438 | -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \ |
| 439 | dpkg/DEBIAN/md5sums |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 440 | |
| 441 | # Re-run ldconfig after installation/removal |
| 442 | { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \ |
| 443 | >dpkg/DEBIAN/postinst |
| 444 | { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \ |
| 445 | >dpkg/DEBIAN/postrm |
| 446 | chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm |
| 447 | |
| 448 | # Remove any other control files |
| 449 | find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \ |
| 450 | -name postinst -o -name postrm ")" -o -print | |
| 451 | xargs -r rm -rf |
| 452 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 453 | # Remove any files/dirs that live outside of "lib" directories, |
| 454 | # or are not in our list of changed includes. |
| 455 | find dpkg -mindepth 1 -regextype posix-extended \ |
| 456 | "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \ |
| 457 | -prune -o -print | tac | |
| 458 | 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] | 459 | find dpkg -name lib64 -o -name bin -o -name "?bin" | |
| 460 | tac | xargs -r rm -rf |
| 461 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 462 | # Remove any symbolic links that were broken by the above steps. |
| 463 | find -L dpkg -type l -print | tac | xargs -r rm -rf |
| 464 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 465 | # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32 |
| 466 | # That is where gdb looks for them. |
| 467 | find dpkg -type d -o -path "*/lib/*" -print | |
| 468 | xargs -r -n 1 sh -c " |
| 469 | i=\$(echo \"\${0}\" | |
| 470 | sed -e s,/lib/,/lib32/,g \ |
| 471 | -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,); |
| 472 | mkdir -p \"\${i%/*}\"; |
| 473 | mv \"\${0}\" \"\${i}\"" |
| 474 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 475 | # Rename include to include32. |
| 476 | [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32" |
| 477 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 478 | # Prune any empty directories |
| 479 | find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || : |
| 480 | |
| 481 | # Create our own Debian package |
| 482 | cd .. |
| 483 | dpkg --build staging/dpkg .' 2>&1)" |
| 484 | compat="$(eval echo $(echo "${compat}" | |
| 485 | sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))" |
| 486 | [ -r "${compat}" ] || { |
| 487 | echo "${msg}" >&2 |
| 488 | echo "Failed to build new Debian archive!" >&2 |
| 489 | exit 1 |
| 490 | } |
| 491 | |
| 492 | msg="$(sudo dpkg -i "${compat}" 2>&1)" && { |
| 493 | echo "Installed ${compat##*/}" |
| 494 | } || { |
| 495 | # echo "${msg}" >&2 |
| 496 | echo "Skipped ${compat##*/}" |
| 497 | } |
| 498 | done |
| 499 | |
| 500 | # Add symbolic links for developing 32bit code |
| 501 | echo "Adding missing symbolic links, enabling 32bit code development..." |
| 502 | for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* | |
| 503 | sed -e 's/[.]so[.][0-9].*/.so/' | |
| 504 | sort -u); do |
| 505 | [ "x${i##*/}" = "xld-linux.so" ] && continue |
| 506 | [ -r "$i" ] && continue |
| 507 | j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | |
| 508 | sort -n | tail -n 1)" |
| 509 | [ -r "$i.$j" ] || continue |
| 510 | sudo ln -s "${i##*/}.$j" "$i" |
| 511 | done |
| 512 | fi |