OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS 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 enter the chroot environment | 7 # Script to enter the chroot environment |
8 | 8 |
9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 die "Could not mount $MOUNTED_PATH" | 135 die "Could not mount $MOUNTED_PATH" |
136 fi | 136 fi |
137 | 137 |
138 if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then | 138 if [ $FLAGS_ssh_agent -eq $FLAGS_TRUE ]; then |
139 TARGET_DIR="$(readlink -f "${FLAGS_chroot}/home/${USER}/.ssh")" | 139 TARGET_DIR="$(readlink -f "${FLAGS_chroot}/home/${USER}/.ssh")" |
140 if [ -n "${SSH_AUTH_SOCK}" \ | 140 if [ -n "${SSH_AUTH_SOCK}" \ |
141 -a -d "${HOME}/.ssh" ] | 141 -a -d "${HOME}/.ssh" ] |
142 then | 142 then |
143 mkdir -p "${TARGET_DIR}" | 143 mkdir -p "${TARGET_DIR}" |
144 cp -r "${HOME}/.ssh/known_hosts" "${TARGET_DIR}" | 144 cp -r "${HOME}/.ssh/known_hosts" "${TARGET_DIR}" |
| 145 cp -r "${HOME}/.ssh/config" "${TARGET_DIR}" |
145 ASOCK="$(dirname "${SSH_AUTH_SOCK}")" | 146 ASOCK="$(dirname "${SSH_AUTH_SOCK}")" |
146 mkdir -p "${FLAGS_chroot}/${ASOCK}" | 147 mkdir -p "${FLAGS_chroot}/${ASOCK}" |
147 sudo mount --bind "${ASOCK}" "${FLAGS_chroot}/${ASOCK}" || \ | 148 sudo mount --bind "${ASOCK}" "${FLAGS_chroot}/${ASOCK}" || \ |
148 die "Count not mount ${ASOCK}" | 149 die "Count not mount ${ASOCK}" |
149 fi | 150 fi |
150 fi | 151 fi |
151 | 152 |
152 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev/pts")" | 153 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev/pts")" |
153 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] | 154 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] |
154 then | 155 then |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 # Run command or interactive shell. Also include the non-chrooted path to | 334 # Run command or interactive shell. Also include the non-chrooted path to |
334 # the source trunk for scripts that may need to print it (e.g. | 335 # the source trunk for scripts that may need to print it (e.g. |
335 # build_image.sh). | 336 # build_image.sh). |
336 sudo -- chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ | 337 sudo -- chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ |
337 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ | 338 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C SSH_AGENT_PID="${SSH_AGENT_PID}" \ |
338 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" "$@" | 339 SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" "$@" |
339 | 340 |
340 # Remove trap and explicitly unmount | 341 # Remove trap and explicitly unmount |
341 trap - EXIT | 342 trap - EXIT |
342 teardown_env | 343 teardown_env |
OLD | NEW |