blob: d882f2529f7873e930422ff3ec1f104f5e48920b [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"
johnme49bb458a2014-11-27 15:45:3115 echo "--lib32: enable installation of 32-bit libraries, e.g. for V8 snapshot"
[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]fbeddf22014-01-17 23:59:0136# These default to on because (some) bots need them and it keeps things
37# simple for the bot setup if all bots just run the script in its default
38# mode. Developers who don't want stuff they don't need installed on their
39# own workstations can pass --no-arm --no-nacl when running the script.
40do_inst_arm=1
41do_inst_nacl=1
42
[email protected]1eae2bfb2010-01-26 18:17:5343while test "$1" != ""
44do
45 case "$1" in
[email protected]ce774642011-09-12 23:21:3946 --syms) do_inst_syms=1;;
47 --no-syms) do_inst_syms=0;;
[email protected]ce774642011-09-12 23:21:3948 --lib32) do_inst_lib32=1;;
[email protected]f2826b6a2012-11-15 01:06:2649 --arm) do_inst_arm=1;;
50 --no-arm) do_inst_arm=0;;
[email protected]bd29cdd2013-02-22 03:49:2051 --chromeos-fonts) do_inst_chromeos_fonts=1;;
52 --no-chromeos-fonts) do_inst_chromeos_fonts=0;;
[email protected]565416362014-01-16 21:26:4753 --nacl) do_inst_nacl=1;;
54 --no-nacl) do_inst_nacl=0;;
[email protected]e2544ed42012-04-23 04:48:3155 --no-prompt) do_default=1
56 do_quietly="-qq --assume-yes"
57 ;;
[email protected]ba48c4ca2013-10-25 16:11:4658 --quick-check) do_quick_check=1;;
[email protected]fe63a022013-01-15 22:11:4759 --unsupported) do_unsupported=1;;
[email protected]1eae2bfb2010-01-26 18:17:5360 *) usage;;
61 esac
62 shift
63done
64
johnme49bb458a2014-11-27 15:45:3165if test "$do_inst_arm" = "1"; then
66 do_inst_lib32=1
67fi
68
[email protected]0febc9b2014-05-22 20:07:1969# Check for lsb_release command in $PATH
70if ! which lsb_release > /dev/null; then
71 echo "ERROR: lsb_release not found in \$PATH" >&2
72 exit 1;
73fi
[email protected]f2826b6a2012-11-15 01:06:2674
[email protected]0febc9b2014-05-22 20:07:1975lsb_release=$(lsb_release --codename --short)
halton.huo3e728c42016-01-20 05:12:2376ubuntu_codenames="(precise|trusty|utopic|vivid|wily)"
[email protected]ba48c4ca2013-10-25 16:11:4677if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then
[email protected]0febc9b2014-05-22 20:07:1978 if [[ ! $lsb_release =~ $ubuntu_codenames ]]; then
halton.huo48405252015-04-30 01:52:3979 echo "ERROR: Only Ubuntu 12.04 (precise), 14.04 (trusty), " \
halton.huo3e728c42016-01-20 05:12:2380 "14.10 (utopic), 15.04 (vivid) and 15.10 (wily) "
81 "are currently supported" >&2
[email protected]fe63a022013-01-15 22:11:4782 exit 1
83 fi
[email protected]cf1df402008-10-31 21:45:3084
[email protected]fe63a022013-01-15 22:11:4785 if ! uname -m | egrep -q "i686|x86_64"; then
86 echo "Only x86 architectures are currently supported" >&2
87 exit
88 fi
[email protected]e041ed12009-03-10 16:43:0189fi
90
[email protected]ba48c4ca2013-10-25 16:11:4691if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then
[email protected]e041ed12009-03-10 16:43:0192 echo "Running as non-root user."
93 echo "You might have to enter your password one or more times for 'sudo'."
[email protected]8ada8c52009-03-10 21:53:0894 echo
[email protected]e041ed12009-03-10 16:43:0195fi
96
[email protected]fdc6bf52010-06-07 22:01:5797# Packages needed for chromeos only
dnj6a8491d12015-05-26 21:08:1298chromeos_dev_list="libbluetooth-dev libxkbcommon-dev realpath"
[email protected]fdc6bf52010-06-07 22:01:5799
[email protected]b61f6882013-11-14 20:41:41100# Packages needed for development
halton.huo3e728c42016-01-20 05:12:23101dev_list="bison cdbs curl dpkg-dev elfutils devscripts fakeroot
Henrik Kjellander011f9c82014-09-19 07:28:34102 flex fonts-thai-tlwg g++ git-core git-svn gperf language-pack-da
[email protected]48d96e92014-08-19 18:31:00103 language-pack-fr language-pack-he language-pack-zh-hant
104 libapache2-mod-php5 libasound2-dev libbrlapi-dev libav-tools
105 libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev
revemandd26069a2015-11-09 21:39:21106 libdrm-dev libelf-dev libexif-dev libffi-dev libgconf2-dev
107 libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev
108 libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev
109 libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev
110 libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev
111 openbox patch perl php5-cgi pkg-config python python-cherrypy3
112 python-crypto python-dev python-numpy python-opencv python-openssl
113 python-psutil python-yaml rpm ruby subversion ttf-dejavu-core
halton.huo3e728c42016-01-20 05:12:23114 ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho wdiff
revemandd26069a2015-11-09 21:39:21115 zip $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:57116
[email protected]f16aabf2012-08-15 21:00:14117# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
[email protected]f8ceadb2014-08-18 12:30:23118# NaCl binaries.
ki.stfu0a79d6992015-09-17 07:27:12119if file -L /sbin/init | grep -q 'ELF 64-bit'; then
[email protected]d93d68b12012-10-15 06:39:53120 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
[email protected]f16aabf2012-08-15 21:00:14121fi
122
[email protected]fdc6bf52010-06-07 22:01:57123# Run-time libraries required by chromeos only
[email protected]ba48c4ca2013-10-25 16:11:46124chromeos_lib_list="libpulse0 libbz2-1.0"
[email protected]e041ed12009-03-10 16:43:01125
126# Full list of required run-time libraries
[email protected]d8f52322013-10-29 05:50:38127lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1
revemandd26069a2015-11-09 21:39:21128 libexif12 libffi6 libfontconfig1 libfreetype6 libglib2.0-0
129 libgnome-keyring0 libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3
130 libpixman-1-0 libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6
[email protected]8190b882012-12-05 19:40:34131 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
132 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1
133 libxtst6 zlib1g $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:01134
135# Debugging symbols for all of the run-time libraries
revemandd26069a2015-11-09 21:39:21136dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libffi6-dbg libfontconfig1-dbg
[email protected]6ffd19f352012-10-23 02:00:41137 libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
138 libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
139 libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
140 libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
lfgad917d12015-03-17 23:28:00141 libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg"
142
143# Find the proper version of libstdc++6-4.x-dbg.
144if [ "x$lsb_release" = "xprecise" ]; then
145 dbg_list="${dbg_list} libstdc++6-4.6-dbg"
146elif [ "x$lsb_release" = "xtrusty" ]; then
147 dbg_list="${dbg_list} libstdc++6-4.8-dbg"
148else
149 dbg_list="${dbg_list} libstdc++6-4.9-dbg"
150fi
[email protected]e041ed12009-03-10 16:43:01151
johnme49bb458a2014-11-27 15:45:31152# 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf
153lib32_list="linux-libc-dev:i386"
154
[email protected]3f85dac32013-10-29 02:38:46155# arm cross toolchain packages needed to build chrome on armhf
[email protected]a2984e22014-05-22 00:48:12156arm_list="libc6-dev-armhf-cross
157 linux-libc-dev-armhf-cross
johnme49bb458a2014-11-27 15:45:31158 g++-arm-linux-gnueabihf"
[email protected]31a605532011-08-23 22:27:35159
sbcb5d4ded2015-04-01 17:49:03160# Work around for dependency issue Ubuntu/Trusty: http://crbug.com/435056
161if [ "x$lsb_release" = "xtrusty" ]; then
162 arm_list+=" g++-4.8-multilib-arm-linux-gnueabihf
163 gcc-4.8-multilib-arm-linux-gnueabihf"
164fi
165
[email protected]713eac62014-06-02 23:10:03166# Packages to build NaCl, its toolchains, and its ports.
Brad Nelson5e59c2c2014-09-06 06:18:45167naclports_list="ant autoconf bison cmake gawk intltool xutils-dev xsltproc"
168nacl_list="g++-mingw-w64-i686 lib32z1-dev
[email protected]5203a352014-06-19 16:17:50169 libasound2:i386 libcap2:i386 libelf-dev:i386 libexif12:i386
[email protected]419a9a62014-06-19 18:26:18170 libfontconfig1:i386 libgconf-2-4:i386 libglib2.0-0:i386 libgpm2:i386
[email protected]a14d76e2014-07-23 02:25:08171 libgtk2.0-0:i386 libncurses5:i386 lib32ncurses5-dev
Brad Nelson5e59c2c2014-09-06 06:18:45172 libnss3:i386 libpango1.0-0:i386
sbc6ab44c32015-02-13 23:19:17173 libssl1.0.0:i386 libtinfo-dev libtinfo-dev:i386 libtool
[email protected]419a9a62014-06-19 18:26:18174 libxcomposite1:i386 libxcursor1:i386 libxdamage1:i386 libxi6:i386
Brad Nelson5e59c2c2014-09-06 06:18:45175 libxrandr2:i386 libxss1:i386 libxtst6:i386 texinfo xvfb
176 ${naclports_list}"
[email protected]419a9a62014-06-19 18:26:18177
torne8a6eb692015-11-05 12:43:08178# Find the proper version of packages that depend on mesa. Only one -lts variant
179# of mesa can be installed and everything that depends on it must match.
180
181# Query for the name and status of all mesa LTS variants, filter for only
182# installed packages, extract just the name, and eliminate duplicates (there can
183# be more than one with the same name in the case of multiarch). Expand into an
184# array.
185mesa_packages=($(dpkg-query -Wf'${package} ${status}\n' \
186 libgl1-mesa-glx-lts-\* | \
187 grep " ok installed" | cut -d " " -f 1 | sort -u))
188if [ "${#mesa_packages[@]}" -eq 0 ]; then
189 mesa_variant=""
190elif [ "${#mesa_packages[@]}" -eq 1 ]; then
191 # Strip the base package name and leave just "-lts-whatever"
192 mesa_variant="${mesa_packages[0]#libgl1-mesa-glx}"
193else
194 echo "ERROR: unable to determine which libgl1-mesa-glx variant is installed."
195 exit 1
196fi
[email protected]3a4bd5d2014-06-25 23:55:04197dev_list="${dev_list} libgbm-dev${mesa_variant}
vabrf1e8b17f2015-03-17 10:56:37198 libgles2-mesa-dev${mesa_variant} libgl1-mesa-dev${mesa_variant}
199 mesa-common-dev${mesa_variant}"
[email protected]419a9a62014-06-19 18:26:18200nacl_list="${nacl_list} libgl1-mesa-glx${mesa_variant}:i386"
[email protected]565416362014-01-16 21:26:47201
[email protected]757c2962012-03-15 19:05:18202# Some package names have changed over time
[email protected]4fc00712013-05-29 23:11:20203if package_exists ttf-mscorefonts-installer; then
[email protected]757c2962012-03-15 19:05:18204 dev_list="${dev_list} ttf-mscorefonts-installer"
[email protected]b11411c2012-03-21 22:09:41205else
206 dev_list="${dev_list} msttcorefonts"
[email protected]757c2962012-03-15 19:05:18207fi
[email protected]4fc00712013-05-29 23:11:20208if package_exists libnspr4-dbg; then
[email protected]1a0f64a2011-05-20 17:53:55209 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
210 lib_list="${lib_list} libnspr4 libnss3"
[email protected]757c2962012-03-15 19:05:18211else
212 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
213 lib_list="${lib_list} libnspr4-0d libnss3-1d"
214fi
[email protected]4fc00712013-05-29 23:11:20215if package_exists libjpeg-dev; then
[email protected]9e895962013-05-21 08:26:42216 dev_list="${dev_list} libjpeg-dev"
[email protected]b11411c2012-03-21 22:09:41217else
[email protected]9e895962013-05-21 08:26:42218 dev_list="${dev_list} libjpeg62-dev"
[email protected]b11411c2012-03-21 22:09:41219fi
[email protected]4fc00712013-05-29 23:11:20220if package_exists libudev1; then
[email protected]9e895962013-05-21 08:26:42221 dev_list="${dev_list} libudev1"
[email protected]ab9e69082014-06-05 15:28:52222 nacl_list="${nacl_list} libudev1:i386"
[email protected]9e895962013-05-21 08:26:42223else
224 dev_list="${dev_list} libudev0"
[email protected]ab9e69082014-06-05 15:28:52225 nacl_list="${nacl_list} libudev0:i386"
[email protected]9e895962013-05-21 08:26:42226fi
[email protected]3ea42912013-09-06 06:23:57227if package_exists libbrlapi0.6; then
228 dev_list="${dev_list} libbrlapi0.6"
229else
230 dev_list="${dev_list} libbrlapi0.5"
231fi
halton.huo3e728c42016-01-20 05:12:23232if package_exists apache2-bin; then
233 dev_list="${dev_list} apache2-bin"
234else
235 dev_list="${dev_list} apache2.2-bin"
236fi
237if package_exists fonts-stix; then
238 dev_list="${dev_list} fonts-stix"
239else
240 dev_list="${dev_list} xfonts-mathml"
241fi
[email protected]757c2962012-03-15 19:05:18242
[email protected]dc099772013-09-30 22:06:58243# Some packages are only needed if the distribution actually supports
[email protected]757c2962012-03-15 19:05:18244# installing them.
[email protected]4fc00712013-05-29 23:11:20245if package_exists appmenu-gtk; then
[email protected]757c2962012-03-15 19:05:18246 lib_list="$lib_list appmenu-gtk"
[email protected]4da8fad2011-04-11 18:42:42247fi
248
johnme49bb458a2014-11-27 15:45:31249# When cross building for arm/Android on 64-bit systems the host binaries
250# that are part of v8 need to be compiled with -m32 which means
251# that basic multilib support is needed.
ki.stfu0a79d6992015-09-17 07:27:12252if file -L /sbin/init | grep -q 'ELF 64-bit'; then
johnme49bb458a2014-11-27 15:45:31253 # gcc-multilib conflicts with the arm cross compiler (at least in trusty) but
254 # g++-X.Y-multilib gives us the 32-bit support that we need. Find out the
255 # appropriate value of X and Y by seeing what version the current
256 # distribution's g++-multilib package depends on.
257 multilib_package=$(apt-cache depends g++-multilib --important | \
258 grep -E --color=never --only-matching '\bg\+\+-[0-9.]+-multilib\b')
259 lib32_list="$lib32_list $multilib_package"
260fi
261
[email protected]8ada8c52009-03-10 21:53:08262# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
263# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
264# been provided to yes_no(), the function also accepts RETURN as a user input.
265# The parameter specifies the exit code that should be returned in that case.
266# The function will echo the user's selection followed by a newline character.
267# Users can abort the function by pressing CTRL-C. This will call "exit 1".
268yes_no() {
[email protected]e2544ed42012-04-23 04:48:31269 if [ 0 -ne "${do_default-0}" ] ; then
[email protected]dc099772013-09-30 22:06:58270 [ $1 -eq 0 ] && echo "Y" || echo "N"
[email protected]e2544ed42012-04-23 04:48:31271 return $1
272 fi
[email protected]8ada8c52009-03-10 21:53:08273 local c
274 while :; do
275 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
276 stty -echo iuclc -icanon 2>/dev/null
277 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
278 case "$c" in
279 " 0a") if [ -n "$1" ]; then
280 [ $1 -eq 0 ] && echo "Y" || echo "N"
281 return $1
282 fi
283 ;;
284 " 79") echo "Y"
285 return 0
286 ;;
287 " 6e") echo "N"
288 return 1
289 ;;
290 "") echo "Aborted" >&2
291 exit 1
292 ;;
293 *) # The user pressed an unrecognized key. As we are not echoing
294 # any incorrect user input, alert the user by ringing the bell.
295 (tput bel) 2>/dev/null
296 ;;
297 esac
298 done
299}
300
[email protected]ba48c4ca2013-10-25 16:11:46301if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0}
[email protected]1eae2bfb2010-01-26 18:17:53302then
303 echo "This script installs all tools and libraries needed to build Chromium."
304 echo ""
305 echo "For most of the libraries, it can also install debugging symbols, which"
306 echo "will allow you to debug code in the system libraries. Most developers"
307 echo "won't need these symbols."
308 echo -n "Do you want me to install them for you (y/N) "
309 if yes_no 1; then
310 do_inst_syms=1
311 fi
312fi
313if test "$do_inst_syms" = "1"; then
[email protected]ba48c4ca2013-10-25 16:11:46314 echo "Including debugging symbols."
[email protected]8ada8c52009-03-10 21:53:08315else
[email protected]ba48c4ca2013-10-25 16:11:46316 echo "Skipping debugging symbols."
[email protected]8ada8c52009-03-10 21:53:08317 dbg_list=
318fi
319
johnme49bb458a2014-11-27 15:45:31320if test "$do_inst_lib32" = "1" ; then
321 echo "Including 32-bit libraries for ARM/Android."
322else
323 echo "Skipping 32-bit libraries for ARM/Android."
324 lib32_list=
[email protected]9f28a9cf2012-12-17 23:31:40325fi
326
[email protected]ba48c4ca2013-10-25 16:11:46327if test "$do_inst_arm" = "1" ; then
[email protected]ba48c4ca2013-10-25 16:11:46328 echo "Including ARM cross toolchain."
[email protected]f2826b6a2012-11-15 01:06:26329else
[email protected]ba48c4ca2013-10-25 16:11:46330 echo "Skipping ARM cross toolchain."
[email protected]f2826b6a2012-11-15 01:06:26331 arm_list=
332fi
333
[email protected]565416362014-01-16 21:26:47334if test "$do_inst_nacl" = "1"; then
[email protected]713eac62014-06-02 23:10:03335 echo "Including NaCl, NaCl toolchain, NaCl ports dependencies."
[email protected]565416362014-01-16 21:26:47336else
[email protected]713eac62014-06-02 23:10:03337 echo "Skipping NaCl, NaCl toolchain, NaCl ports dependencies."
[email protected]565416362014-01-16 21:26:47338 nacl_list=
339fi
340
johnme4bd10302015-01-06 11:25:52341# The `sort -r -s -t: -k2` sorts all the :i386 packages to the front, to avoid
342# confusing dpkg-query (crbug.com/446172).
[email protected]565416362014-01-16 21:26:47343packages="$(
johnme49bb458a2014-11-27 15:45:31344 echo "${dev_list} ${lib_list} ${dbg_list} ${lib32_list} ${arm_list}"\
johnme4bd10302015-01-06 11:25:52345 "${nacl_list}" | tr " " "\n" | sort -u | sort -r -s -t: -k2 | tr "\n" " "
[email protected]565416362014-01-16 21:26:47346)"
[email protected]ba48c4ca2013-10-25 16:11:46347
348if [ 1 -eq "${do_quick_check-0}" ] ; then
349 failed_check="$(dpkg-query -W -f '${PackageSpec}:${Status}\n' \
350 ${packages} 2>&1 | grep -v "ok installed" || :)"
351 if [ -n "${failed_check}" ]; then
352 echo
353 nomatch="$(echo "${failed_check}" | \
354 sed -e "s/^No packages found matching \(.*\).$/\1/;t;d")"
355 missing="$(echo "${failed_check}" | \
356 sed -e "/^No packages found matching/d;s/^\(.*\):.*$/\1/")"
357 if [ "$nomatch" ]; then
358 # Distinguish between packages that actually aren't available to the
359 # system (i.e. not in any repo) and packages that just aren't known to
360 # dpkg (i.e. managed by apt).
361 unknown=""
362 for p in ${nomatch}; do
363 if apt-cache show ${p} > /dev/null 2>&1; then
364 missing="${p}\n${missing}"
365 else
366 unknown="${p}\n${unknown}"
367 fi
368 done
369 if [ -n "${unknown}" ]; then
370 echo "WARNING: The following packages are unknown to your system"
371 echo "(maybe missing a repo or need to 'sudo apt-get update'):"
372 echo -e "${unknown}" | sed -e "s/^/ /"
373 fi
374 fi
375 if [ -n "${missing}" ]; then
376 echo "WARNING: The following packages are not installed:"
377 echo -e "${missing}" | sed -e "s/^/ /"
378 fi
379 exit 1
380 fi
381 exit 0
382fi
383
johnme49bb458a2014-11-27 15:45:31384if test "$do_inst_lib32" = "1" || test "$do_inst_nacl" = "1"; then
thestig83d03502015-03-20 08:06:12385 if [[ ! $lsb_release =~ (precise) ]]; then
johnme49bb458a2014-11-27 15:45:31386 sudo dpkg --add-architecture i386
387 fi
388fi
sbc42564092015-04-01 01:01:28389sudo apt-get update
[email protected]e041ed12009-03-10 16:43:01390
391# We initially run "apt-get" with the --reinstall option and parse its output.
392# This way, we can find all the packages that need to be newly installed
393# without accidentally promoting any packages from "auto" to "manual".
394# We then re-run "apt-get" with just the list of missing packages.
395echo "Finding missing packages..."
[email protected]757c2962012-03-15 19:05:18396# Intentionally leaving $packages unquoted so it's more readable.
[email protected]b6e064522009-08-10 18:47:51397echo "Packages required: " $packages
398echo
[email protected]79a9d2962009-08-06 21:10:58399new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
[email protected]c3d8b152013-05-10 10:10:03400if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then
[email protected]b6e064522009-08-10 18:47:51401 # We probably never hit this following line.
[email protected]79a9d2962009-08-06 21:10:58402 echo "No missing packages, and the packages are up-to-date."
[email protected]b62f11e72010-05-03 17:20:45403elif [ $? -eq 1 ]; then
[email protected]79a9d2962009-08-06 21:10:58404 # We expect apt-get to have exit status of 1.
[email protected]757c2962012-03-15 19:05:18405 # This indicates that we cancelled the install with "yes n|".
[email protected]b6e064522009-08-10 18:47:51406 new_list=$(echo "$new_list" |
[email protected]79a9d2962009-08-06 21:10:58407 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
[email protected]b6e064522009-08-10 18:47:51408 new_list=$(echo "$new_list" | sed 's/ *$//')
409 if [ -z "$new_list" ] ; then
410 echo "No missing packages, and the packages are up-to-date."
411 else
412 echo "Installing missing packages: $new_list."
[email protected]e2544ed42012-04-23 04:48:31413 sudo apt-get install ${do_quietly-} ${new_list}
[email protected]b6e064522009-08-10 18:47:51414 fi
415 echo
[email protected]79a9d2962009-08-06 21:10:58416else
417 # An apt-get exit status of 100 indicates that a real error has occurred.
[email protected]e041ed12009-03-10 16:43:01418
[email protected]79a9d2962009-08-06 21:10:58419 # I am intentionally leaving out the '"'s around new_list_cmd,
420 # as this makes it easier to cut and paste the output
[email protected]79a9d2962009-08-06 21:10:58421 echo "The following command failed: " ${new_list_cmd}
422 echo
423 echo "It produces the following output:"
424 yes n | $new_list_cmd || true
425 echo
426 echo "You will have to install the above packages yourself."
427 echo
428 exit 100
429fi
[email protected]e041ed12009-03-10 16:43:01430
[email protected]d96cc3472013-09-19 00:53:30431# Install the Chrome OS default fonts. This must go after running
432# apt-get, since install-chromeos-fonts depends on curl.
433if test "$do_inst_chromeos_fonts" != "0"; then
434 echo
435 echo "Installing Chrome OS fonts."
436 dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
437 if ! sudo $dir/linux/install-chromeos-fonts.py; then
438 echo "ERROR: The installation of the Chrome OS default fonts failed."
439 if [ `stat -f -c %T $dir` == "nfs" ]; then
440 echo "The reason is that your repo is installed on a remote file system."
441 else
442 echo "This is expected if your repo is installed on a remote file system."
443 fi
444 echo "It is recommended to install your repo on a local file system."
445 echo "You can skip the installation of the Chrome OS default founts with"
446 echo "the command line option: --no-chromeos-fonts."
447 exit 1
448 fi
449else
450 echo "Skipping installation of Chrome OS fonts."
451fi
452
sbc6ab44c32015-02-13 23:19:17453# $1 - target name
454# $2 - link name
455create_library_symlink() {
456 target=$1
457 linkname=$2
458 if [ -L $linkname ]; then
459 if [ "$(basename $(readlink $linkname))" != "$(basename $target)" ]; then
460 sudo rm $linkname
461 fi
462 fi
463 if [ ! -r $linkname ]; then
464 echo "Creating link: $linkname"
465 sudo ln -fs $target $linkname
466 fi
467}
468
[email protected]713eac62014-06-02 23:10:03469if test "$do_inst_nacl" = "1"; then
470 echo "Installing symbolic links for NaCl."
sbc6ab44c32015-02-13 23:19:17471 # naclports needs to cross build python for i386, but libssl1.0.0:i386
472 # only contains libcrypto.so.1.0.0 and not the symlink needed for
473 # linking (libcrypto.so).
474 create_library_symlink /lib/i386-linux-gnu/libcrypto.so.1.0.0 \
475 /usr/lib/i386-linux-gnu/libcrypto.so
476
477 create_library_symlink /lib/i386-linux-gnu/libssl.so.1.0.0 \
478 /usr/lib/i386-linux-gnu/libssl.so
[email protected]713eac62014-06-02 23:10:03479else
480 echo "Skipping symbolic links for NaCl."
481fi