OLD | NEW |
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 # Script to create a Chrome OS dev recovery image using a dev install shim | 7 # Script to create a Chrome OS dev recovery image using a dev install shim |
8 | 8 |
9 # Source constants and utility functions | 9 # Source constants and utility functions |
10 . "$(dirname "$0")/resize_stateful_partition.sh" | 10 . "$(dirname "$0")/resize_stateful_partition.sh" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 local resized_sectors=$(enlarge_partition_image $temp_state $PAYLOAD_DIR_SIZE) | 87 local resized_sectors=$(enlarge_partition_image $temp_state $PAYLOAD_DIR_SIZE) |
88 | 88 |
89 # Mount resized stateful FS and copy payload content to its root directory | 89 # Mount resized stateful FS and copy payload content to its root directory |
90 local temp_mnt=$(mktemp -d "/tmp/temp_mnt.XXXXXX") | 90 local temp_mnt=$(mktemp -d "/tmp/temp_mnt.XXXXXX") |
91 local loop_dev=$(get_loop_dev) | 91 local loop_dev=$(get_loop_dev) |
92 trap "cleanup_loop_dev ${loop_dev}" EXIT | 92 trap "cleanup_loop_dev ${loop_dev}" EXIT |
93 mkdir -p "${temp_mnt}" | 93 mkdir -p "${temp_mnt}" |
94 sudo mount -o loop=${loop_dev} "${temp_state}" "${temp_mnt}" | 94 sudo mount -o loop=${loop_dev} "${temp_state}" "${temp_mnt}" |
95 trap "umount_from_loop_dev ${temp_mnt} && rm -f \"${temp_state}\"" EXIT | 95 trap "umount_from_loop_dev ${temp_mnt} && rm -f \"${temp_state}\"" EXIT |
96 sudo cp -R "${FLAGS_payload_dir}" "${temp_mnt}" | 96 sudo cp -R "${FLAGS_payload_dir}" "${temp_mnt}/dev_payload" |
97 sudo mv "${temp_mnt}/$(basename ${FLAGS_payload_dir})" \ | 97 |
98 "${temp_mnt}/dev_payload" | |
99 # Mark image as dev recovery | 98 # Mark image as dev recovery |
100 sudo touch "${temp_mnt}/.recovery" | 99 sudo touch "${temp_mnt}/.recovery" |
101 sudo touch "${temp_mnt}/.dev_recovery" | 100 sudo touch "${temp_mnt}/.dev_recovery" |
102 | 101 |
103 # TODO(tgao): handle install script (for default and custom cases) | 102 # TODO(tgao): handle install script (for default and custom cases) |
104 (update_partition_table $FLAGS_dev_install_shim $temp_state \ | 103 (update_partition_table $FLAGS_dev_install_shim $temp_state \ |
105 $resized_sectors $TEMP_IMG) | 104 $resized_sectors $TEMP_IMG) |
106 | 105 |
107 # trap handler will clean up loop device and temp mount point | 106 # trap handler will clean up loop device and temp mount point |
108 } | 107 } |
109 | 108 |
110 # Main | 109 # Main |
111 DST_PATH="${INSTALL_SHIM_DIR}/${DEV_RECOVERY_IMAGE}" | 110 DST_PATH="${INSTALL_SHIM_DIR}/${DEV_RECOVERY_IMAGE}" |
112 info "Attempting to create dev recovery image using dev install shim \ | 111 info "Attempting to create dev recovery image using dev install shim \ |
113 ${FLAGS_dev_install_shim}" | 112 ${FLAGS_dev_install_shim}" |
114 (create_dev_recovery_image) | 113 (create_dev_recovery_image) |
115 | 114 |
116 if [ -n ${TEMP_IMG} ] && [ -f ${TEMP_IMG} ]; then | 115 if [ -n ${TEMP_IMG} ] && [ -f ${TEMP_IMG} ]; then |
117 mv -f $TEMP_IMG $DST_PATH | 116 mv -f $TEMP_IMG $DST_PATH |
118 info "Dev recovery image created at ${DST_PATH}" | 117 info "Dev recovery image created at ${DST_PATH}" |
119 else | 118 else |
120 info "Failed to create developer recovery image" | 119 info "Failed to create developer recovery image" |
121 fi | 120 fi |
OLD | NEW |