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

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

Issue 1991006: add the ability to umount automounted devices from within the chroot (Closed) Base URL: ssh://git@chromiumos-git//chromeos
Patch Set: Created 10 years, 7 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 | src/scripts/image_to_usb.sh » ('j') | 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.
11 . "$(dirname "$0")/common.sh" 11 . "$(dirname "$0")/common.sh"
12 12
13 # Script must be run outside the chroot and as a regular user. 13 # Script must be run outside the chroot and as a regular user.
14 assert_outside_chroot 14 assert_outside_chroot
15 assert_not_root_user 15 assert_not_root_user
16 16
17 # Define command line flags 17 # Define command line flags
18 # See http://code.google.com/p/shflags/wiki/Documentation10x 18 # See http://code.google.com/p/shflags/wiki/Documentation10x
19 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ 19 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \
20 "The destination dir for the chroot environment." "d" 20 "The destination dir for the chroot environment." "d"
21 DEFINE_string trunk "$GCLIENT_ROOT" \ 21 DEFINE_string trunk "$GCLIENT_ROOT" \
22 "The source trunk to bind mount within the chroot." "s" 22 "The source trunk to bind mount within the chroot." "s"
23 DEFINE_string build_number "" \ 23 DEFINE_string build_number "" \
24 "The build-bot build number (when called by buildbot only)." "b" 24 "The build-bot build number (when called by buildbot only)." "b"
25 DEFINE_string chrome_root "" \ 25 DEFINE_string chrome_root "" \
26 "The root of your chrome browser source. Should contain a 'src' subdir." 26 "The root of your chrome browser source. Should contain a 'src' subdir."
27 DEFINE_string automount_dir "/media" \
28 "The directory in which your host OS creates mountpoints for external media."
27 29
28 DEFINE_boolean official_build $FLAGS_FALSE \ 30 DEFINE_boolean official_build $FLAGS_FALSE \
29 "Set CHROMEOS_OFFICIAL=1 for release builds." 31 "Set CHROMEOS_OFFICIAL=1 for release builds."
30 DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts." 32 DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts."
31 DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts." 33 DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts."
32 34
33 # More useful help 35 # More useful help
34 FLAGS_HELP="USAGE: $0 [flags] [VAR=value] [-- \"command\"] 36 FLAGS_HELP="USAGE: $0 [flags] [VAR=value] [-- \"command\"]
35 37
36 One or more VAR=value pairs can be specified to export variables into 38 One or more VAR=value pairs can be specified to export variables into
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 die "Could not mount $MOUNTED_PATH" 95 die "Could not mount $MOUNTED_PATH"
94 fi 96 fi
95 97
96 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev")" 98 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}/dev")"
97 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] 99 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
98 then 100 then
99 sudo mount --bind /dev "$MOUNTED_PATH" || \ 101 sudo mount --bind /dev "$MOUNTED_PATH" || \
100 die "Could not mount $MOUNTED_PATH" 102 die "Could not mount $MOUNTED_PATH"
101 fi 103 fi
102 104
105 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${FLAGS_automount_dir}")"
106 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
107 then
108 sudo mount --bind "${FLAGS_automount_dir}" "$MOUNTED_PATH" || \
109 die "Could not mount $MOUNTED_PATH"
110 fi
111
103 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")" 112 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}$CHROOT_TRUNK_DIR")"
104 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] 113 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
105 then 114 then
106 sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \ 115 sudo mount --bind "$FLAGS_trunk" "$MOUNTED_PATH" || \
107 die "Could not mount $MOUNTED_PATH" 116 die "Could not mount $MOUNTED_PATH"
108 fi 117 fi
109 118
110 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")" 119 MOUNTED_PATH="$(readlink -f "${FLAGS_chroot}${INNER_CHROME_ROOT}")"
111 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ] 120 if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
112 then 121 then
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 248
240 # Run command or interactive shell. Also include the non-chrooted path to 249 # Run command or interactive shell. Also include the non-chrooted path to
241 # the source trunk for scripts that may need to print it (e.g. 250 # the source trunk for scripts that may need to print it (e.g.
242 # build_image.sh). 251 # build_image.sh).
243 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \ 252 sudo chroot "$FLAGS_chroot" sudo -i -u $USER $CHROOT_PASSTHRU \
244 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@" 253 EXTERNAL_TRUNK_PATH="${FLAGS_trunk}" LANG=C "$@"
245 254
246 # Remove trap and explicitly unmount 255 # Remove trap and explicitly unmount
247 trap - EXIT 256 trap - EXIT
248 teardown_env 257 teardown_env
OLDNEW
« no previous file with comments | « no previous file | src/scripts/image_to_usb.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698