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

Unified Diff: mod_image_for_recovery.sh

Issue 3007005: issue 2825046 (Closed) Base URL: http://src.chromium.org/git/crosutils.git
Patch Set: Created 10 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mod_image_for_recovery.sh
diff --git a/mod_image_for_recovery.sh b/mod_image_for_recovery.sh
index faa240c3cd7560f665f8559d73271895e842b7ff..7d4066a86c2a34e6572241e441da892deebdda74 100755
--- a/mod_image_for_recovery.sh
+++ b/mod_image_for_recovery.sh
@@ -8,35 +8,50 @@
. "$(dirname "$0")/common.sh"
+# Load functions and constants for chromeos-install
+. "$(dirname "$0")/chromeos-common.sh"
+
# Script must be run inside the chroot.
restart_in_chroot_if_needed $*
-DEFINE_string image_dir "" \
- "Directory to pristine/base image."
-DEFINE_string image_name "chromiumos_image.bin" \
- "Name of Chrome OS image to modify."
+get_default_board
+
+DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built"
+DEFINE_string image "" "Location of the rootfs raw image file"
# Parse command line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
-set -e
+# No board, no default and no image set then we can't find the image
+if [ -z $FLAGS_image ] && [ -z $FLAGS_board ] ; then
+ setup_board_warning
+ die "mod_image_for_recovery failed. No board set and no image set"
+fi
-if [ -z $FLAGS_image_dir ] || [ ! -d $FLAGS_image_dir ]; then
- echo "Error: invalid flag --image_dir"
- exit 1
+# We have a board name but no image set. Use image at default location
+if [ -z $FLAGS_image ] ; then
+ IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
+ FILENAME="chromiumos_image.bin"
+ FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/${FILENAME}"
fi
-SRC_PATH="${FLAGS_image_dir}/${FLAGS_image_name}"
-if [ -z $FLAGS_image_name ] || [ ! -f $SRC_PATH ]; then
- echo "Error: invalid flag --image_name"
+# Turn path into an absolute path.
+FLAGS_image=$(eval readlink -f ${FLAGS_image})
+
+# Abort early if we can't find the image
+if [ ! -f $FLAGS_image ] ; then
+ echo "No image found at $FLAGS_image"
exit 1
fi
+set -e
+
# Constants
-OUTPUT_DIR=$FLAGS_image_dir
-ROOT_FS_DIR="${OUTPUT_DIR}/rootfs"
-STATEFUL_FS_DIR="${OUTPUT_DIR}/stateful_partition"
+IMAGE_DIR="$(dirname "$FLAGS_image")"
+IMAGE_NAME="$(basename "$FLAGS_image")"
+ROOT_FS_DIR="$IMAGE_DIR/rootfs"
+STATEFUL_DIR="$IMAGE_DIR/stateful_partition"
RECOVERY_IMAGE="recovery_image.bin"
mount_gpt_cleanup() {
@@ -49,24 +64,24 @@ update_recovery_packages() {
echo "Modifying image ${image_name} for recovery use"
- trap "mount_gpt_cleanup \"${ROOT_FS_DIR}\" \"${STATEFUL_FS_DIR}\"" EXIT
+ trap "mount_gpt_cleanup \"${ROOT_FS_DIR}\" \"${STATEFUL_DIR}\"" EXIT
- ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \
+ ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${IMAGE_DIR}" \
--image "$( basename ${image_name} )" -r "${ROOT_FS_DIR}" \
- -s "${STATEFUL_FS_DIR}"
+ -s "${STATEFUL_DIR}"
# Mark the image as a recovery image (needed for recovery boot)
- sudo touch "${STATEFUL_FS_DIR}/.recovery"
+ sudo touch "${STATEFUL_DIR}/.recovery"
trap - EXIT
${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \
- -s "${STATEFUL_FS_DIR}"
+ -s "${STATEFUL_DIR}"
}
# Main
-DST_PATH="${OUTPUT_DIR}/${RECOVERY_IMAGE}"
-echo "Making a copy of original image ${SRC_PATH}"
-cp $SRC_PATH $DST_PATH
+DST_PATH="${IMAGE_DIR}/${RECOVERY_IMAGE}"
+echo "Making a copy of original image ${FLAGS_image}"
+cp $FLAGS_image $DST_PATH
update_recovery_packages $DST_PATH
echo "Recovery image created at ${DST_PATH}"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698