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

Side by Side Diff: mount_gpt_image.sh

Issue 6685101: Allow file in --from arg (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: comments Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « image_to_usb.sh ('k') | 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) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 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 # Helper script that mounts chromium os image from a device or directory 7 # Helper script that mounts chromium os image from a device or directory
8 # and creates mount points for /var and /usr/local (if in dev_mode). 8 # and creates mount points for /var and /usr/local (if in dev_mode).
9 9
10 # --- BEGIN COMMON.SH BOILERPLATE --- 10 # --- BEGIN COMMON.SH BOILERPLATE ---
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 # Flags. 44 # Flags.
45 DEFINE_string board "$DEFAULT_BOARD" \ 45 DEFINE_string board "$DEFAULT_BOARD" \
46 "The board for which the image was built." b 46 "The board for which the image was built." b
47 DEFINE_boolean read_only $FLAGS_FALSE \ 47 DEFINE_boolean read_only $FLAGS_FALSE \
48 "Mount in read only mode -- skips stateful items." 48 "Mount in read only mode -- skips stateful items."
49 DEFINE_boolean safe $FLAGS_FALSE \ 49 DEFINE_boolean safe $FLAGS_FALSE \
50 "Mount rootfs in read only mode." 50 "Mount rootfs in read only mode."
51 DEFINE_boolean unmount $FLAGS_FALSE \ 51 DEFINE_boolean unmount $FLAGS_FALSE \
52 "Unmount previously mounted dir." u 52 "Unmount previously mounted dir." u
53 DEFINE_string from "/dev/sdc" \ 53 DEFINE_string from "/dev/sdc" \
54 "Directory containing image or device with image on it" f 54 "Directory, image, or device with image on it" f
55 DEFINE_string image "chromiumos_image.bin"\ 55 DEFINE_string image "chromiumos_image.bin"\
56 "Name of the bin file if a directory is specified in the from flag" i 56 "Name of the bin file if a directory is specified in the from flag" i
57 DEFINE_string "rootfs_mountpt" "/tmp/m" "Mount point for rootfs" "r" 57 DEFINE_string "rootfs_mountpt" "/tmp/m" "Mount point for rootfs" "r"
58 DEFINE_string "stateful_mountpt" "/tmp/s" \ 58 DEFINE_string "stateful_mountpt" "/tmp/s" \
59 "Mount point for stateful partition" "s" 59 "Mount point for stateful partition" "s"
60 DEFINE_string "esp_mountpt" "" \ 60 DEFINE_string "esp_mountpt" "" \
61 "Mount point for esp partition" "e" 61 "Mount point for esp partition" "e"
62 DEFINE_boolean most_recent ${FLAGS_FALSE} "Use the most recent image dir" m 62 DEFINE_boolean most_recent ${FLAGS_FALSE} "Use the most recent image dir" m
63 63
64 # Parse flags 64 # Parse flags
65 FLAGS "$@" || exit 1 65 FLAGS "$@" || exit 1
66 eval set -- "${FLAGS_ARGV}" 66 eval set -- "${FLAGS_ARGV}"
67 67
68 # Die on error 68 # Die on error
69 set -e 69 set -e
70 70
71 # Check for conflicting args.
72 # If --from is a block device, --image can't also be specified.
73 if [ -b "${FLAGS_from}" ]; then
74 if [ "${FLAGS_image}" != "chromiumos_image.bin" ]; then
75 die "-i ${FLAGS_image} can't be used with block device ${FLAGS_from}"
76 fi
77 fi
78
79 # Allow --from /foo/file.bin
80 if [ -f "${FLAGS_from}" ]; then
81 # If --from is specified as a file, --image cannot be also specified.
82 if [ "${FLAGS_image}" != "chromiumos_image.bin" ]; then
83 die "-i ${FLAGS_image} can't be used with --from file ${FLAGS_from}"
84 fi
85 pathname=$(dirname "${FLAGS_from}")
86 filename=$(basename "${FLAGS_from}")
87 FLAGS_image="${filename}"
88 FLAGS_from="${pathname}"
89 fi
90
71 # Common unmounts for either a device or directory 91 # Common unmounts for either a device or directory
72 function unmount_image() { 92 function unmount_image() {
73 echo "Unmounting image from ${FLAGS_stateful_mountpt}" \ 93 echo "Unmounting image from ${FLAGS_stateful_mountpt}" \
74 "and ${FLAGS_rootfs_mountpt}" 94 "and ${FLAGS_rootfs_mountpt}"
75 # Don't die on error to force cleanup 95 # Don't die on error to force cleanup
76 set +e 96 set +e
77 # Reset symlinks in /usr/local. 97 # Reset symlinks in /usr/local.
78 if mount | egrep ".* ${FLAGS_stateful_mountpt} .*\(rw,"; then 98 if mount | egrep ".* ${FLAGS_stateful_mountpt} .*\(rw,"; then
79 setup_symlinks_on_root "/usr/local" "/var" \ 99 setup_symlinks_on_root "/usr/local" "/var" \
80 "${FLAGS_stateful_mountpt}" 100 "${FLAGS_stateful_mountpt}"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 FLAGS_from=`eval readlink -f ${FLAGS_from}` 201 FLAGS_from=`eval readlink -f ${FLAGS_from}`
182 FLAGS_rootfs_mountpt=`eval readlink -f ${FLAGS_rootfs_mountpt}` 202 FLAGS_rootfs_mountpt=`eval readlink -f ${FLAGS_rootfs_mountpt}`
183 FLAGS_stateful_mountpt=`eval readlink -f ${FLAGS_stateful_mountpt}` 203 FLAGS_stateful_mountpt=`eval readlink -f ${FLAGS_stateful_mountpt}`
184 204
185 # Perform desired operation. 205 # Perform desired operation.
186 if [ ${FLAGS_unmount} -eq ${FLAGS_TRUE} ] ; then 206 if [ ${FLAGS_unmount} -eq ${FLAGS_TRUE} ] ; then
187 unmount_image 207 unmount_image
188 else 208 else
189 mount_image 209 mount_image
190 fi 210 fi
OLDNEW
« no previous file with comments | « image_to_usb.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698