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

Side by Side Diff: mod_image_for_recovery.sh

Issue 2948005: remove handling of kernel verification block from recovery image (Closed) Base URL: ssh://git@chromiumos-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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 # Script to modify a pristine/dev Chrome OS image to be used for recovery 7 # Script to modify a pristine/dev Chrome OS image to be used for recovery
8 8
9 . "$(dirname "$0")/common.sh" 9 . "$(dirname "$0")/common.sh"
10 10
(...skipping 28 matching lines...) Expand all
39 STATEFUL_FS_DIR="${OUTPUT_DIR}/stateful_partition" 39 STATEFUL_FS_DIR="${OUTPUT_DIR}/stateful_partition"
40 RECOVERY_IMAGE="recovery_image.bin" 40 RECOVERY_IMAGE="recovery_image.bin"
41 41
42 mount_gpt_cleanup() { 42 mount_gpt_cleanup() {
43 "${SCRIPTS_DIR}/mount_gpt_image.sh" -u -r "$1" -s "$2" 43 "${SCRIPTS_DIR}/mount_gpt_image.sh" -u -r "$1" -s "$2"
44 } 44 }
45 45
46 # Modifies an existing image for recovery use 46 # Modifies an existing image for recovery use
47 update_recovery_packages() { 47 update_recovery_packages() {
48 local image_name=$1 48 local image_name=$1
49 local sector_size=512 # sector size in bytes
50 local num_sectors_vb=128 # number of sectors in kernel verification blob
51 # Start offset of kernel A (aligned to 4096-sector boundary)
52 local start_kern_a=4096
53 local vb_file="${STATEFUL_FS_DIR}/verification_blob.kernel"
54 49
55 echo "Modifying image ${image_name} for recovery use" 50 echo "Modifying image ${image_name} for recovery use"
56 51
57 trap "mount_gpt_cleanup \"${ROOT_FS_DIR}\" \"${STATEFUL_FS_DIR}\"" EXIT 52 trap "mount_gpt_cleanup \"${ROOT_FS_DIR}\" \"${STATEFUL_FS_DIR}\"" EXIT
58 53
59 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ 54 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \
60 --image "$( basename ${image_name} )" -r "${ROOT_FS_DIR}" \ 55 --image "$( basename ${image_name} )" -r "${ROOT_FS_DIR}" \
61 -s "${STATEFUL_FS_DIR}" 56 -s "${STATEFUL_FS_DIR}"
62 57
63 # Mark the image as a recovery image (needed for recovery boot) 58 # Mark the image as a recovery image (needed for recovery boot)
64 sudo touch "${STATEFUL_FS_DIR}/.recovery" 59 sudo touch "${STATEFUL_FS_DIR}/.recovery"
65 60
66 # Copy verification blob out of kernel A into stateful partition
67 # so that we can restore it during recovery
68 sudo touch $vb_file
69 echo "Backing up kernel verification blob onto stateful partition ..."
70 sudo dd if="$image_name" of="$vb_file" skip=$start_kern_a bs=$sector_size \
71 count=$num_sectors_vb conv=notrunc
72
73 # Overwrite verification blob with recovery image verification blob
74 # TODO(tgao): resign kernel for recovery image
75 echo "Overwrite kernel verification blob with resigned blob for recovery..."
76 sudo dd if=/dev/zero of="$image_name" seek=$start_kern_a bs=$sector_size \
77 count=$num_sectors_vb conv=notrunc
78
79 trap - EXIT 61 trap - EXIT
80 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ 62 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \
81 -s "${STATEFUL_FS_DIR}" 63 -s "${STATEFUL_FS_DIR}"
82 } 64 }
83 65
84 # Main 66 # Main
85 67
86 DST_PATH="${OUTPUT_DIR}/${RECOVERY_IMAGE}" 68 DST_PATH="${OUTPUT_DIR}/${RECOVERY_IMAGE}"
87 echo "Making a copy of original image ${SRC_PATH}" 69 echo "Making a copy of original image ${SRC_PATH}"
88 cp $SRC_PATH $DST_PATH 70 cp $SRC_PATH $DST_PATH
89 update_recovery_packages $DST_PATH 71 update_recovery_packages $DST_PATH
90 echo "Recovery image created at ${DST_PATH}" 72 echo "Recovery image created at ${DST_PATH}"
OLDNEW
« 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