Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1466)

Side by Side Diff: src/scripts/enter_chroot.sh

Issue 1582011: Better handling of fuse in chroot (Closed)
Patch Set: Remove var Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 fi 58 fi
59 59
60 # Only now can we die on error. shflags functions leak non-zero error codes, 60 # Only now can we die on error. shflags functions leak non-zero error codes,
61 # so will die prematurely if 'set -e' is specified before now. 61 # so will die prematurely if 'set -e' is specified before now.
62 # TODO: replace shflags with something less error-prone, or contribute a fix. 62 # TODO: replace shflags with something less error-prone, or contribute a fix.
63 set -e 63 set -e
64 64
65 INNER_CHROME_ROOT="/home/$USER/chrome_root" # inside chroot 65 INNER_CHROME_ROOT="/home/$USER/chrome_root" # inside chroot
66 CHROME_ROOT_CONFIG="/var/cache/chrome_root" # inside chroot 66 CHROME_ROOT_CONFIG="/var/cache/chrome_root" # inside chroot
67 INNER_DEPOT_TOOLS_ROOT="/home/$USER/depot_tools" # inside chroot 67 INNER_DEPOT_TOOLS_ROOT="/home/$USER/depot_tools" # inside chroot
68 KERNEL_MODULES_ROOT="/lib/modules/$( uname -r )" # inside and outside chroot
69 FUSE_DEVICE="/dev/fuse" 68 FUSE_DEVICE="/dev/fuse"
70 69
71 sudo chmod 0777 "$FLAGS_chroot/var/lock" 70 sudo chmod 0777 "$FLAGS_chroot/var/lock"
72 71
73 LOCKFILE="$FLAGS_chroot/var/lock/enter_chroot" 72 LOCKFILE="$FLAGS_chroot/var/lock/enter_chroot"
74 73
75 function setup_env { 74 function setup_env {
76 ( 75 (
77 flock 200 76 flock 200
78 echo $$ >> "$LOCKFILE" 77 echo $$ >> "$LOCKFILE"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 then 133 then
135 if [ $(which gclient 2>/dev/null) ]; then 134 if [ $(which gclient 2>/dev/null) ]; then
136 echo "Mounting depot_tools" 135 echo "Mounting depot_tools"
137 DEPOT_TOOLS=$(dirname $(which gclient) ) 136 DEPOT_TOOLS=$(dirname $(which gclient) )
138 mkdir -p "$MOUNTED_PATH" 137 mkdir -p "$MOUNTED_PATH"
139 if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then 138 if ! sudo mount --bind "$DEPOT_TOOLS" "$MOUNTED_PATH"; then
140 echo "depot_tools failed to mount; perhaps it's on NFS?" 139 echo "depot_tools failed to mount; perhaps it's on NFS?"
141 echo "This may impact chromium build." 140 echo "This may impact chromium build."
142 fi 141 fi
143 fi 142 fi
144 fi 143 fi
145 144
146 # Mount fuse device from host machine into chroot and copy over 145 # Mount fuse device from host machine into chroot and copy over
147 # corresponding kernel modules. 146 # corresponding kernel modules.
148 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${FUSE_DEVICE}")" 147 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${FUSE_DEVICE}")"
adlr 2010/04/05 23:31:31 can you remove the call to readlink? readlink will
sosa 2010/04/05 23:41:40 readlink -f only checks the directory, not the las
149 if [ -z "$(mount | grep -F "on ${MOUNTED_PATH} ")" ] && \ 148 if [ -z "$(mount | grep -F "on ${MOUNTED_PATH} ")" ] && \
150 [ -c "${FUSE_DEVICE}" ] ; then 149 [ -c "${FUSE_DEVICE}" ] ; then
151 if [ -c "${FUSE_DEVICE}" ] ; then 150 echo "Attempting to mount fuse device for gmergefs"
152 echo "Mounting fuse device" 151 sudo touch "${MOUNTED_PATH}"
153 sudo touch "${MOUNTED_PATH}" 152 sudo mount --bind "${FUSE_DEVICE}" "${MOUNTED_PATH}"
154 sudo mount --bind "${FUSE_DEVICE}" "${MOUNTED_PATH}" 153 sudo modprobe fuse 2> /dev/null ||\
155 INNER_MOD_PATH="$(readlink -f "${FLAGS_chroot}${KERNEL_MODULES_ROOT}")" 154 echo "-- Note: modprobe fuse failed. gmergefs will not work"
156 if [ ! -f "${INNER_MOD_PATH}/modules.dep" ] ; then 155 fi
157 sudo mkdir -p "${INNER_MOD_PATH}/kernel/fs/fuse" 156
158 sudo cp -fu "${KERNEL_MODULES_ROOT}/modules.dep" "${INNER_MOD_PATH}"
159 if [ -f "${KERNEL_MODULES_ROOT}/kernel/fs/fuse/fuse.ko" ] ; then
160 sudo cp -fu "${KERNEL_MODULES_ROOT}/kernel/fs/fuse/fuse.ko" \
161 "${INNER_MOD_PATH}/kernel/fs/fuse"
162 else
163 echo "Warning: Fuse device found but no modules for running kernel"
164 echo "gmergefs will not work"
165 fi
166 fi
167 else
168 echo "Warning: Fuse device not found. gmergefs will not work"
169 fi
170 fi
171
172 ) 200>>"$LOCKFILE" || die "setup_env failed" 157 ) 200>>"$LOCKFILE" || die "setup_env failed"
173 } 158 }
174 159
175 function teardown_env { 160 function teardown_env {
176 # Only teardown if we're the last enter_chroot to die 161 # Only teardown if we're the last enter_chroot to die
177 ( 162 (
178 flock 200 163 flock 200
179 164
180 # check each pid in $LOCKFILE to see if it's died unexpectedly 165 # check each pid in $LOCKFILE to see if it's died unexpectedly
181 TMP_LOCKFILE="$LOCKFILE.tmp" 166 TMP_LOCKFILE="$LOCKFILE.tmp"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 245
261 # Run command or interactive shell. Also include the non-chrooted path to 246 # Run command or interactive shell. Also include the non-chrooted path to
262 # the source trunk for scripts that may need to print it (e.g. 247 # the source trunk for scripts that may need to print it (e.g.
263 # build_image.sh). 248 # build_image.sh).
264 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ 249 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \
265 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" 250 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@"
266 251
267 # Remove trap and explicitly unmount 252 # Remove trap and explicitly unmount
268 trap - EXIT 253 trap - EXIT
269 teardown_env 254 teardown_env
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698