| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 die "Could not mount $MOUNTED_PATH" | 86 die "Could not mount $MOUNTED_PATH" |
| 87 fi | 87 fi |
| 88 | 88 |
| 89 MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/sys")" | 89 MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/sys")" |
| 90 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] | 90 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] |
| 91 then | 91 then |
| 92 sudo mount none -t sysfs "$MOUNTED_PATH" || \ | 92 sudo mount none -t sysfs "$MOUNTED_PATH" || \ |
| 93 die "Could not mount $MOUNTED_PATH" | 93 die "Could not mount $MOUNTED_PATH" |
| 94 fi | 94 fi |
| 95 | 95 |
| 96 MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/dev/pts")" | 96 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev")" |
| 97 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] | 97 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] |
| 98 then | 98 then |
| 99 sudo mount none -t devpts "$MOUNTED_PATH" || \ | 99 sudo mount --bind /dev "$MOUNTED_PATH" || \ |
| 100 die "Could not mount $MOUNTED_PATH" | 100 die "Could not mount $MOUNTED_PATH" |
| 101 fi | 101 fi |
| 102 | 102 |
| 103 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")" | 103 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")" |
| 104 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] | 104 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] |
| 105 then | 105 then |
| 106 sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \ | 106 sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \ |
| 107 die "Could not mount $MOUNTED_PATH" | 107 die "Could not mount $MOUNTED_PATH" |
| 108 fi | 108 fi |
| 109 | 109 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 135 echo "Mounting depot_tools" | 135 echo "Mounting depot_tools" |
| 136 DEPOT_TOOLS=$(dirname $(which gclient) ) | 136 DEPOT_TOOLS=$(dirname $(which gclient) ) |
| 137 mkdir -p "$MOUNTED_PATH" | 137 mkdir -p "$MOUNTED_PATH" |
| 138 if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then | 138 if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then |
| 139 echo "depot_tools failed to mount; perhaps it's on NFS?" | 139 echo "depot_tools failed to mount; perhaps it's on NFS?" |
| 140 echo "This may impact chromium build." | 140 echo "This may impact chromium build." |
| 141 fi | 141 fi |
| 142 fi | 142 fi |
| 143 fi | 143 fi |
| 144 | 144 |
| 145 # Mount fuse device from host machine into chroot and copy over | 145 # Install fuse module. |
| 146 # corresponding kernel modules. | 146 if [ -c "${FUSE_DEVICE}" ] ; then |
| 147 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${FUSE_DEVICE}")" | |
| 148 if [ -z "$(mount | grep -F "on ${MOUNTED_PATH} ")" ] && \ | |
| 149 [ -c "${FUSE_DEVICE}" ] ; then | |
| 150 echo "Attempting to mount fuse device for gmergefs" | |
| 151 sudo touch "${MOUNTED_PATH}" | |
| 152 sudo mount --bind "${FUSE_DEVICE}" "${MOUNTED_PATH}" | |
| 153 sudo modprobe fuse 2> /dev/null ||\ | 147 sudo modprobe fuse 2> /dev/null ||\ |
| 154 echo "-- Note: modprobe fuse failed. gmergefs will not work" | 148 echo "-- Note: modprobe fuse failed. gmergefs will not work" |
| 155 fi | 149 fi |
| 156 | 150 |
| 157 ) 200>>"$LOCKFILE" || die "setup_env failed" | 151 ) 200>>"$LOCKFILE" || die "setup_env failed" |
| 158 } | 152 } |
| 159 | 153 |
| 160 function teardown_env { | 154 function teardown_env { |
| 161 # Only teardown if we're the last enter_chroot to die | 155 # Only teardown if we're the last enter_chroot to die |
| 162 ( | 156 ( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 239 |
| 246 # Run command or interactive shell. Also include the non-chrooted path to | 240 # Run command or interactive shell. Also include the non-chrooted path to |
| 247 # the source trunk for scripts that may need to print it (e.g. | 241 # the source trunk for scripts that may need to print it (e.g. |
| 248 # build_image.sh). | 242 # build_image.sh). |
| 249 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ | 243 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ |
| 250 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" | 244 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" |
| 251 | 245 |
| 252 # Remove trap and explicitly unmount | 246 # Remove trap and explicitly unmount |
| 253 trap - EXIT | 247 trap - EXIT |
| 254 teardown_env | 248 teardown_env |
| OLD | NEW |