install-build-deps.sh 23 KB

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