install-build-deps.sh 20 KB

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