[M73 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / build / install-build-deps.sh
1 #!/bin/bash -e
2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Script to install everything needed to build chromium (well, ideally, anyway)
8 # See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_instructions.md
9
10 usage() {
11   echo "Usage: $0 [--options]"
12   echo "Options:"
13   echo "--[no-]syms: enable or disable installation of debugging symbols"
14   echo "--lib32: enable installation of 32-bit libraries, e.g. for V8 snapshot"
15   echo "--[no-]arm: enable or disable installation of arm cross toolchain"
16   echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
17        "fonts"
18   echo "--[no-]nacl: enable or disable installation of prerequisites for"\
19        "building standalone NaCl and all its toolchains"
20   echo "--[no-]backwards-compatible: enable or disable installation of packages
21         that are no longer currently needed and have been removed from this
22         script.  Useful for bisection."
23   echo "--no-prompt: silently select standard options/defaults"
24   echo "--quick-check: quickly try to determine if dependencies are installed"
25   echo "               (this avoids interactive prompts and sudo commands,"
26   echo "               so might not be 100% accurate)"
27   echo "--unsupported: attempt installation even on unsupported systems"
28   echo "Script will prompt interactively if options not given."
29   exit 1
30 }
31
32 # Checks whether a particular package is available in the repos.
33 # USAGE: $ package_exists <package name>
34 package_exists() {
35   # 'apt-cache search' takes a regex string, so eg. the +'s in packages like
36   # "libstdc++" need to be escaped.
37   local escaped="$(echo $1 | sed 's/[\~\+\.\:-]/\\&/g')"
38   [ ! -z "$(apt-cache search --names-only "${escaped}" | \
39             awk '$1 == "'$1'" { print $1; }')" ]
40 }
41
42 # These default to on because (some) bots need them and it keeps things
43 # simple for the bot setup if all bots just run the script in its default
44 # mode.  Developers who don't want stuff they don't need installed on their
45 # own workstations can pass --no-arm --no-nacl when running the script.
46 do_inst_arm=1
47 do_inst_nacl=1
48
49 while [ "$1" != "" ]
50 do
51   case "$1" in
52   --syms)                    do_inst_syms=1;;
53   --no-syms)                 do_inst_syms=0;;
54   --lib32)                   do_inst_lib32=1;;
55   --arm)                     do_inst_arm=1;;
56   --no-arm)                  do_inst_arm=0;;
57   --chromeos-fonts)          do_inst_chromeos_fonts=1;;
58   --no-chromeos-fonts)       do_inst_chromeos_fonts=0;;
59   --nacl)                    do_inst_nacl=1;;
60   --no-nacl)                 do_inst_nacl=0;;
61   --backwards-compatible)    do_inst_backwards_compatible=1;;
62   --no-backwards-compatible) do_inst_backwards_compatible=0;;
63   --add-cross-tool-repo)     add_cross_tool_repo=1;;
64   --no-prompt)               do_default=1
65                              do_quietly="-qq --assume-yes"
66     ;;
67   --quick-check)             do_quick_check=1;;
68   --unsupported)             do_unsupported=1;;
69   *) usage;;
70   esac
71   shift
72 done
73
74 if [ "$do_inst_arm" = "1" ]; then
75   do_inst_lib32=1
76 fi
77
78 # Check for lsb_release command in $PATH
79 if ! which lsb_release > /dev/null; then
80   echo "ERROR: lsb_release not found in \$PATH" >&2
81   exit 1;
82 fi
83
84 distro_codename=$(lsb_release --codename --short)
85 distro_id=$(lsb_release --id --short)
86 supported_codenames="(trusty|xenial|artful|bionic)"
87 supported_ids="(Debian)"
88 if [ 0 -eq "${do_unsupported-0}" ] && [ 0 -eq "${do_quick_check-0}" ] ; then
89   if [[ ! $distro_codename =~ $supported_codenames &&
90         ! $distro_id =~ $supported_ids ]]; then
91     echo -e "ERROR: The only supported distros are\n" \
92       "\tUbuntu 14.04 LTS (trusty)\n" \
93       "\tUbuntu 16.04 LTS (xenial)\n" \
94       "\tUbuntu 17.10 (artful)\n" \
95       "\tUbuntu 18.04 LTS (bionic)\n" \
96       "\tDebian 8 (jessie) or later" >&2
97     exit 1
98   fi
99
100   if ! uname -m | egrep -q "i686|x86_64"; then
101     echo "Only x86 architectures are currently supported" >&2
102     exit
103   fi
104 fi
105
106 if [ "x$(id -u)" != x0 ] && [ 0 -eq "${do_quick_check-0}" ]; then
107   echo "Running as non-root user."
108   echo "You might have to enter your password one or more times for 'sudo'."
109   echo
110 fi
111
112 # Packages needed for chromeos only
113 chromeos_dev_list="libbluetooth-dev libxkbcommon-dev"
114
115 if package_exists realpath; then
116   chromeos_dev_list="${chromeos_dev_list} realpath"
117 fi
118
119 # Packages needed for development
120 dev_list="\
121   binutils
122   bison
123   bzip2
124   cdbs
125   curl
126   dbus-x11
127   dpkg-dev
128   elfutils
129   devscripts
130   fakeroot
131   flex
132   g++
133   git-core
134   git-svn
135   gperf
136   libappindicator3-dev
137   libasound2-dev
138   libatspi2.0-dev
139   libbrlapi-dev
140   libbz2-dev
141   libcairo2-dev
142   libcap-dev
143   libcups2-dev
144   libcurl4-gnutls-dev
145   libdrm-dev
146   libelf-dev
147   libffi-dev
148   libgbm-dev
149   libglib2.0-dev
150   libglu1-mesa-dev
151   libgnome-keyring-dev
152   libgtk-3-dev
153   libkrb5-dev
154   libnspr4-dev
155   libnss3-dev
156   libpam0g-dev
157   libpci-dev
158   libpulse-dev
159   libsctp-dev
160   libspeechd-dev
161   libsqlite3-dev
162   libssl-dev
163   libudev-dev
164   libwww-perl
165   libxslt1-dev
166   libxss-dev
167   libxt-dev
168   libxtst-dev
169   locales
170   openbox
171   p7zip
172   patch
173   perl
174   pkg-config
175   python
176   python-cherrypy3
177   python-crypto
178   python-dev
179   python-numpy
180   python-opencv
181   python-openssl
182   python-psutil
183   python-yaml
184   rpm
185   ruby
186   subversion
187   uuid-dev
188   wdiff
189   x11-utils
190   xcompmgr
191   xz-utils
192   zip
193   $chromeos_dev_list
194 "
195
196 # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
197 # NaCl binaries.
198 if file -L /sbin/init | grep -q 'ELF 64-bit'; then
199   dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
200 fi
201
202 # Run-time libraries required by chromeos only
203 chromeos_lib_list="libpulse0 libbz2-1.0"
204
205 # List of required run-time libraries
206 common_lib_list="\
207   libappindicator3-1
208   libasound2
209   libatk1.0-0
210   libatspi2.0-0
211   libc6
212   libcairo2
213   libcap2
214   libcups2
215   libexpat1
216   libffi6
217   libfontconfig1
218   libfreetype6
219   libglib2.0-0
220   libgnome-keyring0
221   libgtk-3-0
222   libpam0g
223   libpango1.0-0
224   libpci3
225   libpcre3
226   libpixman-1-0
227   libspeechd2
228   libstdc++6
229   libsqlite3-0
230   libuuid1
231   libwayland-egl1-mesa
232   libx11-6
233   libx11-xcb1
234   libxau6
235   libxcb1
236   libxcomposite1
237   libxcursor1
238   libxdamage1
239   libxdmcp6
240   libxext6
241   libxfixes3
242   libxi6
243   libxinerama1
244   libxrandr2
245   libxrender1
246   libxtst6
247   zlib1g
248 "
249
250 # Full list of required run-time libraries
251 lib_list="\
252   $common_lib_list
253   $chromeos_lib_list
254 "
255
256 # 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf
257 lib32_list="linux-libc-dev:i386 libpci3:i386"
258
259 # 32-bit libraries needed for a 32-bit build
260 lib32_list="$lib32_list libx11-xcb1:i386"
261
262 # Packages that have been removed from this script.  Regardless of configuration
263 # or options passed to this script, whenever a package is removed, it should be
264 # added here.
265 backwards_compatible_list="\
266   7za
267   fonts-indic
268   fonts-ipafont
269   fonts-stix
270   fonts-thai-tlwg
271   fonts-tlwg-garuda
272   language-pack-da
273   language-pack-fr
274   language-pack-he
275   language-pack-zh-hant
276   libappindicator-dev
277   libappindicator1
278   libappindicator3-1:i386
279   libdconf-dev
280   libdconf-dev:i386
281   libdconf1
282   libdconf1:i386
283   libexif-dev
284   libexif12
285   libexif12:i386
286   libgbm-dev
287   libgconf-2-4:i386
288   libgconf2-dev
289   libgl1-mesa-dev
290   libgl1-mesa-glx:i386
291   libgles2-mesa-dev
292   libgtk-3-0:i386
293   libgtk2.0-0
294   libgtk2.0-0:i386
295   libgtk2.0-dev
296   mesa-common-dev
297   msttcorefonts
298   ttf-dejavu-core
299   ttf-indic-fonts
300   ttf-kochi-gothic
301   ttf-kochi-mincho
302   ttf-mscorefonts-installer
303   xfonts-mathml
304 "
305 case $distro_codename in
306   trusty)
307     backwards_compatible_list+=" \
308       libgbm-dev-lts-trusty
309       libgl1-mesa-dev-lts-trusty
310       libgl1-mesa-glx-lts-trusty:i386
311       libgles2-mesa-dev-lts-trusty
312       mesa-common-dev-lts-trusty"
313     ;;
314   xenial)
315     backwards_compatible_list+=" \
316       libgbm-dev-lts-xenial
317       libgl1-mesa-dev-lts-xenial
318       libgl1-mesa-glx-lts-xenial:i386
319       libgles2-mesa-dev-lts-xenial
320       mesa-common-dev-lts-xenial"
321     ;;
322 esac
323
324 # arm cross toolchain packages needed to build chrome on armhf
325 EM_REPO="deb http://emdebian.org/tools/debian/ jessie main"
326 EM_SOURCE=$(cat <<EOF
327 # Repo added by Chromium $0
328 ${EM_REPO}
329 # deb-src http://emdebian.org/tools/debian/ jessie main
330 EOF
331 )
332 EM_ARCHIVE_KEY_FINGER="084C6C6F39159EDB67969AA87DE089671804772E"
333 GPP_ARM_PACKAGE="g++-arm-linux-gnueabihf"
334 case $distro_codename in
335   jessie)
336     eval $(apt-config shell APT_SOURCESDIR 'Dir::Etc::sourceparts/d')
337     CROSSTOOLS_LIST="${APT_SOURCESDIR}/crosstools.list"
338     arm_list="libc6-dev:armhf
339               linux-libc-dev:armhf"
340     if [ "$do_inst_arm" = "1" ]; then
341       if $(dpkg-query -W ${GPP_ARM_PACKAGE} &>/dev/null); then
342         arm_list+=" ${GPP_ARM_PACKAGE}"
343       else
344         if [ "${add_cross_tool_repo}" = "1" ]; then
345           gpg --keyserver pgp.mit.edu --recv-keys ${EM_ARCHIVE_KEY_FINGER}
346           gpg -a --export ${EM_ARCHIVE_KEY_FINGER} | sudo apt-key add -
347           if ! grep "^${EM_REPO}" "${CROSSTOOLS_LIST}" &>/dev/null; then
348             echo "${EM_SOURCE}" | sudo tee -a "${CROSSTOOLS_LIST}" >/dev/null
349           fi
350           arm_list+=" ${GPP_ARM_PACKAGE}"
351         else
352           echo "The Debian Cross-toolchains repository is necessary to"
353           echo "cross-compile Chromium for arm."
354           echo "Rerun with --add-deb-cross-tool-repo to have it added for you."
355         fi
356       fi
357     fi
358     ;;
359   # All necessary ARM packages are available on the default repos on
360   # Debian 9 and later.
361   *)
362     arm_list="libc6-dev-armhf-cross
363               linux-libc-dev-armhf-cross
364               ${GPP_ARM_PACKAGE}"
365     ;;
366 esac
367
368 # Work around for dependency issue Ubuntu/Trusty: http://crbug.com/435056
369 case $distro_codename in
370   trusty)
371     arm_list+=" g++-4.8-multilib-arm-linux-gnueabihf
372                 gcc-4.8-multilib-arm-linux-gnueabihf"
373     ;;
374   xenial|artful|bionic)
375     arm_list+=" g++-5-multilib-arm-linux-gnueabihf
376                 gcc-5-multilib-arm-linux-gnueabihf
377                 gcc-arm-linux-gnueabihf"
378     ;;
379 esac
380
381 # Packages to build NaCl, its toolchains, and its ports.
382 naclports_list="ant autoconf bison cmake gawk intltool xutils-dev xsltproc"
383 nacl_list="\
384   g++-mingw-w64-i686
385   lib32z1-dev
386   libasound2:i386
387   libcap2:i386
388   libelf-dev:i386
389   libfontconfig1:i386
390   libglib2.0-0:i386
391   libgpm2:i386
392   libncurses5:i386
393   lib32ncurses5-dev
394   libnss3:i386
395   libpango1.0-0:i386
396   libssl-dev:i386
397   libtinfo-dev
398   libtinfo-dev:i386
399   libtool
400   libuuid1:i386
401   libxcomposite1:i386
402   libxcursor1:i386
403   libxdamage1:i386
404   libxi6:i386
405   libxrandr2:i386
406   libxss1:i386
407   libxtst6:i386
408   texinfo
409   xvfb
410   ${naclports_list}
411 "
412
413 if package_exists libssl1.1; then
414   nacl_list="${nacl_list} libssl1.1:i386"
415 elif package_exists libssl1.0.2; then
416   nacl_list="${nacl_list} libssl1.0.2:i386"
417 else
418   nacl_list="${nacl_list} libssl1.0.0:i386"
419 fi
420
421 # Some package names have changed over time
422 if package_exists libpng16-16; then
423   lib_list="${lib_list} libpng16-16"
424 else
425   lib_list="${lib_list} libpng12-0"
426 fi
427 if package_exists libnspr4; then
428   lib_list="${lib_list} libnspr4 libnss3"
429 else
430   lib_list="${lib_list} libnspr4-0d libnss3-1d"
431 fi
432 if package_exists libjpeg-dev; then
433   dev_list="${dev_list} libjpeg-dev"
434 else
435   dev_list="${dev_list} libjpeg62-dev"
436 fi
437 if package_exists libudev1; then
438   dev_list="${dev_list} libudev1"
439   nacl_list="${nacl_list} libudev1:i386"
440 else
441   dev_list="${dev_list} libudev0"
442   nacl_list="${nacl_list} libudev0:i386"
443 fi
444 if package_exists libbrlapi0.6; then
445   dev_list="${dev_list} libbrlapi0.6"
446 else
447   dev_list="${dev_list} libbrlapi0.5"
448 fi
449 if package_exists apache2.2-bin; then
450   dev_list="${dev_list} apache2.2-bin"
451 else
452   dev_list="${dev_list} apache2-bin"
453 fi
454 if package_exists libav-tools; then
455   dev_list="${dev_list} libav-tools"
456 fi
457 if package_exists php7.2-cgi; then
458   dev_list="${dev_list} php7.2-cgi libapache2-mod-php7.2"
459 elif package_exists php7.1-cgi; then
460   dev_list="${dev_list} php7.1-cgi libapache2-mod-php7.1"
461 elif package_exists php7.0-cgi; then
462   dev_list="${dev_list} php7.0-cgi libapache2-mod-php7.0"
463 else
464   dev_list="${dev_list} php5-cgi libapache2-mod-php5"
465 fi
466
467 # Some packages are only needed if the distribution actually supports
468 # installing them.
469 if package_exists appmenu-gtk; then
470   lib_list="$lib_list appmenu-gtk"
471 fi
472
473 # Cross-toolchain strip is needed for building the sysroots.
474 if package_exists binutils-arm-linux-gnueabihf; then
475   dev_list="${dev_list} binutils-arm-linux-gnueabihf"
476 fi
477 if package_exists binutils-aarch64-linux-gnu; then
478   dev_list="${dev_list} binutils-aarch64-linux-gnu"
479 fi
480 if package_exists binutils-mipsel-linux-gnu; then
481   dev_list="${dev_list} binutils-mipsel-linux-gnu"
482 fi
483 if package_exists binutils-mips64el-linux-gnuabi64; then
484   dev_list="${dev_list} binutils-mips64el-linux-gnuabi64"
485 fi
486
487 # When cross building for arm/Android on 64-bit systems the host binaries
488 # that are part of v8 need to be compiled with -m32 which means
489 # that basic multilib support is needed.
490 if file -L /sbin/init | grep -q 'ELF 64-bit'; then
491   # gcc-multilib conflicts with the arm cross compiler (at least in trusty) but
492   # g++-X.Y-multilib gives us the 32-bit support that we need. Find out the
493   # appropriate value of X and Y by seeing what version the current
494   # distribution's g++-multilib package depends on.
495   multilib_package=$(apt-cache depends g++-multilib --important | \
496       grep -E --color=never --only-matching '\bg\+\+-[0-9.]+-multilib\b')
497   lib32_list="$lib32_list $multilib_package"
498 fi
499
500 if [ "$do_inst_syms" = "1" ]; then
501   echo "Including debugging symbols."
502
503   # Debian is in the process of transitioning to automatic debug packages, which
504   # have the -dbgsym suffix (https://wiki.debian.org/AutomaticDebugPackages).
505   # Untransitioned packages have the -dbg suffix.  And on some systems, neither
506   # will be available, so exclude the ones that are missing.
507   dbg_package_name() {
508     if package_exists "$1-dbgsym"; then
509       echo "$1-dbgsym"
510     elif package_exists "$1-dbg"; then
511       echo "$1-dbg"
512     fi
513   }
514
515   for package in "${common_lib_list}"; do
516     dbg_list="$dbg_list $(dbg_package_name ${package})"
517   done
518
519   # Debugging symbols packages not following common naming scheme
520   if [ "$(dbg_package_name libstdc++6)" == "" ]; then
521     if package_exists libstdc++6-8-dbg; then
522       dbg_list="${dbg_list} libstdc++6-8-dbg"
523     elif package_exists libstdc++6-7-dbg; then
524       dbg_list="${dbg_list} libstdc++6-7-dbg"
525     elif package_exists libstdc++6-6-dbg; then
526       dbg_list="${dbg_list} libstdc++6-6-dbg"
527     elif package_exists libstdc++6-5-dbg; then
528       dbg_list="${dbg_list} libstdc++6-5-dbg"
529     elif package_exists libstdc++6-4.9-dbg; then
530       dbg_list="${dbg_list} libstdc++6-4.9-dbg"
531     elif package_exists libstdc++6-4.8-dbg; then
532       dbg_list="${dbg_list} libstdc++6-4.8-dbg"
533     elif package_exists libstdc++6-4.7-dbg; then
534       dbg_list="${dbg_list} libstdc++6-4.7-dbg"
535     elif package_exists libstdc++6-4.6-dbg; then
536       dbg_list="${dbg_list} libstdc++6-4.6-dbg"
537     fi
538   fi
539   if [ "$(dbg_package_name libatk1.0-0)" == "" ]; then
540     dbg_list="$dbg_list $(dbg_package_name libatk1.0)"
541   fi
542   if [ "$(dbg_package_name libpango1.0-0)" == "" ]; then
543     dbg_list="$dbg_list $(dbg_package_name libpango1.0-dev)"
544   fi
545 else
546   echo "Skipping debugging symbols."
547   dbg_list=
548 fi
549
550 if [ "$do_inst_lib32" = "1" ]; then
551   echo "Including 32-bit libraries."
552 else
553   echo "Skipping 32-bit libraries."
554   lib32_list=
555 fi
556
557 if [ "$do_inst_arm" = "1" ]; then
558   echo "Including ARM cross toolchain."
559 else
560   echo "Skipping ARM cross toolchain."
561   arm_list=
562 fi
563
564 if [ "$do_inst_nacl" = "1" ]; then
565   echo "Including NaCl, NaCl toolchain, NaCl ports dependencies."
566 else
567   echo "Skipping NaCl, NaCl toolchain, NaCl ports dependencies."
568   nacl_list=
569 fi
570
571 filtered_backwards_compatible_list=
572 if [ "$do_inst_backwards_compatible" = "1" ]; then
573   echo "Including backwards compatible packages."
574   for package in ${backwards_compatible_list}; do
575     if package_exists ${package}; then
576       filtered_backwards_compatible_list+=" ${package}"
577     fi
578   done
579 fi
580
581 # The `sort -r -s -t: -k2` sorts all the :i386 packages to the front, to avoid
582 # confusing dpkg-query (crbug.com/446172).
583 packages="$(
584   echo "${dev_list} ${lib_list} ${dbg_list} ${lib32_list} ${arm_list}" \
585        "${nacl_list}" ${filtered_backwards_compatible_list} | tr " " "\n" | \
586        sort -u | sort -r -s -t: -k2 | tr "\n" " "
587 )"
588
589 if [ 1 -eq "${do_quick_check-0}" ] ; then
590   if ! missing_packages="$(dpkg-query -W -f ' ' ${packages} 2>&1)"; then
591     # Distinguish between packages that actually aren't available to the
592     # system (i.e. not in any repo) and packages that just aren't known to
593     # dpkg (i.e. managed by apt).
594     missing_packages="$(echo "${missing_packages}" | awk '{print $NF}')"
595     not_installed=""
596     unknown=""
597     for p in ${missing_packages}; do
598       if apt-cache show ${p} > /dev/null 2>&1; then
599         not_installed="${p}\n${not_installed}"
600       else
601         unknown="${p}\n${unknown}"
602       fi
603     done
604     if [ -n "${not_installed}" ]; then
605       echo "WARNING: The following packages are not installed:"
606       echo -e "${not_installed}" | sed -e "s/^/  /"
607     fi
608     if [ -n "${unknown}" ]; then
609       echo "WARNING: The following packages are unknown to your system"
610       echo "(maybe missing a repo or need to 'sudo apt-get update'):"
611       echo -e "${unknown}" | sed -e "s/^/  /"
612     fi
613     exit 1
614   fi
615   exit 0
616 fi
617
618 if [ "$do_inst_lib32" = "1" ] || [ "$do_inst_nacl" = "1" ]; then
619   sudo dpkg --add-architecture i386
620 fi
621 sudo apt-get update
622
623 # We initially run "apt-get" with the --reinstall option and parse its output.
624 # This way, we can find all the packages that need to be newly installed
625 # without accidentally promoting any packages from "auto" to "manual".
626 # We then re-run "apt-get" with just the list of missing packages.
627 echo "Finding missing packages..."
628 # Intentionally leaving $packages unquoted so it's more readable.
629 echo "Packages required: " $packages
630 echo
631 new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
632 if new_list="$(yes n | LANGUAGE=en LANG=C $new_list_cmd)"; then
633   # We probably never hit this following line.
634   echo "No missing packages, and the packages are up to date."
635 elif [ $? -eq 1 ]; then
636   # We expect apt-get to have exit status of 1.
637   # This indicates that we cancelled the install with "yes n|".
638   new_list=$(echo "$new_list" |
639     sed -e '1,/The following NEW packages will be installed:/d;s/^  //;t;d')
640   new_list=$(echo "$new_list" | sed 's/ *$//')
641   if [ -z "$new_list" ] ; then
642     echo "No missing packages, and the packages are up to date."
643   else
644     echo "Installing missing packages: $new_list."
645     sudo apt-get install ${do_quietly-} ${new_list}
646   fi
647   echo
648 else
649   # An apt-get exit status of 100 indicates that a real error has occurred.
650
651   # I am intentionally leaving out the '"'s around new_list_cmd,
652   # as this makes it easier to cut and paste the output
653   echo "The following command failed: " ${new_list_cmd}
654   echo
655   echo "It produces the following output:"
656   yes n | $new_list_cmd || true
657   echo
658   echo "You will have to install the above packages yourself."
659   echo
660   exit 100
661 fi
662
663 # Install the Chrome OS default fonts. This must go after running
664 # apt-get, since install-chromeos-fonts depends on curl.
665 if [ "$do_inst_chromeos_fonts" != "0" ]; then
666   echo
667   echo "Installing Chrome OS fonts."
668   dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
669   if ! sudo $dir/linux/install-chromeos-fonts.py; then
670     echo "ERROR: The installation of the Chrome OS default fonts failed."
671     if [ `stat -f -c %T $dir` == "nfs" ]; then
672       echo "The reason is that your repo is installed on a remote file system."
673     else
674       echo "This is expected if your repo is installed on a remote file system."
675     fi
676     echo "It is recommended to install your repo on a local file system."
677     echo "You can skip the installation of the Chrome OS default founts with"
678     echo "the command line option: --no-chromeos-fonts."
679     exit 1
680   fi
681 else
682   echo "Skipping installation of Chrome OS fonts."
683 fi
684
685 echo "Installing locales."
686 CHROMIUM_LOCALES="da_DK.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 zh_TW.UTF-8"
687 LOCALE_GEN=/etc/locale.gen
688 if [ -e ${LOCALE_GEN} ]; then
689   OLD_LOCALE_GEN="$(cat /etc/locale.gen)"
690   for CHROMIUM_LOCALE in ${CHROMIUM_LOCALES}; do
691     sudo sed -i "s/^# ${CHROMIUM_LOCALE}/${CHROMIUM_LOCALE}/" ${LOCALE_GEN}
692   done
693   # Regenerating locales can take a while, so only do it if we need to.
694   if (echo "${OLD_LOCALE_GEN}" | cmp -s ${LOCALE_GEN}); then
695     echo "Locales already up-to-date."
696   else
697     sudo locale-gen
698   fi
699 else
700   for CHROMIUM_LOCALE in ${CHROMIUM_LOCALES}; do
701     sudo locale-gen ${CHROMIUM_LOCALE}
702   done
703 fi