| 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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 esac | 497 esac |
| 498 done | 498 done |
| 499 | 499 |
| 500 # Start a new chroot session and keep track of the session id. We inject this | 500 # Start a new chroot session and keep track of the session id. We inject this |
| 501 # id into all processes that run inside the chroot. Unless they go out of their | 501 # id into all processes that run inside the chroot. Unless they go out of their |
| 502 # way to clear their environment, we can then later identify our child and | 502 # way to clear their environment, we can then later identify our child and |
| 503 # grand-child processes by scanning their environment. | 503 # grand-child processes by scanning their environment. |
| 504 session="$(schroot -c "${chroot}" -b)" | 504 session="$(schroot -c "${chroot}" -b)" |
| 505 export CHROOT_SESSION_ID="${session}" | 505 export CHROOT_SESSION_ID="${session}" |
| 506 | 506 |
| 507 # Set GOMA_TMP_DIR for better handling of goma inside chroot. |
| 508 export GOMA_TMP_DIR="/tmp/goma_tmp_$CHROOT_SESSION_ID" |
| 509 mkdir -p "$GOMA_TMP_DIR" |
| 510 |
| 507 if [ $# -eq 0 ]; then | 511 if [ $# -eq 0 ]; then |
| 508 # Run an interactive shell session | 512 # Run an interactive shell session |
| 509 schroot -c "${session}" -r -p | 513 schroot -c "${session}" -r -p |
| 510 else | 514 else |
| 511 # Run a command inside of the chroot environment | 515 # Run a command inside of the chroot environment |
| 512 p="$1"; shift | 516 p="$1"; shift |
| 513 schroot -c "${session}" -r -p "$p" -- "$@" | 517 schroot -c "${session}" -r -p "$p" -- "$@" |
| 514 fi | 518 fi |
| 515 rc=$? | 519 rc=$? |
| 516 | 520 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 547 fi | 551 fi |
| 548 kill -9 $pids | 552 kill -9 $pids |
| 549 done | 553 done |
| 550 done | 554 done |
| 551 # End the chroot session. This should clean up all temporary files. But if we | 555 # End the chroot session. This should clean up all temporary files. But if we |
| 552 # earlier failed to terminate all (daemon) processes inside of the session, | 556 # earlier failed to terminate all (daemon) processes inside of the session, |
| 553 # deleting the session could fail. When that happens, the user has to manually | 557 # deleting the session could fail. When that happens, the user has to manually |
| 554 # clean up the stale files by invoking us with "--clean" after having killed | 558 # clean up the stale files by invoking us with "--clean" after having killed |
| 555 # all running processes. | 559 # all running processes. |
| 556 schroot -c "${session}" -e | 560 schroot -c "${session}" -e |
| 561 # Since no goma processes are running, we can remove goma directory. |
| 562 rm -rf "$GOMA_TMP_DIR" |
| 557 exit $rc | 563 exit $rc |
| 558 EOF | 564 EOF |
| 559 sudo chown root:root /usr/local/bin/"${target%bit}" | 565 sudo chown root:root /usr/local/bin/"${target%bit}" |
| 560 sudo chmod 755 /usr/local/bin/"${target%bit}" | 566 sudo chmod 755 /usr/local/bin/"${target%bit}" |
| 561 | 567 |
| 562 # Add the standard Ubuntu update repositories if requested. | 568 # Add the standard Ubuntu update repositories if requested. |
| 563 [ "${alt_repos}" = "y" -a \ | 569 [ "${alt_repos}" = "y" -a \ |
| 564 -r "/var/lib/chroot/${target}/etc/apt/sources.list" ] && | 570 -r "/var/lib/chroot/${target}/etc/apt/sources.list" ] && |
| 565 sudo sed -i '/^deb .* [^ -]\+ main$/p | 571 sudo sed -i '/^deb .* [^ -]\+ main$/p |
| 566 s/^\(deb .* [^ -]\+\) main/\1-security main/ | 572 s/^\(deb .* [^ -]\+\) main/\1-security main/ |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 | 849 |
| 844 For Chrome, this probably means you want to make your "out" directory a | 850 For Chrome, this probably means you want to make your "out" directory a |
| 845 symbolic link that points somewhere inside of "${HOME}/chroot". | 851 symbolic link that points somewhere inside of "${HOME}/chroot". |
| 846 | 852 |
| 847 You still need to run "gclient runhooks" whenever you switch from building | 853 You still need to run "gclient runhooks" whenever you switch from building |
| 848 outside of the chroot to inside of the chroot. But you will find that you | 854 outside of the chroot to inside of the chroot. But you will find that you |
| 849 don't have to repeatedly erase and then completely rebuild all your object | 855 don't have to repeatedly erase and then completely rebuild all your object |
| 850 and binary files. | 856 and binary files. |
| 851 | 857 |
| 852 EOF | 858 EOF |
| OLD | NEW |