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