mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-26 21:11:54 +01:00
Allow file in --from arg
* mount_gpt_image.sh * image_to_usb.sh BUG=chromium-os:12367 TEST=mount w/ --from file, check failure with file and -i, block dev and -i, check unmount, check image_to_usb, check --from dir -i file Change-Id: I8d8604ee7ee83513edd687b0a66cda44f64db1f8 Review URL: http://codereview.chromium.org/6685101
This commit is contained in:
parent
ce8384d7c6
commit
f9c49add44
@ -40,7 +40,7 @@ get_default_board
|
||||
# Flags
|
||||
DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built"
|
||||
DEFINE_string from "" \
|
||||
"Directory containing ${CHROMEOS_IMAGE_NAME}"
|
||||
"Directory containing ${CHROMEOS_IMAGE_NAME}, or filename"
|
||||
DEFINE_string to "/dev/sdX" "${DEFAULT_TO_HELP}"
|
||||
DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
|
||||
DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
|
||||
@ -72,6 +72,15 @@ if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Allow --from /foo/file.bin
|
||||
if [ -f "${FLAGS_from}" ]; then
|
||||
pathname=$(dirname "${FLAGS_from}")
|
||||
filename=$(basename "${FLAGS_from}")
|
||||
FLAGS_image_name="${filename}"
|
||||
FLAGS_from="${pathname}"
|
||||
fi
|
||||
|
||||
|
||||
# Require autotest for manucaturing image.
|
||||
if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then
|
||||
echo "Factory image requires --test_image, setting."
|
||||
|
||||
@ -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}" \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user