15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#!/bin/bash -e
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Copyright (c) 2012 The Chromium Authors. All rights reserved.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# found in the LICENSE file.
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Script to install everything needed to build chromium (well, ideally, anyway)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)usage() {
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "Usage: $0 [--options]"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "Options:"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "--[no-]syms: enable or disable installation of debugging symbols"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  echo "--[no-]arm: enable or disable installation of arm cross toolchain"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)       "fonts"
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  echo "--[no-]nacl: enable or disable installation of prerequisites for"\
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)       "building standalone NaCl and all its toolchains"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "--no-prompt: silently select standard options/defaults"
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "--quick-check: quickly try to determine if dependencies are installed"
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "               (this avoids interactive prompts and sudo commands,"
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "               so might not be 100% accurate)"
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "--unsupported: attempt installation even on unsupported systems"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "Script will prompt interactively if options not given."
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  exit 1
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# Checks whether a particular package is available in the repos.
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)# USAGE: $ package_exists <package name>
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)package_exists() {
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  apt-cache pkgnames | grep -x "$1" > /dev/null 2>&1
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# These default to on because (some) bots need them and it keeps things
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# simple for the bot setup if all bots just run the script in its default
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# mode.  Developers who don't want stuff they don't need installed on their
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# own workstations can pass --no-arm --no-nacl when running the script.
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)do_inst_arm=1
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)do_inst_nacl=1
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)while test "$1" != ""
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)do
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  case "$1" in
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  --syms)                   do_inst_syms=1;;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  --no-syms)                do_inst_syms=0;;
4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  # TODO(phajdan.jr): Remove the lib32 flags when nothing else refers to them.
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  --lib32)                  do_inst_lib32=1;;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  --no-lib32)               do_inst_lib32=0;;
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  --arm)                    do_inst_arm=1;;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  --no-arm)                 do_inst_arm=0;;
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  --chromeos-fonts)         do_inst_chromeos_fonts=1;;
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  --no-chromeos-fonts)      do_inst_chromeos_fonts=0;;
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  --nacl)                   do_inst_nacl=1;;
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  --no-nacl)                do_inst_nacl=0;;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  --no-prompt)              do_default=1
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            do_quietly="-qq --assume-yes"
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ;;
591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  --quick-check)            do_quick_check=1;;
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  --unsupported)            do_unsupported=1;;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  *) usage;;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  esac
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  shift
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)done
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
66cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)# Check for lsb_release command in $PATH
67cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)if ! which lsb_release > /dev/null; then
68cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  echo "ERROR: lsb_release not found in \$PATH" >&2
69cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  exit 1;
70cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)fi
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)lsb_release=$(lsb_release --codename --short)
73cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)ubuntu_codenames="(precise|quantal|raring|saucy|trusty)"
741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then
75cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if [[ ! $lsb_release =~ $ubuntu_codenames ]]; then
76cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    echo "ERROR: Only Ubuntu 12.04 (precise) through 14.04 (trusty) are"\
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        "currently supported" >&2
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    exit 1
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  fi
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if ! uname -m | egrep -q "i686|x86_64"; then
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    echo "Only x86 architectures are currently supported" >&2
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    exit
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  fi
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "Running as non-root user."
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "You might have to enter your password one or more times for 'sudo'."
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Packages needed for chromeos only
9403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)chromeos_dev_list="libbluetooth-dev libxkbcommon-dev"
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
96f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)# Packages needed for development
971320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccidev_list="apache2.2-bin bison cdbs curl dpkg-dev elfutils devscripts fakeroot
981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          flex fonts-thai-tlwg g++ git-core git-svn gperf language-pack-da
9903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          language-pack-fr language-pack-he language-pack-zh-hant
10003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libapache2-mod-php5 libasound2-dev libbrlapi-dev libav-tools
10103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev
10203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libdrm-dev libelf-dev libexif-dev libgconf2-dev libgl1-mesa-dev
10303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev
10403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev
10503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev
10603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev
107116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch          mesa-common-dev openbox patch perl php5-cgi pkg-config python
1081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          python-cherrypy3 python-crypto python-dev python-openssl
1091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          python-psutil rpm ruby subversion ttf-dejavu-core ttf-indic-fonts
1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          ttf-kochi-gothic ttf-kochi-mincho wdiff xfonts-mathml zip
1111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          $chromeos_dev_list"
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
11403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)# NaCl binaries.
1150f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)if file /sbin/init | grep -q 'ELF 64-bit'; then
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Run-time libraries required by chromeos only
1201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)chromeos_lib_list="libpulse0 libbz2-1.0"
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Full list of required run-time libraries
1231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1
124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)          libexif12 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0
12690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)          libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libx11-6
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          libxtst6 zlib1g $chromeos_lib_list"
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Debugging symbols for all of the run-time libraries
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
137f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)          libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg
138f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)          libstdc++6-4.6-dbg"
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# arm cross toolchain packages needed to build chrome on armhf
141cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)arm_list="libc6-dev-armhf-cross
142cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)          linux-libc-dev-armhf-cross
1431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          g++-arm-linux-gnueabihf
1441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          linux-libc-dev:i386"
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)# Packages to build NaCl, its toolchains, and its ports.
1471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinaclports_list="ant autoconf bison cmake gawk intltool xutils-dev xsltproc"
1481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinacl_list="g++-mingw-w64-i686 lib32z1-dev
1496d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)           libasound2:i386 libcap2:i386 libelf-dev:i386 libexif12:i386
1506d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)           libfontconfig1:i386 libgconf-2-4:i386 libglib2.0-0:i386 libgpm2:i386
1515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)           libgtk2.0-0:i386 libncurses5:i386 lib32ncurses5-dev
1521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci           libnss3:i386 libpango1.0-0:i386
1536d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)           libssl0.9.8:i386 libtinfo-dev libtinfo-dev:i386 libtool
1546d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)           libxcomposite1:i386 libxcursor1:i386 libxdamage1:i386 libxi6:i386
1551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci           libxrandr2:i386 libxss1:i386 libxtst6:i386 texinfo xvfb
1561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci           ${naclports_list}"
1576d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
1586d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)# Find the proper version of libgbm-dev. We can't just install libgbm-dev as
1596d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)# it depends on mesa, and only one version of mesa can exists on the system.
1606d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)# Hence we must match the same version or this entire script will fail.
1616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)mesa_variant=""
1621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccifor variant in "-lts-quantal" "-lts-raring" "-lts-saucy" "-lts-trusty"; do
1636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  if $(dpkg-query -Wf'${Status}' libgl1-mesa-glx${variant} | \
1646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)       grep -q " ok installed"); then
1656d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)    mesa_variant="${variant}"
1666d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  fi
1676d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)done
168116680a4aac90f2aa7413d9095a592090648e557Ben Murdochdev_list="${dev_list} libgbm-dev${mesa_variant}
169116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch          libgles2-mesa-dev${mesa_variant}"
1706d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)nacl_list="${nacl_list} libgl1-mesa-glx${mesa_variant}:i386"
1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Some package names have changed over time
173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if package_exists ttf-mscorefonts-installer; then
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dev_list="${dev_list} ttf-mscorefonts-installer"
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)else
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dev_list="${dev_list} msttcorefonts"
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
178868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if package_exists libnspr4-dbg; then
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  lib_list="${lib_list} libnspr4 libnss3"
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)else
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  lib_list="${lib_list} libnspr4-0d libnss3-1d"
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
185868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if package_exists libjpeg-dev; then
18690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  dev_list="${dev_list} libjpeg-dev"
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)else
18890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  dev_list="${dev_list} libjpeg62-dev"
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
190868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if package_exists libudev1; then
19190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  dev_list="${dev_list} libudev1"
19246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  nacl_list="${nacl_list} libudev1:i386"
19390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)else
19490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  dev_list="${dev_list} libudev0"
19546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  nacl_list="${nacl_list} libudev0:i386"
19690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)fi
19758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)if package_exists libbrlapi0.6; then
19858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  dev_list="${dev_list} libbrlapi0.6"
19958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)else
20058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  dev_list="${dev_list} libbrlapi0.5"
20158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)fi
20290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2044e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)# Some packages are only needed if the distribution actually supports
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# installing them.
206868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)if package_exists appmenu-gtk; then
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  lib_list="$lib_list appmenu-gtk"
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# been provided to yes_no(), the function also accepts RETURN as a user input.
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# The parameter specifies the exit code that should be returned in that case.
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# The function will echo the user's selection followed by a newline character.
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Users can abort the function by pressing CTRL-C. This will call "exit 1".
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)yes_no() {
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if [ 0 -ne "${do_default-0}" ] ; then
2184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    [ $1 -eq 0 ] && echo "Y" || echo "N"
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return $1
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  fi
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  local c
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  while :; do
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         stty -echo iuclc -icanon 2>/dev/null
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)         dd count=1 bs=1 2>/dev/null | od -An -tx1)"
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    case "$c" in
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      " 0a") if [ -n "$1" ]; then
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)               [ $1 -eq 0 ] && echo "Y" || echo "N"
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)               return $1
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             fi
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             ;;
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      " 79") echo "Y"
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             return 0
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             ;;
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      " 6e") echo "N"
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             return 1
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             ;;
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      "")    echo "Aborted" >&2
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             exit 1
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             ;;
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      *)     # The user pressed an unrecognized key. As we are not echoing
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             # any incorrect user input, alert the user by ringing the bell.
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             (tput bel) 2>/dev/null
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)             ;;
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    esac
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  done
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0}
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)then
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "This script installs all tools and libraries needed to build Chromium."
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo ""
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "For most of the libraries, it can also install debugging symbols, which"
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "will allow you to debug code in the system libraries. Most developers"
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "won't need these symbols."
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo -n "Do you want me to install them for you (y/N) "
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if yes_no 1; then
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    do_inst_syms=1
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  fi
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)if test "$do_inst_syms" = "1"; then
2621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "Including debugging symbols."
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)else
2641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "Skipping debugging symbols."
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  dbg_list=
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# When cross building for arm on 64-bit systems the host binaries
2692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# that are part of v8 need to be compiled with -m32 which means
2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# that basic multilib support is needed.
2710f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)if file /sbin/init | grep -q 'ELF 64-bit'; then
272cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  if [ "$lsb_release" = "trusty" ]; then
273cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    # gcc-multilib conflicts with the arm cross compiler in trusty but
274cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    # g++-4.8-multilib gives us the 32-bit support that we need.
275cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    arm_list="$arm_list g++-4.8-multilib"
276cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  else
277cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    arm_list="$arm_list g++-multilib"
278cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  fi
2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)fi
2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)if test "$do_inst_arm" = "1" ; then
2821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "Including ARM cross toolchain."
2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)else
2841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  echo "Skipping ARM cross toolchain."
2852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  arm_list=
2862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)fi
2872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)if test "$do_inst_nacl" = "1"; then
28946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  echo "Including NaCl, NaCl toolchain, NaCl ports dependencies."
2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)else
29146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  echo "Skipping NaCl, NaCl toolchain, NaCl ports dependencies."
2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  nacl_list=
2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)fi
2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)packages="$(
2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  echo "${dev_list} ${lib_list} ${dbg_list} ${arm_list} ${nacl_list}" |
2975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  tr " " "\n" | sort -u | tr "\n" " "
2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles))"
2991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
3001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)if [ 1 -eq "${do_quick_check-0}" ] ; then
3011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  failed_check="$(dpkg-query -W -f '${PackageSpec}:${Status}\n' \
3021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    ${packages} 2>&1 | grep -v "ok installed" || :)"
3031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  if [ -n "${failed_check}" ]; then
3041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    echo
3051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    nomatch="$(echo "${failed_check}" | \
3061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      sed -e "s/^No packages found matching \(.*\).$/\1/;t;d")"
3071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    missing="$(echo "${failed_check}" | \
3081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      sed -e "/^No packages found matching/d;s/^\(.*\):.*$/\1/")"
3091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    if [ "$nomatch" ]; then
3101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      # Distinguish between packages that actually aren't available to the
3111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      # system (i.e. not in any repo) and packages that just aren't known to
3121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      # dpkg (i.e. managed by apt).
3131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      unknown=""
3141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      for p in ${nomatch}; do
3151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        if apt-cache show ${p} > /dev/null 2>&1; then
3161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)          missing="${p}\n${missing}"
3171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        else
3181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)          unknown="${p}\n${unknown}"
3191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        fi
3201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      done
3211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      if [ -n "${unknown}" ]; then
3221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        echo "WARNING: The following packages are unknown to your system"
3231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        echo "(maybe missing a repo or need to 'sudo apt-get update'):"
3241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        echo -e "${unknown}" | sed -e "s/^/  /"
3251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      fi
3261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    fi
3271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    if [ -n "${missing}" ]; then
3281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      echo "WARNING: The following packages are not installed:"
3291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      echo -e "${missing}" | sed -e "s/^/  /"
3301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    fi
3311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    exit 1
3321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  fi
3331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  exit 0
3341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)fi
3351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)sudo apt-get update
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# We initially run "apt-get" with the --reinstall option and parse its output.
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# This way, we can find all the packages that need to be newly installed
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# without accidentally promoting any packages from "auto" to "manual".
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# We then re-run "apt-get" with just the list of missing packages.
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)echo "Finding missing packages..."
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Intentionally leaving $packages unquoted so it's more readable.
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)echo "Packages required: " $packages
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)echo
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
347b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  # We probably never hit this following line.
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "No missing packages, and the packages are up-to-date."
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)elif [ $? -eq 1 ]; then
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  # We expect apt-get to have exit status of 1.
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  # This indicates that we cancelled the install with "yes n|".
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  new_list=$(echo "$new_list" |
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    sed -e '1,/The following NEW packages will be installed:/d;s/^  //;t;d')
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  new_list=$(echo "$new_list" | sed 's/ *$//')
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if [ -z "$new_list" ] ; then
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    echo "No missing packages, and the packages are up-to-date."
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  else
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    echo "Installing missing packages: $new_list."
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    sudo apt-get install ${do_quietly-} ${new_list}
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  fi
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)else
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  # An apt-get exit status of 100 indicates that a real error has occurred.
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  # I am intentionally leaving out the '"'s around new_list_cmd,
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  # as this makes it easier to cut and paste the output
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "The following command failed: " ${new_list_cmd}
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "It produces the following output:"
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  yes n | $new_list_cmd || true
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo "You will have to install the above packages yourself."
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  echo
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  exit 100
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fi
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
378d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# Install the Chrome OS default fonts. This must go after running
379d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)# apt-get, since install-chromeos-fonts depends on curl.
380d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)if test "$do_inst_chromeos_fonts" != "0"; then
381d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  echo
382d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  echo "Installing Chrome OS fonts."
383d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
384d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  if ! sudo $dir/linux/install-chromeos-fonts.py; then
385d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    echo "ERROR: The installation of the Chrome OS default fonts failed."
386d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    if [ `stat -f -c %T $dir` == "nfs" ]; then
387d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      echo "The reason is that your repo is installed on a remote file system."
388d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    else
389d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      echo "This is expected if your repo is installed on a remote file system."
390d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    fi
391d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    echo "It is recommended to install your repo on a local file system."
392d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    echo "You can skip the installation of the Chrome OS default founts with"
393d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    echo "the command line option: --no-chromeos-fonts."
394d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    exit 1
395d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  fi
396d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)else
397d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  echo "Skipping installation of Chrome OS fonts."
398d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)fi
399d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
40046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)if test "$do_inst_nacl" = "1"; then
40146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  echo "Installing symbolic links for NaCl."
40246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  if [ ! -r /usr/lib/i386-linux-gnu/libcrypto.so ]; then
40346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)    sudo ln -fs libcrypto.so.0.9.8 /usr/lib/i386-linux-gnu/libcrypto.so
40446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  fi
40546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  if [ ! -r /usr/lib/i386-linux-gnu/libssl.so ]; then
40646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)    sudo ln -fs libssl.so.0.9.8 /usr/lib/i386-linux-gnu/libssl.so
40746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  fi
40846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)else
40946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  echo "Skipping symbolic links for NaCl."
41046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)fi
411