| 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 # This script installs Debian-derived distributions in a chroot environment. | 7 # This script installs Debian-derived distributions in a chroot environment. |
| 8 # It can for example be used to have an accurate 32bit build and test | 8 # It can for example be used to have an accurate 32bit build and test |
| 9 # environment when otherwise working on a 64bit machine. | 9 # environment when otherwise working on a 64bit machine. |
| 10 # N. B. it is unlikely that this script will ever work on anything other than a | 10 # N. B. it is unlikely that this script will ever work on anything other than a |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 echo "you now have to install the build dependencies. Do you want me to" | 651 echo "you now have to install the build dependencies. Do you want me to" |
| 652 printf "start the script that does this for you (y/n)? " | 652 printf "start the script that does this for you (y/n)? " |
| 653 read install_deps | 653 read install_deps |
| 654 case "${install_deps}" in | 654 case "${install_deps}" in |
| 655 y|Y) | 655 y|Y) |
| 656 echo | 656 echo |
| 657 # We prefer running the script in-place, but this might not be | 657 # We prefer running the script in-place, but this might not be |
| 658 # possible, if it lives on a network filesystem that denies | 658 # possible, if it lives on a network filesystem that denies |
| 659 # access to root. | 659 # access to root. |
| 660 tmp_script= | 660 tmp_script= |
| 661 if ! sudo "${target%bit}" sh -c "[ -x '${script}' ]" >&/dev/null; then | 661 if ! sudo /usr/local/bin/"${target%bit}" \ |
| 662 sh -c "[ -x '${script}' ]" >&/dev/null; then |
| 662 tmp_script="/tmp/${script##*/}" | 663 tmp_script="/tmp/${script##*/}" |
| 663 cp "${script}" "${tmp_script}" | 664 cp "${script}" "${tmp_script}" |
| 664 fi | 665 fi |
| 665 # Some distributions automatically start an instance of the system- | 666 # Some distributions automatically start an instance of the system- |
| 666 # wide dbus daemon or of the logging daemon, when installing the Chrome | 667 # wide dbus daemon or of the logging daemon, when installing the Chrome |
| 667 # build depencies. This prevents the chroot session from being closed. | 668 # build depencies. This prevents the chroot session from being closed. |
| 668 # So, we always try to shut down any running instance of dbus and | 669 # So, we always try to shut down any running instance of dbus and |
| 669 # rsyslog. | 670 # rsyslog. |
| 670 sudo "${target%bit}" sh -c "${script} --no-lib32; | 671 sudo "${target%bit}" sh -c "${script} --no-lib32; |
| 671 rc=$?; | 672 rc=$?; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 for i in $(list_all_chroots); do | 761 for i in $(list_all_chroots); do |
| 761 sudo "$i" mkdir -p "${dir}/chroot" | 762 sudo "$i" mkdir -p "${dir}/chroot" |
| 762 done | 763 done |
| 763 sudo sed -i "s,${HOME}/chroot,${dir}/chroot,g" /etc/schroot/mount-* | 764 sudo sed -i "s,${HOME}/chroot,${dir}/chroot,g" /etc/schroot/mount-* |
| 764 break | 765 break |
| 765 fi | 766 fi |
| 766 done | 767 done |
| 767 fi | 768 fi |
| 768 | 769 |
| 769 # Clean up package files | 770 # Clean up package files |
| 770 sudo schroot -c "${target%bit}" -p -- apt-get clean | 771 sudo schroot -c /usr/local/bin/"${target%bit}" -p -- apt-get clean |
| 771 sudo apt-get clean | 772 sudo apt-get clean |
| 772 | 773 |
| 773 trap '' INT TERM QUIT HUP | 774 trap '' INT TERM QUIT HUP |
| 774 trap '' EXIT | 775 trap '' EXIT |
| 775 | 776 |
| 776 # Let the user know what we did | 777 # Let the user know what we did |
| 777 cat <<EOF | 778 cat <<EOF |
| 778 | 779 |
| 779 | 780 |
| 780 Successfully installed ${distname} ${arch} | 781 Successfully installed ${distname} ${arch} |
| 781 | 782 |
| 782 You can run programs inside of the chroot by invoking the "${target%bit}" | 783 You can run programs inside of the chroot by invoking the |
| 783 command. | 784 "/usr/local/bin/${target%bit}" command. |
| 784 | 785 |
| 785 This command can be used with arguments, in order to just run a single | 786 This command can be used with arguments, in order to just run a single |
| 786 program inside of the chroot environment (e.g. "${target%bit} make chrome") | 787 program inside of the chroot environment (e.g. "${target%bit} make chrome") |
| 787 or without arguments, in order to run an interactive shell session inside | 788 or without arguments, in order to run an interactive shell session inside |
| 788 of the chroot environment. | 789 of the chroot environment. |
| 789 | 790 |
| 790 If you need to run things as "root", you can use "sudo" (e.g. try | 791 If you need to run things as "root", you can use "sudo" (e.g. try |
| 791 "sudo ${target%bit} apt-get update"). | 792 "sudo ${target%bit} apt-get update"). |
| 792 | 793 |
| 793 Your home directory is shared between the host and the chroot. But I | 794 Your home directory is shared between the host and the chroot. But I |
| 794 configured "${HOME}/chroot" to be private to the chroot environment. | 795 configured "${HOME}/chroot" to be private to the chroot environment. |
| 795 You can use it for files that need to differ between environments. This | 796 You can use it for files that need to differ between environments. This |
| 796 would be a good place to store binaries that you have built from your | 797 would be a good place to store binaries that you have built from your |
| 797 source files. | 798 source files. |
| 798 | 799 |
| 799 For Chrome, this probably means you want to make your "out" directory a | 800 For Chrome, this probably means you want to make your "out" directory a |
| 800 symbolic link that points somewhere inside of "${HOME}/chroot". | 801 symbolic link that points somewhere inside of "${HOME}/chroot". |
| 801 | 802 |
| 802 You still need to run "gclient runhooks" whenever you switch from building | 803 You still need to run "gclient runhooks" whenever you switch from building |
| 803 outside of the chroot to inside of the chroot. But you will find that you | 804 outside of the chroot to inside of the chroot. But you will find that you |
| 804 don't have to repeatedly erase and then completely rebuild all your object | 805 don't have to repeatedly erase and then completely rebuild all your object |
| 805 and binary files. | 806 and binary files. |
| 806 | 807 |
| 807 EOF | 808 EOF |
| OLD | NEW |