blob: 9269dd7c5fadbec2737cdeb10c4e5df681ac2892 [file] [log] [blame]
[email protected]e041ed12009-03-10 16:43:011#!/bin/bash -e
2
[email protected]aac39c92012-02-08 18:39:533# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]e46cdae2009-08-25 20:59:274# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
[email protected]cf1df402008-10-31 21:45:307# Script to install everything needed to build chromium (well, ideally, anyway)
[email protected]592ea8ca2008-11-03 19:47:368# See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
9# and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit
[email protected]cf1df402008-10-31 21:45:3010
[email protected]1eae2bfb2010-01-26 18:17:5311usage() {
12 echo "Usage: $0 [--options]"
13 echo "Options:"
14 echo "--[no-]syms: enable or disable installation of debugging symbols"
[email protected]1eae2bfb2010-01-26 18:17:5315 echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
[email protected]f2826b6a2012-11-15 01:06:2616 echo "--[no-]arm: enable or disable installation of arm cross toolchain"
[email protected]bd29cdd2013-02-22 03:49:2017 echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
18 "fonts"
[email protected]565416362014-01-16 21:26:4719 echo "--[no-]nacl: enable or disable installation of prerequisites for"\
20 "building standalone NaCl and all its toolchains"
[email protected]e2544ed42012-04-23 04:48:3121 echo "--no-prompt: silently select standard options/defaults"
[email protected]ba48c4ca2013-10-25 16:11:4622 echo "--quick-check: quickly try to determine if dependencies are installed"
23 echo " (this avoids interactive prompts and sudo commands,"
24 echo " so might not be 100% accurate)"
25 echo "--unsupported: attempt installation even on unsupported systems"
[email protected]1eae2bfb2010-01-26 18:17:5326 echo "Script will prompt interactively if options not given."
27 exit 1
28}
29
[email protected]4fc00712013-05-29 23:11:2030# Checks whether a particular package is available in the repos.
31# USAGE: $ package_exists <package name>
32package_exists() {
33 apt-cache pkgnames | grep -x "$1" > /dev/null 2>&1
34}
35
[email protected]1eae2bfb2010-01-26 18:17:5336while test "$1" != ""
37do
38 case "$1" in
[email protected]ce774642011-09-12 23:21:3939 --syms) do_inst_syms=1;;
40 --no-syms) do_inst_syms=0;;
[email protected]ce774642011-09-12 23:21:3941 --lib32) do_inst_lib32=1;;
42 --no-lib32) do_inst_lib32=0;;
[email protected]f2826b6a2012-11-15 01:06:2643 --arm) do_inst_arm=1;;
44 --no-arm) do_inst_arm=0;;
[email protected]bd29cdd2013-02-22 03:49:2045 --chromeos-fonts) do_inst_chromeos_fonts=1;;
46 --no-chromeos-fonts) do_inst_chromeos_fonts=0;;
[email protected]565416362014-01-16 21:26:4747 --nacl) do_inst_nacl=1;;
48 --no-nacl) do_inst_nacl=0;;
[email protected]e2544ed42012-04-23 04:48:3149 --no-prompt) do_default=1
50 do_quietly="-qq --assume-yes"
51 ;;
[email protected]ba48c4ca2013-10-25 16:11:4652 --quick-check) do_quick_check=1;;
[email protected]fe63a022013-01-15 22:11:4753 --unsupported) do_unsupported=1;;
[email protected]1eae2bfb2010-01-26 18:17:5354 *) usage;;
55 esac
56 shift
57done
58
[email protected]20288142014-01-08 06:38:0159ubuntu_versions="12\.04|12\.10|13\.04|13\.10"
60ubuntu_codenames="precise|quantal|raring|saucy"
[email protected]fe63a022013-01-15 22:11:4761ubuntu_issue="Ubuntu ($ubuntu_versions|$ubuntu_codenames)"
62# GCEL is an Ubuntu-derived VM image used on Google Compute Engine; /etc/issue
63# doesn't contain a version number so just trust that the user knows what
64# they're doing.
65gcel_issue="^GCEL"
[email protected]f2826b6a2012-11-15 01:06:2666
[email protected]ba48c4ca2013-10-25 16:11:4667if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then
[email protected]fe63a022013-01-15 22:11:4768 if ! egrep -q "($ubuntu_issue|$gcel_issue)" /etc/issue; then
[email protected]20288142014-01-08 06:38:0169 echo "ERROR: Only Ubuntu 12.04 (precise) through 13.10 (saucy) are"\
[email protected]fe63a022013-01-15 22:11:4770 "currently supported" >&2
71 exit 1
72 fi
[email protected]cf1df402008-10-31 21:45:3073
[email protected]fe63a022013-01-15 22:11:4774 if ! uname -m | egrep -q "i686|x86_64"; then
75 echo "Only x86 architectures are currently supported" >&2
76 exit
77 fi
[email protected]e041ed12009-03-10 16:43:0178fi
79
[email protected]ba48c4ca2013-10-25 16:11:4680if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then
[email protected]e041ed12009-03-10 16:43:0181 echo "Running as non-root user."
82 echo "You might have to enter your password one or more times for 'sudo'."
[email protected]8ada8c52009-03-10 21:53:0883 echo
[email protected]e041ed12009-03-10 16:43:0184fi
85
[email protected]fdc6bf52010-06-07 22:01:5786# Packages needed for chromeos only
[email protected]ba48c4ca2013-10-25 16:11:4687chromeos_dev_list="libbluetooth-dev"
[email protected]fdc6bf52010-06-07 22:01:5788
[email protected]b61f6882013-11-14 20:41:4189# Packages needed for development
[email protected]2022c6b2013-12-17 12:03:2690dev_list="apache2.2-bin bison curl dpkg-dev elfutils fakeroot flex g++ git-core
91 gperf language-pack-da language-pack-fr language-pack-he
[email protected]b7b532802013-11-23 01:37:4992 language-pack-zh-hant libapache2-mod-php5 libasound2-dev libbrlapi-dev
[email protected]b61f6882013-11-14 20:41:4193 libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev
94 libdrm-dev libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev
95 libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev
96 libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev
97 libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev
98 libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev
[email protected]d8f52322013-10-29 05:50:3899 mesa-common-dev openbox patch perl php5-cgi pkg-config python
100 python-cherrypy3 python-dev python-psutil rpm ruby subversion
101 ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho
[email protected]20288142014-01-08 06:38:01102 wdiff xfonts-mathml $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:57103
[email protected]f16aabf2012-08-15 21:00:14104# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
[email protected]d93d68b12012-10-15 06:39:53105# NaCl binaries. These are always needed, regardless of whether or not we want
[email protected]f16aabf2012-08-15 21:00:14106# the full 32-bit "cross-compile" support (--lib32).
[email protected]9161abe2013-10-31 15:15:49107if file /sbin/init | grep -q 'ELF 64-bit'; then
[email protected]d93d68b12012-10-15 06:39:53108 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
[email protected]f16aabf2012-08-15 21:00:14109fi
110
[email protected]fdc6bf52010-06-07 22:01:57111# Run-time libraries required by chromeos only
[email protected]ba48c4ca2013-10-25 16:11:46112chromeos_lib_list="libpulse0 libbz2-1.0"
[email protected]e041ed12009-03-10 16:43:01113
114# Full list of required run-time libraries
[email protected]d8f52322013-10-29 05:50:38115lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1
[email protected]6ffd19f352012-10-23 02:00:41116 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
[email protected]ca3a1d262012-10-30 22:33:20117 libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0
[email protected]9e895962013-05-21 08:26:42118 libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6
[email protected]8190b882012-12-05 19:40:34119 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
120 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1
121 libxtst6 zlib1g $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:01122
123# Debugging symbols for all of the run-time libraries
[email protected]6ffd19f352012-10-23 02:00:41124dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg
125 libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
126 libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
127 libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
128 libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
[email protected]362196232013-11-10 00:43:40129 libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg
130 libstdc++6-4.6-dbg"
[email protected]e041ed12009-03-10 16:43:01131
[email protected]3f85dac32013-10-29 02:38:46132# arm cross toolchain packages needed to build chrome on armhf
133arm_list="libc6-armhf-cross libc6-dev-armhf-cross libgcc1-armhf-cross
134 libgomp1-armhf-cross linux-libc-dev-armhf-cross
135 libgcc1-dbg-armhf-cross libgomp1-dbg-armhf-cross
136 binutils-arm-linux-gnueabihf cpp-arm-linux-gnueabihf
137 gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
138 libmudflap0-dbg-armhf-cross"
[email protected]f2826b6a2012-11-15 01:06:26139
[email protected]3f85dac32013-10-29 02:38:46140# Old armel cross toolchain packages
141armel_list="libc6-armel-cross libc6-dev-armel-cross libgcc1-armel-cross
142 libgomp1-armel-cross linux-libc-dev-armel-cross
143 libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross
144 binutils-arm-linux-gnueabi cpp-arm-linux-gnueabi
145 gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
146 libmudflap0-dbg-armel-cross"
147
148# TODO(sbc): remove armel once the armhf transition is complete
149arm_list="$arm_list $armel_list"
[email protected]31a605532011-08-23 22:27:35150
[email protected]565416362014-01-16 21:26:47151# Packages to build standalone NaCl and all its toolchains.
[email protected]4ef4dcc2014-01-17 22:19:28152nacl_list="g++-mingw-w64-i686 libtinfo-dev:i386"
[email protected]565416362014-01-16 21:26:47153
[email protected]757c2962012-03-15 19:05:18154# Some package names have changed over time
[email protected]4fc00712013-05-29 23:11:20155if package_exists ttf-mscorefonts-installer; then
[email protected]757c2962012-03-15 19:05:18156 dev_list="${dev_list} ttf-mscorefonts-installer"
[email protected]b11411c2012-03-21 22:09:41157else
158 dev_list="${dev_list} msttcorefonts"
[email protected]757c2962012-03-15 19:05:18159fi
[email protected]4fc00712013-05-29 23:11:20160if package_exists libnspr4-dbg; then
[email protected]1a0f64a2011-05-20 17:53:55161 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
162 lib_list="${lib_list} libnspr4 libnss3"
[email protected]757c2962012-03-15 19:05:18163else
164 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
165 lib_list="${lib_list} libnspr4-0d libnss3-1d"
166fi
[email protected]4fc00712013-05-29 23:11:20167if package_exists libjpeg-dev; then
[email protected]9e895962013-05-21 08:26:42168 dev_list="${dev_list} libjpeg-dev"
[email protected]b11411c2012-03-21 22:09:41169else
[email protected]9e895962013-05-21 08:26:42170 dev_list="${dev_list} libjpeg62-dev"
[email protected]b11411c2012-03-21 22:09:41171fi
[email protected]4fc00712013-05-29 23:11:20172if package_exists libudev1; then
[email protected]9e895962013-05-21 08:26:42173 dev_list="${dev_list} libudev1"
174else
175 dev_list="${dev_list} libudev0"
176fi
[email protected]3ea42912013-09-06 06:23:57177if package_exists libbrlapi0.6; then
178 dev_list="${dev_list} libbrlapi0.6"
179else
180 dev_list="${dev_list} libbrlapi0.5"
181fi
[email protected]9e895962013-05-21 08:26:42182
[email protected]757c2962012-03-15 19:05:18183
[email protected]dc099772013-09-30 22:06:58184# Some packages are only needed if the distribution actually supports
[email protected]757c2962012-03-15 19:05:18185# installing them.
[email protected]4fc00712013-05-29 23:11:20186if package_exists appmenu-gtk; then
[email protected]757c2962012-03-15 19:05:18187 lib_list="$lib_list appmenu-gtk"
[email protected]4da8fad2011-04-11 18:42:42188fi
189
[email protected]8ada8c52009-03-10 21:53:08190# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
191# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
192# been provided to yes_no(), the function also accepts RETURN as a user input.
193# The parameter specifies the exit code that should be returned in that case.
194# The function will echo the user's selection followed by a newline character.
195# Users can abort the function by pressing CTRL-C. This will call "exit 1".
196yes_no() {
[email protected]e2544ed42012-04-23 04:48:31197 if [ 0 -ne "${do_default-0}" ] ; then
[email protected]dc099772013-09-30 22:06:58198 [ $1 -eq 0 ] && echo "Y" || echo "N"
[email protected]e2544ed42012-04-23 04:48:31199 return $1
200 fi
[email protected]8ada8c52009-03-10 21:53:08201 local c
202 while :; do
203 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
204 stty -echo iuclc -icanon 2>/dev/null
205 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
206 case "$c" in
207 " 0a") if [ -n "$1" ]; then
208 [ $1 -eq 0 ] && echo "Y" || echo "N"
209 return $1
210 fi
211 ;;
212 " 79") echo "Y"
213 return 0
214 ;;
215 " 6e") echo "N"
216 return 1
217 ;;
218 "") echo "Aborted" >&2
219 exit 1
220 ;;
221 *) # The user pressed an unrecognized key. As we are not echoing
222 # any incorrect user input, alert the user by ringing the bell.
223 (tput bel) 2>/dev/null
224 ;;
225 esac
226 done
227}
228
[email protected]ba48c4ca2013-10-25 16:11:46229if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0}
[email protected]1eae2bfb2010-01-26 18:17:53230then
231 echo "This script installs all tools and libraries needed to build Chromium."
232 echo ""
233 echo "For most of the libraries, it can also install debugging symbols, which"
234 echo "will allow you to debug code in the system libraries. Most developers"
235 echo "won't need these symbols."
236 echo -n "Do you want me to install them for you (y/N) "
237 if yes_no 1; then
238 do_inst_syms=1
239 fi
240fi
241if test "$do_inst_syms" = "1"; then
[email protected]ba48c4ca2013-10-25 16:11:46242 echo "Including debugging symbols."
[email protected]8ada8c52009-03-10 21:53:08243else
[email protected]ba48c4ca2013-10-25 16:11:46244 echo "Skipping debugging symbols."
[email protected]8ada8c52009-03-10 21:53:08245 dbg_list=
246fi
247
[email protected]9f28a9cf2012-12-17 23:31:40248# When cross building for arm on 64-bit systems the host binaries
249# that are part of v8 need to be compiled with -m32 which means
250# that basic multilib support is needed.
[email protected]9161abe2013-10-31 15:15:49251if file /sbin/init | grep -q 'ELF 64-bit'; then
[email protected]9f28a9cf2012-12-17 23:31:40252 arm_list="$arm_list g++-multilib"
253fi
254
[email protected]ba48c4ca2013-10-25 16:11:46255if test "$do_inst_arm" = "1" ; then
[email protected]ba48c4ca2013-10-25 16:11:46256 echo "Including ARM cross toolchain."
[email protected]f2826b6a2012-11-15 01:06:26257else
[email protected]ba48c4ca2013-10-25 16:11:46258 echo "Skipping ARM cross toolchain."
[email protected]f2826b6a2012-11-15 01:06:26259 arm_list=
260fi
261
[email protected]565416362014-01-16 21:26:47262if test "$do_inst_nacl" = "1"; then
263 echo "Including standalone NaCl dependencies."
264else
265 echo "Skipping standalone NaCl dependencies."
266 nacl_list=
267fi
268
269packages="$(
270 echo "${dev_list} ${lib_list} ${dbg_list} ${arm_list} ${nacl_list}" |
271 tr " " "\n" | sort -u | tr "\n" " "
272)"
[email protected]ba48c4ca2013-10-25 16:11:46273
274if [ 1 -eq "${do_quick_check-0}" ] ; then
275 failed_check="$(dpkg-query -W -f '${PackageSpec}:${Status}\n' \
276 ${packages} 2>&1 | grep -v "ok installed" || :)"
277 if [ -n "${failed_check}" ]; then
278 echo
279 nomatch="$(echo "${failed_check}" | \
280 sed -e "s/^No packages found matching \(.*\).$/\1/;t;d")"
281 missing="$(echo "${failed_check}" | \
282 sed -e "/^No packages found matching/d;s/^\(.*\):.*$/\1/")"
283 if [ "$nomatch" ]; then
284 # Distinguish between packages that actually aren't available to the
285 # system (i.e. not in any repo) and packages that just aren't known to
286 # dpkg (i.e. managed by apt).
287 unknown=""
288 for p in ${nomatch}; do
289 if apt-cache show ${p} > /dev/null 2>&1; then
290 missing="${p}\n${missing}"
291 else
292 unknown="${p}\n${unknown}"
293 fi
294 done
295 if [ -n "${unknown}" ]; then
296 echo "WARNING: The following packages are unknown to your system"
297 echo "(maybe missing a repo or need to 'sudo apt-get update'):"
298 echo -e "${unknown}" | sed -e "s/^/ /"
299 fi
300 fi
301 if [ -n "${missing}" ]; then
302 echo "WARNING: The following packages are not installed:"
303 echo -e "${missing}" | sed -e "s/^/ /"
304 fi
305 exit 1
306 fi
307 exit 0
308fi
309
[email protected]e041ed12009-03-10 16:43:01310sudo apt-get update
311
312# We initially run "apt-get" with the --reinstall option and parse its output.
313# This way, we can find all the packages that need to be newly installed
314# without accidentally promoting any packages from "auto" to "manual".
315# We then re-run "apt-get" with just the list of missing packages.
316echo "Finding missing packages..."
[email protected]757c2962012-03-15 19:05:18317# Intentionally leaving $packages unquoted so it's more readable.
[email protected]b6e064522009-08-10 18:47:51318echo "Packages required: " $packages
319echo
[email protected]79a9d2962009-08-06 21:10:58320new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
[email protected]c3d8b152013-05-10 10:10:03321if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then
[email protected]b6e064522009-08-10 18:47:51322 # We probably never hit this following line.
[email protected]79a9d2962009-08-06 21:10:58323 echo "No missing packages, and the packages are up-to-date."
[email protected]b62f11e72010-05-03 17:20:45324elif [ $? -eq 1 ]; then
[email protected]79a9d2962009-08-06 21:10:58325 # We expect apt-get to have exit status of 1.
[email protected]757c2962012-03-15 19:05:18326 # This indicates that we cancelled the install with "yes n|".
[email protected]b6e064522009-08-10 18:47:51327 new_list=$(echo "$new_list" |
[email protected]79a9d2962009-08-06 21:10:58328 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
[email protected]b6e064522009-08-10 18:47:51329 new_list=$(echo "$new_list" | sed 's/ *$//')
330 if [ -z "$new_list" ] ; then
331 echo "No missing packages, and the packages are up-to-date."
332 else
333 echo "Installing missing packages: $new_list."
[email protected]e2544ed42012-04-23 04:48:31334 sudo apt-get install ${do_quietly-} ${new_list}
[email protected]b6e064522009-08-10 18:47:51335 fi
336 echo
[email protected]79a9d2962009-08-06 21:10:58337else
338 # An apt-get exit status of 100 indicates that a real error has occurred.
[email protected]e041ed12009-03-10 16:43:01339
[email protected]79a9d2962009-08-06 21:10:58340 # I am intentionally leaving out the '"'s around new_list_cmd,
341 # as this makes it easier to cut and paste the output
[email protected]79a9d2962009-08-06 21:10:58342 echo "The following command failed: " ${new_list_cmd}
343 echo
344 echo "It produces the following output:"
345 yes n | $new_list_cmd || true
346 echo
347 echo "You will have to install the above packages yourself."
348 echo
349 exit 100
350fi
[email protected]e041ed12009-03-10 16:43:01351
[email protected]d96cc3472013-09-19 00:53:30352# Install the Chrome OS default fonts. This must go after running
353# apt-get, since install-chromeos-fonts depends on curl.
354if test "$do_inst_chromeos_fonts" != "0"; then
355 echo
356 echo "Installing Chrome OS fonts."
357 dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
358 if ! sudo $dir/linux/install-chromeos-fonts.py; then
359 echo "ERROR: The installation of the Chrome OS default fonts failed."
360 if [ `stat -f -c %T $dir` == "nfs" ]; then
361 echo "The reason is that your repo is installed on a remote file system."
362 else
363 echo "This is expected if your repo is installed on a remote file system."
364 fi
365 echo "It is recommended to install your repo on a local file system."
366 echo "You can skip the installation of the Chrome OS default founts with"
367 echo "the command line option: --no-chromeos-fonts."
368 exit 1
369 fi
370else
371 echo "Skipping installation of Chrome OS fonts."
372fi
373
[email protected]e041ed12009-03-10 16:43:01374# Install 32bit backwards compatibility support for 64bit systems
[email protected]9161abe2013-10-31 15:15:49375if file /sbin/init | grep -q 'ELF 64-bit'; then
[email protected]1eae2bfb2010-01-26 18:17:53376 if test "$do_inst_lib32" != "1"
377 then
[email protected]4a242bea2012-11-07 19:31:52378 echo "NOTE: If you were expecting the option to install 32bit libs,"
379 echo "please run with the --lib32 flag."
380 echo
381 echo "Installation complete."
[email protected]8ada8c52009-03-10 21:53:08382 exit 0
[email protected]f3b3ba7b2013-04-24 00:11:27383 else
384 # This conditional statement has been added to deprecate and eventually
385 # remove support for 32bit libraries on 64bit systems. But for the time
386 # being, we still have to support a few legacy systems (e.g. bots), where
387 # this feature is needed.
388 # We only even give the user the option to install these libraries, if
389 # they explicitly requested doing so by setting the --lib32 command line
390 # flag.
391 # And even then, we interactively ask them one more time whether they are
392 # absolutely sure.
393 # In order for that to work, we must reset the ${do_inst_lib32} variable.
394 # There are other ways to achieve the same goal. But resetting the
395 # variable is the best way to document the intended behavior -- and to
396 # allow us to gradually deprecate and then remove the obsolete code.
[email protected]dc099772013-09-30 22:06:58397 if test "${do_default-0}" -ne 1; then
398 do_inst_lib32=
399 fi
[email protected]8ada8c52009-03-10 21:53:08400 fi
[email protected]b62f11e72010-05-03 17:20:45401
[email protected]4a242bea2012-11-07 19:31:52402 echo "WARNING"
[email protected]e76a3632012-03-15 20:56:27403 echo
[email protected]4a242bea2012-11-07 19:31:52404 echo "We no longer recommend that you use this script to install"
405 echo "32bit libraries on a 64bit system. Instead, consider using the"
406 echo "install-chroot.sh script to help you set up a 32bit environment"
407 echo "for building and testing 32bit versions of Chrome."
408 echo
409 echo "The code for installing 32bit libraries on a 64bit system is"
410 echo "unmaintained and might not work with modern versions of Ubuntu"
411 echo "or Debian."
[email protected]dc099772013-09-30 22:06:58412 if test "$do_inst_lib32" != "" ; then
413 echo
414 echo -n "Are you sure you want to proceed (y/N) "
415 if yes_no 1; then
416 do_inst_lib32=1
417 fi
[email protected]4a242bea2012-11-07 19:31:52418 fi
419 if test "$do_inst_lib32" != "1"
[email protected]796c3522012-11-07 22:56:35420 then
[email protected]4a242bea2012-11-07 19:31:52421 exit 0
422 fi
[email protected]e76a3632012-03-15 20:56:27423
[email protected]b62f11e72010-05-03 17:20:45424 # Standard 32bit compatibility libraries
425 echo "First, installing the limited existing 32-bit support..."
[email protected]7cf14b372011-12-08 18:32:52426 cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
[email protected]b62f11e72010-05-03 17:20:45427 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
[email protected]7cf14b372011-12-08 18:32:52428 if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
429 cmp_list="${cmp_list} lib32readline-gplv2-dev"
430 else
431 cmp_list="${cmp_list} lib32readline5-dev"
432 fi
[email protected]221569d32012-05-20 04:55:48433 sudo apt-get install ${do_quietly-} $cmp_list
[email protected]b62f11e72010-05-03 17:20:45434
[email protected]e041ed12009-03-10 16:43:01435 tmp=/tmp/install-32bit.$$
436 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
437 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
438 touch "${tmp}/status"
439
440 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
[email protected]b6e064522009-08-10 18:47:51441 cat >>"${tmp}/apt/apt.conf" <<EOF
[email protected]79a9d2962009-08-06 21:10:58442 Apt::Architecture "i386";
443 Dir::Cache "${tmp}/cache";
444 Dir::Cache::Archives "${tmp}/";
445 Dir::State::Lists "${tmp}/apt/lists/";
446 Dir::State::status "${tmp}/status";
[email protected]b6e064522009-08-10 18:47:51447EOF
[email protected]1bf2ac972009-06-30 23:57:48448
[email protected]e041ed12009-03-10 16:43:01449 # Download 32bit packages
450 echo "Computing list of available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53451 sudo apt-get -c="${tmp}/apt/apt.conf" update
[email protected]e041ed12009-03-10 16:43:01452
453 echo "Downloading available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53454 sudo apt-get -c="${tmp}/apt/apt.conf" \
455 --yes --download-only --force-yes --reinstall install \
[email protected]e041ed12009-03-10 16:43:01456 ${lib_list} ${dbg_list}
457
458 # Open packages, remove everything that is not a library, move the
459 # library to a lib32 directory and package everything as a *.deb file.
460 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
461 for i in ${lib_list} ${dbg_list}; do
462 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
463 compat="$(echo "${orig}" |
464 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
465 rm -rf "${tmp}/staging"
466 msg="$(fakeroot -u sh -exc '
467 # Unpack 32bit Debian archive
468 umask 022
469 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
470 cd "'"${tmp}"'/staging"
471 ar x "'${orig}'"
[email protected]55d1d7532013-03-19 03:06:45472 tar Cfx dpkg data.tar*
[email protected]e041ed12009-03-10 16:43:01473 tar zCfx dpkg/DEBIAN control.tar.gz
474
[email protected]34799f9d2010-07-08 17:51:33475 # Create a posix extended regular expression fragment that will
476 # recognize the includes which have changed. Should be rare,
477 # will almost always be empty.
478 includes=`sed -n -e "s/^[0-9a-z]* //g" \
479 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
480 xargs -n 1 -I FILE /bin/sh -c \
481 "cmp -s dpkg/FILE /FILE || echo FILE" |
482 tr "\n" "|" |
483 sed -e "s,|$,,"`
[email protected]e041ed12009-03-10 16:43:01484
[email protected]34799f9d2010-07-08 17:51:33485 # If empty, set it to not match anything.
486 test -z "$includes" && includes="^//"
487
488 # Turn the conflicts into an extended RE for removal from the
489 # Provides line.
490 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
491 dpkg/DEBIAN/control`
492
493 # Rename package, change architecture, remove conflicts and dependencies
494 sed -r -i \
495 -e "/Package/s/$/-ia32/" \
496 -e "/Architecture/s/:.*$/: amd64/" \
497 -e "/Depends/s/:.*/: ia32-libs/" \
498 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
499 -e "/Recommends/d" \
500 -e "/Conflicts/d" \
501 dpkg/DEBIAN/control
502
503 # Only keep files that live in "lib" directories or the includes
504 # that have changed.
505 sed -r -i \
506 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
507 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
508 -e "s, lib/, lib32/,g" \
509 -e "s,/lib/,/lib32/,g" \
510 -e "t;d" \
511 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
512 dpkg/DEBIAN/md5sums
[email protected]e041ed12009-03-10 16:43:01513
514 # Re-run ldconfig after installation/removal
515 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
516 >dpkg/DEBIAN/postinst
517 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
518 >dpkg/DEBIAN/postrm
519 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
520
521 # Remove any other control files
522 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
523 -name postinst -o -name postrm ")" -o -print |
524 xargs -r rm -rf
525
[email protected]34799f9d2010-07-08 17:51:33526 # Remove any files/dirs that live outside of "lib" directories,
527 # or are not in our list of changed includes.
528 find dpkg -mindepth 1 -regextype posix-extended \
529 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
530 -prune -o -print | tac |
531 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
[email protected]e041ed12009-03-10 16:43:01532 find dpkg -name lib64 -o -name bin -o -name "?bin" |
533 tac | xargs -r rm -rf
534
[email protected]34799f9d2010-07-08 17:51:33535 # Remove any symbolic links that were broken by the above steps.
536 find -L dpkg -type l -print | tac | xargs -r rm -rf
537
[email protected]e041ed12009-03-10 16:43:01538 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
539 # That is where gdb looks for them.
540 find dpkg -type d -o -path "*/lib/*" -print |
541 xargs -r -n 1 sh -c "
542 i=\$(echo \"\${0}\" |
543 sed -e s,/lib/,/lib32/,g \
544 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
545 mkdir -p \"\${i%/*}\";
546 mv \"\${0}\" \"\${i}\""
547
[email protected]34799f9d2010-07-08 17:51:33548 # Rename include to include32.
549 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
550
[email protected]e041ed12009-03-10 16:43:01551 # Prune any empty directories
552 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
553
554 # Create our own Debian package
555 cd ..
556 dpkg --build staging/dpkg .' 2>&1)"
557 compat="$(eval echo $(echo "${compat}" |
558 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
559 [ -r "${compat}" ] || {
560 echo "${msg}" >&2
561 echo "Failed to build new Debian archive!" >&2
562 exit 1
563 }
564
565 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
566 echo "Installed ${compat##*/}"
567 } || {
568 # echo "${msg}" >&2
569 echo "Skipped ${compat##*/}"
570 }
571 done
572
573 # Add symbolic links for developing 32bit code
574 echo "Adding missing symbolic links, enabling 32bit code development..."
575 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
576 sed -e 's/[.]so[.][0-9].*/.so/' |
577 sort -u); do
578 [ "x${i##*/}" = "xld-linux.so" ] && continue
579 [ -r "$i" ] && continue
580 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
581 sort -n | tail -n 1)"
582 [ -r "$i.$j" ] || continue
583 sudo ln -s "${i##*/}.$j" "$i"
584 done
585fi