OLD | NEW |
1 #!/bin/bash -e | 1 #!/bin/bash -e |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to install everything needed to build chromium (well, ideally, anyway) | 7 # Script to install everything needed to build chromium (well, ideally, anyway) |
8 # See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_i
nstructions.md | 8 # See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_i
nstructions.md |
9 | 9 |
10 usage() { | 10 usage() { |
11 echo "Usage: $0 [--options]" | 11 echo "Usage: $0 [--options]" |
12 echo "Options:" | 12 echo "Options:" |
13 echo "--[no-]syms: enable or disable installation of debugging symbols" | 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" | 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" | 15 echo "--[no-]arm: enable or disable installation of arm cross toolchain" |
16 echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\ | 16 echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\ |
17 "fonts" | 17 "fonts" |
18 echo "--[no-]nacl: enable or disable installation of prerequisites for"\ | 18 echo "--[no-]nacl: enable or disable installation of prerequisites for"\ |
19 "building standalone NaCl and all its toolchains" | 19 "building standalone NaCl and all its toolchains" |
20 echo "--no-prompt: silently select standard options/defaults" | 20 echo "--no-prompt: silently select standard options/defaults" |
21 echo "--quick-check: quickly try to determine if dependencies are installed" | 21 echo "--quick-check: quickly try to determine if dependencies are installed" |
22 echo " (this avoids interactive prompts and sudo commands," | 22 echo " (this avoids interactive prompts and sudo commands," |
23 echo " so might not be 100% accurate)" | 23 echo " so might not be 100% accurate)" |
24 echo "--unsupported: attempt installation even on unsupported systems" | 24 echo "--unsupported: attempt installation even on unsupported systems" |
25 echo "Script will prompt interactively if options not given." | 25 echo "Script will prompt interactively if options not given." |
26 exit 1 | 26 exit 1 |
27 } | 27 } |
28 | 28 |
| 29 # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is |
| 30 # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has |
| 31 # been provided to yes_no(), the function also accepts RETURN as a user input. |
| 32 # The parameter specifies the exit code that should be returned in that case. |
| 33 # The function will echo the user's selection followed by a newline character. |
| 34 # Users can abort the function by pressing CTRL-C. This will call "exit 1". |
| 35 yes_no() { |
| 36 if [ 0 -ne "${do_default-0}" ] ; then |
| 37 [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 38 return $1 |
| 39 fi |
| 40 local c |
| 41 while :; do |
| 42 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT |
| 43 stty -echo iuclc -icanon 2>/dev/null |
| 44 dd count=1 bs=1 2>/dev/null | od -An -tx1)" |
| 45 case "$c" in |
| 46 " 0a") if [ -n "$1" ]; then |
| 47 [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 48 return $1 |
| 49 fi |
| 50 ;; |
| 51 " 79") echo "Y" |
| 52 return 0 |
| 53 ;; |
| 54 " 6e") echo "N" |
| 55 return 1 |
| 56 ;; |
| 57 "") echo "Aborted" >&2 |
| 58 exit 1 |
| 59 ;; |
| 60 *) # The user pressed an unrecognized key. As we are not echoing |
| 61 # any incorrect user input, alert the user by ringing the bell. |
| 62 (tput bel) 2>/dev/null |
| 63 ;; |
| 64 esac |
| 65 done |
| 66 } |
| 67 |
29 # Checks whether a particular package is available in the repos. | 68 # Checks whether a particular package is available in the repos. |
30 # USAGE: $ package_exists <package name> | 69 # USAGE: $ package_exists <package name> |
31 package_exists() { | 70 package_exists() { |
32 apt-cache pkgnames | grep -x "$1" > /dev/null 2>&1 | 71 apt-cache pkgnames | grep -x "$1" > /dev/null 2>&1 |
33 } | 72 } |
34 | 73 |
35 # These default to on because (some) bots need them and it keeps things | 74 # These default to on because (some) bots need them and it keeps things |
36 # simple for the bot setup if all bots just run the script in its default | 75 # simple for the bot setup if all bots just run the script in its default |
37 # mode. Developers who don't want stuff they don't need installed on their | 76 # mode. Developers who don't want stuff they don't need installed on their |
38 # own workstations can pass --no-arm --no-nacl when running the script. | 77 # own workstations can pass --no-arm --no-nacl when running the script. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 elif [ "x$lsb_release" = "xtrusty" ]; then | 184 elif [ "x$lsb_release" = "xtrusty" ]; then |
146 dbg_list="${dbg_list} libstdc++6-4.8-dbg" | 185 dbg_list="${dbg_list} libstdc++6-4.8-dbg" |
147 else | 186 else |
148 dbg_list="${dbg_list} libstdc++6-4.9-dbg" | 187 dbg_list="${dbg_list} libstdc++6-4.9-dbg" |
149 fi | 188 fi |
150 | 189 |
151 # 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf | 190 # 32-bit libraries needed e.g. to compile V8 snapshot for Android or armhf |
152 lib32_list="linux-libc-dev:i386" | 191 lib32_list="linux-libc-dev:i386" |
153 | 192 |
154 # arm cross toolchain packages needed to build chrome on armhf | 193 # arm cross toolchain packages needed to build chrome on armhf |
155 arm_list="libc6-dev-armhf-cross | 194 EM_REPO="deb http://emdebian.org/tools/debian/ jessie main" |
156 linux-libc-dev-armhf-cross | 195 EM_SOURCE=$(cat <<EOF |
157 g++-arm-linux-gnueabihf" | 196 # Repo added by Chromium $0 |
| 197 ${EM_REPO} |
| 198 # deb-src http://emdebian.org/tools/debian/ jessie main |
| 199 EOF |
| 200 ) |
| 201 EM_ARCHIVE_KEY_FINGER="084C6C6F39159EDB67969AA87DE089671804772E" |
| 202 GPP_ARM_PACKAGE="g++-arm-linux-gnueabihf" |
| 203 case $lsb_release in |
| 204 "jessie") |
| 205 eval $(apt-config shell APT_SOURCESDIR 'Dir::Etc::sourceparts/d') |
| 206 CROSSTOOLS_LIST="${APT_SOURCESDIR}/crosstools.list" |
| 207 arm_list="libc6-dev:armhf |
| 208 linux-libc-dev:armhf" |
| 209 if test "$do_inst_arm" = "1"; then |
| 210 if $(dpkg-query -W ${GPP_ARM_PACKAGE} &>/dev/null); then |
| 211 arm_list+=" ${GPP_ARM_PACKAGE}" |
| 212 else |
| 213 echo "The Debian Cross-toolchains repository is necessary to" |
| 214 echo "cross-compile Chromium for arm." |
| 215 echo -n "Do you want me to add it for you (y/N) " |
| 216 if yes_no 1; then |
| 217 gpg --keyserver pgp.mit.edu --recv-keys ${EM_ARCHIVE_KEY_FINGER} |
| 218 gpg -a --export ${EM_ARCHIVE_KEY_FINGER} | sudo apt-key add - |
| 219 if ! grep "^${EM_REPO}" "${CROSSTOOLS_LIST}" &>/dev/null; then |
| 220 echo "${EM_SOURCE}" | sudo tee -a "${CROSSTOOLS_LIST}" >/dev/null |
| 221 fi |
| 222 arm_list+=" ${GPP_ARM_PACKAGE}" |
| 223 fi |
| 224 fi |
| 225 fi |
| 226 ;; |
| 227 *) |
| 228 arm_list="libc6-dev-armhf-cross |
| 229 linux-libc-dev-armhf-cross |
| 230 ${GPP_ARM_PACKAGE}" |
| 231 ;; |
| 232 esac |
158 | 233 |
159 # Work around for dependency issue Ubuntu/Trusty: http://crbug.com/435056 | 234 # Work around for dependency issue Ubuntu/Trusty: http://crbug.com/435056 |
160 case $lsb_release in | 235 case $lsb_release in |
161 trusty) | 236 trusty) |
162 arm_list+=" g++-4.8-multilib-arm-linux-gnueabihf | 237 arm_list+=" g++-4.8-multilib-arm-linux-gnueabihf |
163 gcc-4.8-multilib-arm-linux-gnueabihf" | 238 gcc-4.8-multilib-arm-linux-gnueabihf" |
164 ;; | 239 ;; |
165 wily) | 240 wily) |
166 arm_list+=" g++-5-multilib-arm-linux-gnueabihf | 241 arm_list+=" g++-5-multilib-arm-linux-gnueabihf |
167 gcc-5-multilib-arm-linux-gnueabihf | 242 gcc-5-multilib-arm-linux-gnueabihf |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 if file -L /sbin/init | grep -q 'ELF 64-bit'; then | 353 if file -L /sbin/init | grep -q 'ELF 64-bit'; then |
279 # gcc-multilib conflicts with the arm cross compiler (at least in trusty) but | 354 # gcc-multilib conflicts with the arm cross compiler (at least in trusty) but |
280 # g++-X.Y-multilib gives us the 32-bit support that we need. Find out the | 355 # g++-X.Y-multilib gives us the 32-bit support that we need. Find out the |
281 # appropriate value of X and Y by seeing what version the current | 356 # appropriate value of X and Y by seeing what version the current |
282 # distribution's g++-multilib package depends on. | 357 # distribution's g++-multilib package depends on. |
283 multilib_package=$(apt-cache depends g++-multilib --important | \ | 358 multilib_package=$(apt-cache depends g++-multilib --important | \ |
284 grep -E --color=never --only-matching '\bg\+\+-[0-9.]+-multilib\b') | 359 grep -E --color=never --only-matching '\bg\+\+-[0-9.]+-multilib\b') |
285 lib32_list="$lib32_list $multilib_package" | 360 lib32_list="$lib32_list $multilib_package" |
286 fi | 361 fi |
287 | 362 |
288 # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is | |
289 # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has | |
290 # been provided to yes_no(), the function also accepts RETURN as a user input. | |
291 # The parameter specifies the exit code that should be returned in that case. | |
292 # The function will echo the user's selection followed by a newline character. | |
293 # Users can abort the function by pressing CTRL-C. This will call "exit 1". | |
294 yes_no() { | |
295 if [ 0 -ne "${do_default-0}" ] ; then | |
296 [ $1 -eq 0 ] && echo "Y" || echo "N" | |
297 return $1 | |
298 fi | |
299 local c | |
300 while :; do | |
301 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT | |
302 stty -echo iuclc -icanon 2>/dev/null | |
303 dd count=1 bs=1 2>/dev/null | od -An -tx1)" | |
304 case "$c" in | |
305 " 0a") if [ -n "$1" ]; then | |
306 [ $1 -eq 0 ] && echo "Y" || echo "N" | |
307 return $1 | |
308 fi | |
309 ;; | |
310 " 79") echo "Y" | |
311 return 0 | |
312 ;; | |
313 " 6e") echo "N" | |
314 return 1 | |
315 ;; | |
316 "") echo "Aborted" >&2 | |
317 exit 1 | |
318 ;; | |
319 *) # The user pressed an unrecognized key. As we are not echoing | |
320 # any incorrect user input, alert the user by ringing the bell. | |
321 (tput bel) 2>/dev/null | |
322 ;; | |
323 esac | |
324 done | |
325 } | |
326 | |
327 if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0} | 363 if test "$do_inst_syms" = "" && test 0 -eq ${do_quick_check-0} |
328 then | 364 then |
329 echo "This script installs all tools and libraries needed to build Chromium." | 365 echo "This script installs all tools and libraries needed to build Chromium." |
330 echo "" | 366 echo "" |
331 echo "For most of the libraries, it can also install debugging symbols, which" | 367 echo "For most of the libraries, it can also install debugging symbols, which" |
332 echo "will allow you to debug code in the system libraries. Most developers" | 368 echo "will allow you to debug code in the system libraries. Most developers" |
333 echo "won't need these symbols." | 369 echo "won't need these symbols." |
334 echo -n "Do you want me to install them for you (y/N) " | 370 echo -n "Do you want me to install them for you (y/N) " |
335 if yes_no 1; then | 371 if yes_no 1; then |
336 do_inst_syms=1 | 372 do_inst_syms=1 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 fi | 433 fi |
398 exit 1 | 434 exit 1 |
399 fi | 435 fi |
400 exit 0 | 436 exit 0 |
401 fi | 437 fi |
402 | 438 |
403 if test "$do_inst_lib32" = "1" || test "$do_inst_nacl" = "1"; then | 439 if test "$do_inst_lib32" = "1" || test "$do_inst_nacl" = "1"; then |
404 if [[ ! $lsb_release =~ (precise) ]]; then | 440 if [[ ! $lsb_release =~ (precise) ]]; then |
405 sudo dpkg --add-architecture i386 | 441 sudo dpkg --add-architecture i386 |
406 fi | 442 fi |
| 443 if [[ $lsb_release = "jessie" ]]; then |
| 444 sudo dpkg --add-architecture armhf |
| 445 fi |
407 fi | 446 fi |
408 sudo apt-get update | 447 sudo apt-get update |
409 | 448 |
410 # We initially run "apt-get" with the --reinstall option and parse its output. | 449 # We initially run "apt-get" with the --reinstall option and parse its output. |
411 # This way, we can find all the packages that need to be newly installed | 450 # This way, we can find all the packages that need to be newly installed |
412 # without accidentally promoting any packages from "auto" to "manual". | 451 # without accidentally promoting any packages from "auto" to "manual". |
413 # We then re-run "apt-get" with just the list of missing packages. | 452 # We then re-run "apt-get" with just the list of missing packages. |
414 echo "Finding missing packages..." | 453 echo "Finding missing packages..." |
415 # Intentionally leaving $packages unquoted so it's more readable. | 454 # Intentionally leaving $packages unquoted so it's more readable. |
416 echo "Packages required: " $packages | 455 echo "Packages required: " $packages |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 # only contains libcrypto.so.1.0.0 and not the symlink needed for | 530 # only contains libcrypto.so.1.0.0 and not the symlink needed for |
492 # linking (libcrypto.so). | 531 # linking (libcrypto.so). |
493 create_library_symlink /lib/i386-linux-gnu/libcrypto.so.1.0.0 \ | 532 create_library_symlink /lib/i386-linux-gnu/libcrypto.so.1.0.0 \ |
494 /usr/lib/i386-linux-gnu/libcrypto.so | 533 /usr/lib/i386-linux-gnu/libcrypto.so |
495 | 534 |
496 create_library_symlink /lib/i386-linux-gnu/libssl.so.1.0.0 \ | 535 create_library_symlink /lib/i386-linux-gnu/libssl.so.1.0.0 \ |
497 /usr/lib/i386-linux-gnu/libssl.so | 536 /usr/lib/i386-linux-gnu/libssl.so |
498 else | 537 else |
499 echo "Skipping symbolic links for NaCl." | 538 echo "Skipping symbolic links for NaCl." |
500 fi | 539 fi |
OLD | NEW |