Chromium Code Reviews| 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 http://code.google.com/p/chromium/wiki/LinuxBuildInstructions | 8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions |
| 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit | 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit |
| 10 | 10 |
| 11 usage() { | 11 usage() { |
| 12 echo "Usage: $0 [--options]" | 12 echo "Usage: $0 [--options]" |
| 13 echo "Options:" | 13 echo "Options:" |
| 14 echo "--[no-]syms: enable or disable installation of debugging symbols" | 14 echo "--[no-]syms: enable or disable installation of debugging symbols" |
| 15 echo "--[no-]lib32: enable or disable installation of 32 bit libraries" | |
| 16 echo "--[no-]arm: enable or disable installation of arm cross toolchain" | 15 echo "--[no-]arm: enable or disable installation of arm cross toolchain" |
| 17 echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\ | 16 echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\ |
| 18 "fonts" | 17 "fonts" |
| 19 echo "--[no-]nacl: enable or disable installation of prerequisites for"\ | 18 echo "--[no-]nacl: enable or disable installation of prerequisites for"\ |
| 20 "building standalone NaCl and all its toolchains" | 19 "building standalone NaCl and all its toolchains" |
| 21 echo "--no-prompt: silently select standard options/defaults" | 20 echo "--no-prompt: silently select standard options/defaults" |
| 22 echo "--quick-check: quickly try to determine if dependencies are installed" | 21 echo "--quick-check: quickly try to determine if dependencies are installed" |
| 23 echo " (this avoids interactive prompts and sudo commands," | 22 echo " (this avoids interactive prompts and sudo commands," |
| 24 echo " so might not be 100% accurate)" | 23 echo " so might not be 100% accurate)" |
| 25 echo "--unsupported: attempt installation even on unsupported systems" | 24 echo "--unsupported: attempt installation even on unsupported systems" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 38 # mode. Developers who don't want stuff they don't need installed on their | 37 # mode. Developers who don't want stuff they don't need installed on their |
| 39 # own workstations can pass --no-arm --no-nacl when running the script. | 38 # own workstations can pass --no-arm --no-nacl when running the script. |
| 40 do_inst_arm=1 | 39 do_inst_arm=1 |
| 41 do_inst_nacl=1 | 40 do_inst_nacl=1 |
| 42 | 41 |
| 43 while test "$1" != "" | 42 while test "$1" != "" |
| 44 do | 43 do |
| 45 case "$1" in | 44 case "$1" in |
| 46 --syms) do_inst_syms=1;; | 45 --syms) do_inst_syms=1;; |
| 47 --no-syms) do_inst_syms=0;; | 46 --no-syms) do_inst_syms=0;; |
| 47 # TODO(phajdan.jr): Remove the lib32 flags when nothing else refers to them. | |
|
Michael Moss
2014/08/14 14:59:14
I'd almost like to see it fail here, so we can fin
Paweł Hajdan Jr.
2014/08/18 11:49:45
That's why I sent a chromium-dev e-mail.
I think
Michael Moss
2014/08/18 15:53:21
Hence my first sentence where I said I'd like to s
| |
| 48 --lib32) do_inst_lib32=1;; | 48 --lib32) do_inst_lib32=1;; |
| 49 --no-lib32) do_inst_lib32=0;; | 49 --no-lib32) do_inst_lib32=0;; |
| 50 --arm) do_inst_arm=1;; | 50 --arm) do_inst_arm=1;; |
| 51 --no-arm) do_inst_arm=0;; | 51 --no-arm) do_inst_arm=0;; |
| 52 --chromeos-fonts) do_inst_chromeos_fonts=1;; | 52 --chromeos-fonts) do_inst_chromeos_fonts=1;; |
| 53 --no-chromeos-fonts) do_inst_chromeos_fonts=0;; | 53 --no-chromeos-fonts) do_inst_chromeos_fonts=0;; |
| 54 --nacl) do_inst_nacl=1;; | 54 --nacl) do_inst_nacl=1;; |
| 55 --no-nacl) do_inst_nacl=0;; | 55 --no-nacl) do_inst_nacl=0;; |
| 56 --no-prompt) do_default=1 | 56 --no-prompt) do_default=1 |
| 57 do_quietly="-qq --assume-yes" | 57 do_quietly="-qq --assume-yes" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev | 103 libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev |
| 104 libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev | 104 libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev |
| 105 libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev | 105 libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev |
| 106 libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev | 106 libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev |
| 107 mesa-common-dev openbox patch perl php5-cgi pkg-config python | 107 mesa-common-dev openbox patch perl php5-cgi pkg-config python |
| 108 python-cherrypy3 python-dev python-psutil rpm ruby subversion | 108 python-cherrypy3 python-dev python-psutil rpm ruby subversion |
| 109 ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho | 109 ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho |
| 110 wdiff xfonts-mathml zip $chromeos_dev_list" | 110 wdiff xfonts-mathml zip $chromeos_dev_list" |
| 111 | 111 |
| 112 # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built | 112 # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built |
| 113 # NaCl binaries. These are always needed, regardless of whether or not we want | 113 # NaCl binaries. |
| 114 # the full 32-bit "cross-compile" support (--lib32). | |
| 115 if file /sbin/init | grep -q 'ELF 64-bit'; then | 114 if file /sbin/init | grep -q 'ELF 64-bit'; then |
| 116 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6" | 115 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6" |
| 117 fi | 116 fi |
| 118 | 117 |
| 119 # Run-time libraries required by chromeos only | 118 # Run-time libraries required by chromeos only |
| 120 chromeos_lib_list="libpulse0 libbz2-1.0" | 119 chromeos_lib_list="libpulse0 libbz2-1.0" |
| 121 | 120 |
| 122 # Full list of required run-time libraries | 121 # Full list of required run-time libraries |
| 123 lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1 | 122 lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcap2 libcups2 libexpat1 |
| 124 libexif12 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 | 123 libexif12 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 echo "Installing symbolic links for NaCl." | 397 echo "Installing symbolic links for NaCl." |
| 399 if [ ! -r /usr/lib/i386-linux-gnu/libcrypto.so ]; then | 398 if [ ! -r /usr/lib/i386-linux-gnu/libcrypto.so ]; then |
| 400 sudo ln -fs libcrypto.so.0.9.8 /usr/lib/i386-linux-gnu/libcrypto.so | 399 sudo ln -fs libcrypto.so.0.9.8 /usr/lib/i386-linux-gnu/libcrypto.so |
| 401 fi | 400 fi |
| 402 if [ ! -r /usr/lib/i386-linux-gnu/libssl.so ]; then | 401 if [ ! -r /usr/lib/i386-linux-gnu/libssl.so ]; then |
| 403 sudo ln -fs libssl.so.0.9.8 /usr/lib/i386-linux-gnu/libssl.so | 402 sudo ln -fs libssl.so.0.9.8 /usr/lib/i386-linux-gnu/libssl.so |
| 404 fi | 403 fi |
| 405 else | 404 else |
| 406 echo "Skipping symbolic links for NaCl." | 405 echo "Skipping symbolic links for NaCl." |
| 407 fi | 406 fi |
| 408 | |
| 409 # Install 32bit backwards compatibility support for 64bit systems | |
| 410 if file /sbin/init | grep -q 'ELF 64-bit'; then | |
| 411 if test "$do_inst_lib32" != "1" | |
| 412 then | |
| 413 echo "NOTE: If you were expecting the option to install 32bit libs," | |
| 414 echo "please run with the --lib32 flag." | |
| 415 echo | |
| 416 echo "Installation complete." | |
| 417 exit 0 | |
| 418 else | |
| 419 # This conditional statement has been added to deprecate and eventually | |
| 420 # remove support for 32bit libraries on 64bit systems. But for the time | |
| 421 # being, we still have to support a few legacy systems (e.g. bots), where | |
| 422 # this feature is needed. | |
| 423 # We only even give the user the option to install these libraries, if | |
| 424 # they explicitly requested doing so by setting the --lib32 command line | |
| 425 # flag. | |
| 426 # And even then, we interactively ask them one more time whether they are | |
| 427 # absolutely sure. | |
| 428 # In order for that to work, we must reset the ${do_inst_lib32} variable. | |
| 429 # There are other ways to achieve the same goal. But resetting the | |
| 430 # variable is the best way to document the intended behavior -- and to | |
| 431 # allow us to gradually deprecate and then remove the obsolete code. | |
| 432 if test "${do_default-0}" -ne 1; then | |
| 433 do_inst_lib32= | |
| 434 fi | |
| 435 fi | |
| 436 | |
| 437 echo "WARNING" | |
| 438 echo | |
| 439 echo "We no longer recommend that you use this script to install" | |
| 440 echo "32bit libraries on a 64bit system. Instead, consider using the" | |
| 441 echo "install-chroot.sh script to help you set up a 32bit environment" | |
| 442 echo "for building and testing 32bit versions of Chrome." | |
| 443 echo | |
| 444 echo "The code for installing 32bit libraries on a 64bit system is" | |
| 445 echo "unmaintained and might not work with modern versions of Ubuntu" | |
| 446 echo "or Debian." | |
| 447 if test "$do_inst_lib32" != "" ; then | |
| 448 echo | |
| 449 echo -n "Are you sure you want to proceed (y/N) " | |
| 450 if yes_no 1; then | |
| 451 do_inst_lib32=1 | |
| 452 fi | |
| 453 fi | |
| 454 if test "$do_inst_lib32" != "1" | |
| 455 then | |
| 456 exit 0 | |
| 457 fi | |
| 458 | |
| 459 # Standard 32bit compatibility libraries | |
| 460 echo "First, installing the limited existing 32-bit support..." | |
| 461 cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1 | |
| 462 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib" | |
| 463 if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then | |
| 464 cmp_list="${cmp_list} lib32readline-gplv2-dev" | |
| 465 else | |
| 466 cmp_list="${cmp_list} lib32readline5-dev" | |
| 467 fi | |
| 468 sudo apt-get install ${do_quietly-} $cmp_list | |
| 469 | |
| 470 tmp=/tmp/install-32bit.$$ | |
| 471 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT | |
| 472 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial" | |
| 473 touch "${tmp}/status" | |
| 474 | |
| 475 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/" | |
| 476 cat >>"${tmp}/apt/apt.conf" <<EOF | |
| 477 Apt::Architecture "i386"; | |
| 478 Dir::Cache "${tmp}/cache"; | |
| 479 Dir::Cache::Archives "${tmp}/"; | |
| 480 Dir::State::Lists "${tmp}/apt/lists/"; | |
| 481 Dir::State::status "${tmp}/status"; | |
| 482 EOF | |
| 483 | |
| 484 # Download 32bit packages | |
| 485 echo "Computing list of available 32bit packages..." | |
| 486 sudo apt-get -c="${tmp}/apt/apt.conf" update | |
| 487 | |
| 488 echo "Downloading available 32bit packages..." | |
| 489 sudo apt-get -c="${tmp}/apt/apt.conf" \ | |
| 490 --yes --download-only --force-yes --reinstall install \ | |
| 491 ${lib_list} ${dbg_list} | |
| 492 | |
| 493 # Open packages, remove everything that is not a library, move the | |
| 494 # library to a lib32 directory and package everything as a *.deb file. | |
| 495 echo "Repackaging and installing 32bit packages for use on 64bit systems..." | |
| 496 for i in ${lib_list} ${dbg_list}; do | |
| 497 orig="$(echo "${tmp}/${i}"_*_i386.deb)" | |
| 498 compat="$(echo "${orig}" | | |
| 499 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')" | |
| 500 rm -rf "${tmp}/staging" | |
| 501 msg="$(fakeroot -u sh -exc ' | |
| 502 # Unpack 32bit Debian archive | |
| 503 umask 022 | |
| 504 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN" | |
| 505 cd "'"${tmp}"'/staging" | |
| 506 ar x "'${orig}'" | |
| 507 tar Cfx dpkg data.tar* | |
| 508 tar zCfx dpkg/DEBIAN control.tar.gz | |
| 509 | |
| 510 # Create a posix extended regular expression fragment that will | |
| 511 # recognize the includes which have changed. Should be rare, | |
| 512 # will almost always be empty. | |
| 513 includes=`sed -n -e "s/^[0-9a-z]* //g" \ | |
| 514 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums | | |
| 515 xargs -n 1 -I FILE /bin/sh -c \ | |
| 516 "cmp -s dpkg/FILE /FILE || echo FILE" | | |
| 517 tr "\n" "|" | | |
| 518 sed -e "s,|$,,"` | |
| 519 | |
| 520 # If empty, set it to not match anything. | |
| 521 test -z "$includes" && includes="^//" | |
| 522 | |
| 523 # Turn the conflicts into an extended RE for removal from the | |
| 524 # Provides line. | |
| 525 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \ | |
| 526 dpkg/DEBIAN/control` | |
| 527 | |
| 528 # Rename package, change architecture, remove conflicts and dependencies | |
| 529 sed -r -i \ | |
| 530 -e "/Package/s/$/-ia32/" \ | |
| 531 -e "/Architecture/s/:.*$/: amd64/" \ | |
| 532 -e "/Depends/s/:.*/: ia32-libs/" \ | |
| 533 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \ | |
| 534 -e "/Recommends/d" \ | |
| 535 -e "/Conflicts/d" \ | |
| 536 dpkg/DEBIAN/control | |
| 537 | |
| 538 # Only keep files that live in "lib" directories or the includes | |
| 539 # that have changed. | |
| 540 sed -r -i \ | |
| 541 -e "/\/lib64\//d" -e "/\/.?bin\//d" \ | |
| 542 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \ | |
| 543 -e "s, lib/, lib32/,g" \ | |
| 544 -e "s,/lib/,/lib32/,g" \ | |
| 545 -e "t;d" \ | |
| 546 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug ," \ | |
| 547 dpkg/DEBIAN/md5sums | |
| 548 | |
| 549 # Re-run ldconfig after installation/removal | |
| 550 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \ | |
| 551 >dpkg/DEBIAN/postinst | |
| 552 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \ | |
| 553 >dpkg/DEBIAN/postrm | |
| 554 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm | |
| 555 | |
| 556 # Remove any other control files | |
| 557 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \ | |
| 558 -name postinst -o -name postrm ")" -o -print | | |
| 559 xargs -r rm -rf | |
| 560 | |
| 561 # Remove any files/dirs that live outside of "lib" directories, | |
| 562 # or are not in our list of changed includes. | |
| 563 find dpkg -mindepth 1 -regextype posix-extended \ | |
| 564 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \ | |
| 565 -prune -o -print | tac | | |
| 566 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : " | |
| 567 find dpkg -name lib64 -o -name bin -o -name "?bin" | | |
| 568 tac | xargs -r rm -rf | |
| 569 | |
| 570 # Remove any symbolic links that were broken by the above steps. | |
| 571 find -L dpkg -type l -print | tac | xargs -r rm -rf | |
| 572 | |
| 573 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32 | |
| 574 # That is where gdb looks for them. | |
| 575 find dpkg -type d -o -path "*/lib/*" -print | | |
| 576 xargs -r -n 1 sh -c " | |
| 577 i=\$(echo \"\${0}\" | | |
| 578 sed -e s,/lib/,/lib32/,g \ | |
| 579 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,); | |
| 580 mkdir -p \"\${i%/*}\"; | |
| 581 mv \"\${0}\" \"\${i}\"" | |
| 582 | |
| 583 # Rename include to include32. | |
| 584 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32" | |
| 585 | |
| 586 # Prune any empty directories | |
| 587 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || : | |
| 588 | |
| 589 # Create our own Debian package | |
| 590 cd .. | |
| 591 dpkg --build staging/dpkg .' 2>&1)" | |
| 592 compat="$(eval echo $(echo "${compat}" | | |
| 593 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))" | |
| 594 [ -r "${compat}" ] || { | |
| 595 echo "${msg}" >&2 | |
| 596 echo "Failed to build new Debian archive!" >&2 | |
| 597 exit 1 | |
| 598 } | |
| 599 | |
| 600 msg="$(sudo dpkg -i "${compat}" 2>&1)" && { | |
| 601 echo "Installed ${compat##*/}" | |
| 602 } || { | |
| 603 # echo "${msg}" >&2 | |
| 604 echo "Skipped ${compat##*/}" | |
| 605 } | |
| 606 done | |
| 607 | |
| 608 # Add symbolic links for developing 32bit code | |
| 609 echo "Adding missing symbolic links, enabling 32bit code development..." | |
| 610 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* | | |
| 611 sed -e 's/[.]so[.][0-9].*/.so/' | | |
| 612 sort -u); do | |
| 613 [ "x${i##*/}" = "xld-linux.so" ] && continue | |
| 614 [ -r "$i" ] && continue | |
| 615 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | | |
| 616 sort -n | tail -n 1)" | |
| 617 [ -r "$i.$j" ] || continue | |
| 618 sudo ln -s "${i##*/}.$j" "$i" | |
| 619 done | |
| 620 fi | |
| OLD | NEW |