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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « image_to_usb.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mount_gpt_image.sh
diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh
index 87324cbbbe617b8bf986162add7b167d8268fb35..dc0491a5d176f35a57d11c876ea40326a60b3f22 100755
--- a/mount_gpt_image.sh
+++ b/mount_gpt_image.sh
@@ -51,7 +51,7 @@ DEFINE_boolean safe $FLAGS_FALSE \
DEFINE_boolean unmount $FLAGS_FALSE \
"Unmount previously mounted dir." u
DEFINE_string from "/dev/sdc" \
- "Directory containing image or device with image on it" f
+ "Directory, image, or device with image on it" f
DEFINE_string image "chromiumos_image.bin"\
"Name of the bin file if a directory is specified in the from flag" i
DEFINE_string "rootfs_mountpt" "/tmp/m" "Mount point for rootfs" "r"
@@ -68,6 +68,26 @@ eval set -- "${FLAGS_ARGV}"
# Die on error
set -e
+# Check for conflicting args.
+# If --from is a block device, --image can't also be specified.
+if [ -b "${FLAGS_from}" ]; then
+ if [ "${FLAGS_image}" != "chromiumos_image.bin" ]; then
+ die "-i ${FLAGS_image} can't be used with block device ${FLAGS_from}"
+ fi
+fi
+
+# Allow --from /foo/file.bin
+if [ -f "${FLAGS_from}" ]; then
+ # If --from is specified as a file, --image cannot be also specified.
+ if [ "${FLAGS_image}" != "chromiumos_image.bin" ]; then
+ die "-i ${FLAGS_image} can't be used with --from file ${FLAGS_from}"
+ fi
+ pathname=$(dirname "${FLAGS_from}")
+ filename=$(basename "${FLAGS_from}")
+ FLAGS_image="${filename}"
+ FLAGS_from="${pathname}"
+fi
+
# Common unmounts for either a device or directory
function unmount_image() {
echo "Unmounting image from ${FLAGS_stateful_mountpt}" \
« 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