add the ability to umount automounted devices from within the chroot

Talked to kmixter, and we felt that bindmounting the directory in
which the host os creates mount points for automounted external
devices is the cleanest solution to the inside/outside the chroot problem.
By doing this, image_to_usb can be run from inside the chroot without concern.
That means that (as far as I understand) the factory install flow can all be
done inside the chroot, as well as modding images for test and everything else.

Review URL: http://codereview.chromium.org/1991006
This commit is contained in:
Chris Masone 2010-05-11 09:20:00 -07:00
parent 19197c8ac8
commit 99c6a289f4
2 changed files with 17 additions and 1 deletions

View File

@ -24,6 +24,8 @@ DEFINE_string build_number "" \
"The build-bot build number (when called by buildbot only)." "b" "The build-bot build number (when called by buildbot only)." "b"
DEFINE_string chrome_root "" \ DEFINE_string chrome_root "" \
"The root of your chrome browser source. Should contain a 'src' subdir." "The root of your chrome browser source. Should contain a 'src' subdir."
DEFINE_string automount_dir "/media" \
"The directory in which your host OS creates mountpoints for external media."
DEFINE_boolean official_build $FLAGS_FALSE \ DEFINE_boolean official_build $FLAGS_FALSE \
"Set CHROMEOS_OFFICIAL=1 for release builds." "Set CHROMEOS_OFFICIAL=1 for release builds."
@ -100,6 +102,13 @@ function setup_env {
die "Could not mount $MOUNTED_PATH" die "Could not mount $MOUNTED_PATH"
fi fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${FLAGS_automount_dir}")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
sudo mount --bind "${FLAGS_automount_dir}" "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")" MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then then

View File

@ -232,7 +232,14 @@ then
echo "Attempting to unmount any mounts on the USB device..." echo "Attempting to unmount any mounts on the USB device..."
for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}') for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}')
do do
sudo umount "$i" if sudo umount "$i" 2>&1 >/dev/null | grep "not found"; then
echo
echo "The device you have specified is already mounted at some point "
echo "that is not visible from inside the chroot. Please unmount the "
echo "device manually from outside the chroot and try again."
echo
exit 1
fi
done done
sleep 3 sleep 3