From 99c6a289f4bd4dd514b0504eb3547bcd936f48be Mon Sep 17 00:00:00 2001 From: Chris Masone Date: Tue, 11 May 2010 09:20:00 -0700 Subject: [PATCH] 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 --- enter_chroot.sh | 9 +++++++++ image_to_usb.sh | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/enter_chroot.sh b/enter_chroot.sh index 77b4722897..236aa02c09 100755 --- a/enter_chroot.sh +++ b/enter_chroot.sh @@ -24,6 +24,8 @@ DEFINE_string build_number "" \ "The build-bot build number (when called by buildbot only)." "b" DEFINE_string chrome_root "" \ "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 \ "Set CHROMEOS_OFFICIAL=1 for release builds." @@ -100,6 +102,13 @@ function setup_env { die "Could not mount $MOUNTED_PATH" 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")" if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] then diff --git a/image_to_usb.sh b/image_to_usb.sh index ff1a1bbd80..d1ac0b28a2 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -232,7 +232,14 @@ then echo "Attempting to unmount any mounts on the USB device..." for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}') 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 sleep 3