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

Side by Side Diff: scripts/image_signing/sign_official_build.sh

Issue 6368064: Allow signing scripts to (optionally) set the firmware and kernel versions (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: ws fix for real Created 9 years, 10 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 | Annotate | Revision Log
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 # Sign the final build image using the "official" keys. 7 # Sign the final build image using the "official" keys.
8 # 8 #
9 # Prerequisite tools needed in the system path: 9 # Prerequisite tools needed in the system path:
10 # 10 #
11 # gbb_utility (from src/platform/vboot_reference) 11 # gbb_utility (from src/platform/vboot_reference)
12 # vbutil_kernel (from src/platform/vboot_reference) 12 # vbutil_kernel (from src/platform/vboot_reference)
13 # cgpt (from src/platform/vboot_reference) 13 # cgpt (from src/platform/vboot_reference)
14 # dump_kernel_config (from src/platform/vboot_reference) 14 # dump_kernel_config (from src/platform/vboot_reference)
15 # verity (from src/platform/verity) 15 # verity (from src/platform/verity)
16 # load_kernel_test (from src/platform/vboot_reference) 16 # load_kernel_test (from src/platform/vboot_reference)
17 # dumpe2fs 17 # dumpe2fs
18 # sha1sum 18 # sha1sum
19 19
20 # Load common constants and variables. 20 # Load common constants and variables.
21 . "$(dirname "$0")/common.sh" 21 . "$(dirname "$0")/common.sh"
22 22
23 # Print usage string 23 # Print usage string
24 usage() { 24 usage() {
25 cat <<EOF 25 cat <<EOF
26 Usage: $PROG <type> input_image /path/to/keys/dir [output_image] 26 Usage: $PROG <type> input_image /path/to/keys/dir [output_image] [version_file]
27 where <type> is one of: 27 where <type> is one of:
28 ssd (sign an SSD image) 28 ssd (sign an SSD image)
29 recovery (sign a USB recovery image) 29 recovery (sign a USB recovery image)
30 install (sign a factory install image) 30 install (sign a factory install image)
31 usb (sign an image to boot directly from USB) 31 usb (sign an image to boot directly from USB)
32 verify (verify an image including rootfs hashes) 32 verify (verify an image including rootfs hashes)
33 33
34 If you are signing an image, you must specify an [output_image]. 34 output_image: File name of the signed output image
35 version_file: File name of where to read the kernel and firmware versions.
36
37 If you are signing an image, you must specify an [output_image] and
38 optionally, a [version_file].
39
35 EOF 40 EOF
36 } 41 }
37 42
38 if [ $# -ne 3 ] && [ $# -ne 4 ]; then 43 if [ $# -lt 3 ] || [ $# -gt 5 ]; then
39 usage 44 usage
40 exit 1 45 exit 1
41 fi 46 fi
42 47
43 # Abort on errors. 48 # Abort on errors.
44 set -e 49 set -e
45 50
46 # Make sure the tools we need are available. 51 # Make sure the tools we need are available.
47 for prereqs in gbb_utility vbutil_kernel cgpt dump_kernel_config verity \ 52 for prereqs in gbb_utility vbutil_kernel cgpt dump_kernel_config verity \
48 load_kernel_test dumpe2fs sha1sum e2fsck; 53 load_kernel_test dumpe2fs sha1sum e2fsck;
49 do 54 do
50 type -P "${prereqs}" &>/dev/null || \ 55 type -P "${prereqs}" &>/dev/null || \
51 { echo "${prereqs} tool not found."; exit 1; } 56 { echo "${prereqs} tool not found."; exit 1; }
52 done 57 done
53 58
54 TYPE=$1 59 TYPE=$1
55 INPUT_IMAGE=$2 60 INPUT_IMAGE=$2
56 KEY_DIR=$3 61 KEY_DIR=$3
57 OUTPUT_IMAGE=$4 62 OUTPUT_IMAGE=$4
63 VERSION_FILE=$5
64
65 FIRMWARE_VERSION=1
66 KERNEL_VERSION=1
58 67
59 # Get current rootfs hash and kernel command line 68 # Get current rootfs hash and kernel command line
60 # ARGS: IMAGE KERNELPART 69 # ARGS: IMAGE KERNELPART
61 grab_kernel_config() { 70 grab_kernel_config() {
62 local image=$1 71 local image=$1
63 local kernelpart=$2 # Kernel partition number to grab. 72 local kernelpart=$2 # Kernel partition number to grab.
64 # Grab the existing kernel partition and get the kernel config. 73 # Grab the existing kernel partition and get the kernel config.
65 temp_kimage=$(make_temp_file) 74 temp_kimage=$(make_temp_file)
66 extract_image_partition ${image} ${kernelpart} ${temp_kimage} 75 extract_image_partition ${image} ${kernelpart} ${temp_kimage}
67 dump_kernel_config ${temp_kimage} 76 dump_kernel_config ${temp_kimage}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 127 }
119 128
120 # Re-calculate rootfs hash, update rootfs and kernel command line. 129 # Re-calculate rootfs hash, update rootfs and kernel command line.
121 # Args: IMAGE KEYBLOCK PRIVATEKEY KERNELPART 130 # Args: IMAGE KEYBLOCK PRIVATEKEY KERNELPART
122 update_rootfs_hash() { 131 update_rootfs_hash() {
123 local image=$1 # Input image. 132 local image=$1 # Input image.
124 local keyblock=$2 # Keyblock for re-generating signed kernel partition 133 local keyblock=$2 # Keyblock for re-generating signed kernel partition
125 local signprivate=$3 # Private key to use for signing. 134 local signprivate=$3 # Private key to use for signing.
126 local kernelpart=$4 # Kernel partition number to update (usually 2 or 4) 135 local kernelpart=$4 # Kernel partition number to update (usually 2 or 4)
127 136
128 echo "Updating rootfs hash and updating config for Kernel partition " \ 137 echo "Updating rootfs hash and updating config for Kernel partition" \
129 "$kernelpart" 138 "$kernelpart"
130 139
131 # check and clear need_to_resign tag 140 # check and clear need_to_resign tag
132 local rootfs_dir=$(make_temp_dir) 141 local rootfs_dir=$(make_temp_dir)
133 mount_image_partition_ro "${image}" 3 "${rootfs_dir}" 142 mount_image_partition_ro "${image}" 3 "${rootfs_dir}"
134 if has_needs_to_be_resigned_tag "${rootfs_dir}"; then 143 if has_needs_to_be_resigned_tag "${rootfs_dir}"; then
135 # remount as RW 144 # remount as RW
136 sudo umount -d "${rootfs_dir}" 145 sudo umount -d "${rootfs_dir}"
137 mount_image_partition "${image}" 3 "${rootfs_dir}" 146 mount_image_partition "${image}" 3 "${rootfs_dir}"
138 sudo rm -f "${rootfs_dir}/${TAG_NEEDS_TO_BE_SIGNED}" 147 sudo rm -f "${rootfs_dir}/${TAG_NEEDS_TO_BE_SIGNED}"
(...skipping 25 matching lines...) Expand all
164 dd if=${hash_image} of=${rootfs_image} bs=512 \ 173 dd if=${hash_image} of=${rootfs_image} bs=512 \
165 seek=${rootfs_sectors} conv=notrunc 174 seek=${rootfs_sectors} conv=notrunc
166 175
167 local temp_kimage=$(make_temp_file) 176 local temp_kimage=$(make_temp_file)
168 extract_image_partition ${image} ${kernelpart} ${temp_kimage} 177 extract_image_partition ${image} ${kernelpart} ${temp_kimage}
169 # Re-calculate kernel partition signature and command line. 178 # Re-calculate kernel partition signature and command line.
170 local updated_kimage=$(make_temp_file) 179 local updated_kimage=$(make_temp_file)
171 vbutil_kernel --repack ${updated_kimage} \ 180 vbutil_kernel --repack ${updated_kimage} \
172 --keyblock ${keyblock} \ 181 --keyblock ${keyblock} \
173 --signprivate ${signprivate} \ 182 --signprivate ${signprivate} \
183 --version "${KERNEL_VERSION}" \
174 --oldblob ${temp_kimage} \ 184 --oldblob ${temp_kimage} \
175 --config ${temp_config} 185 --config ${temp_config}
176 186
177 replace_image_partition ${image} ${kernelpart} ${updated_kimage} 187 replace_image_partition ${image} ${kernelpart} ${updated_kimage}
178 replace_image_partition ${image} 3 ${rootfs_image} 188 replace_image_partition ${image} 3 ${rootfs_image}
179 } 189 }
180 190
181 # Do a sanity check on the image's rootfs 191 # Do a sanity check on the image's rootfs
182 # ARGS: Image 192 # ARGS: Image
183 verify_image_rootfs() { 193 verify_image_rootfs() {
184 local image=$1 194 local image=$1
185 local rootfs_image=$(make_temp_file) 195 local rootfs_image=$(make_temp_file)
186 extract_image_partition ${image} 3 ${rootfs_image} 196 extract_image_partition ${image} 3 ${rootfs_image}
187 # This flips the read-only compatibility flag, so that e2fsck does not 197 # This flips the read-only compatibility flag, so that e2fsck does not
188 # complain about unknown file system capabilities. 198 # complain about unknown file system capabilities.
189 enable_rw_mount ${rootfs_image} 199 enable_rw_mount ${rootfs_image}
190 echo "Running e2fsck to check root file system for errors" 200 echo "Running e2fsck to check root file system for errors"
191 sudo e2fsck -fn "${rootfs_image}" || 201 sudo e2fsck -fn "${rootfs_image}" ||
192 { echo "Root file system has errors!" && exit 1;} 202 { echo "Root file system has errors!" && exit 1;}
193 } 203 }
194 204
195 # Extracts the firmware update binaries from the a firmware update 205 # Extracts the firmware update binaries from the a firmware update
196 # shell ball (generated by src/platform/firmware/pack_firmware.sh) 206 # shell ball (generated by src/platform/firmware/pack_firmware.sh)
197 # Args: INPUT_SCRIPT OUTPUT_DIR 207 # Args: INPUT_SCRIPT OUTPUT_DIR
198 get_firmwarebin_from_shellball() { 208 get_firmwarebin_from_shellball() {
199 local input=$1 209 local input=$1
200 local output_dir=$2 210 local output_dir=$2
201 if [ -s "${input}" ]; then 211 if [ -s "${input}" ]; then
202 uudecode -o - ${input} | tar -C ${output_dir} -zxf - 2>/dev/null || \ 212 uudecode -o - ${input} | tar -C ${output_dir} -zxf - 2>/dev/null || \
203 { echo "Extracting firmware autoupdate failed." && exit 1; } 213 { echo "Extracting firmware autoupdate failed." && exit 1; }
204 else 214 else
(...skipping 30 matching lines...) Expand all
235 # Replace the root key in the GBB 245 # Replace the root key in the GBB
236 # TODO(gauravsh): Remove when we lock down the R/O portion of firmware. 246 # TODO(gauravsh): Remove when we lock down the R/O portion of firmware.
237 if [ -e "${KEY_DIR}/hwid" ]; then 247 if [ -e "${KEY_DIR}/hwid" ]; then
238 # Only update the hwid if we see one in the key directory. 248 # Only update the hwid if we see one in the key directory.
239 gbb_utility -s \ 249 gbb_utility -s \
240 --rootkey=${KEY_DIR}/root_key.vbpubk \ 250 --rootkey=${KEY_DIR}/root_key.vbpubk \
241 --recoverykey=${KEY_DIR}/recovery_key.vbpubk \ 251 --recoverykey=${KEY_DIR}/recovery_key.vbpubk \
242 --hwid="$(cat ${KEY_DIR}/hwid)" \ 252 --hwid="$(cat ${KEY_DIR}/hwid)" \
243 ${shellball_dir}/bios.bin ${temp_outfd} 253 ${shellball_dir}/bios.bin ${temp_outfd}
244 else 254 else
245 gbb_utility -s \ 255 gbb_utility -s \
246 --rootkey=${KEY_DIR}/root_key.vbpubk \ 256 --rootkey=${KEY_DIR}/root_key.vbpubk \
247 --recoverykey=${KEY_DIR}/recovery_key.vbpubk \ 257 --recoverykey=${KEY_DIR}/recovery_key.vbpubk \
248 ${shellball_dir}/bios.bin ${temp_outfd} 258 ${shellball_dir}/bios.bin ${temp_outfd}
249 fi 259 fi
250 # Resign the firmware with new keys 260 # Resign the firmware with new keys
251 ${SCRIPT_DIR}/resign_firmwarefd.sh ${temp_outfd} ${shellball_dir}/bios.bin \ 261 ${SCRIPT_DIR}/resign_firmwarefd.sh ${temp_outfd} ${shellball_dir}/bios.bin \
252 ${KEY_DIR}/firmware_data_key.vbprivk \ 262 ${KEY_DIR}/firmware_data_key.vbprivk \
253 ${KEY_DIR}/firmware.keyblock \ 263 ${KEY_DIR}/firmware.keyblock \
254 ${KEY_DIR}/kernel_subkey.vbpubk 264 ${KEY_DIR}/kernel_subkey.vbpubk \
265 ${FIRMWARE_VERSION}
255 266
256 # Replace MD5 checksum in the firmware update payload 267 # Replace MD5 checksum in the firmware update payload
257 newfd_checksum=$(md5sum ${shellball_dir}/bios.bin | cut -f 1 -d ' ') 268 newfd_checksum=$(md5sum ${shellball_dir}/bios.bin | cut -f 1 -d ' ')
258 temp_version=$(make_temp_file) 269 temp_version=$(make_temp_file)
259 cat ${shellball_dir}/VERSION | 270 cat ${shellball_dir}/VERSION |
260 sed -e "s#\(.*\)\ \(.*bios.bin.*\)#${newfd_checksum}\ \2#" > ${temp_version} 271 sed -e "s#\(.*\)\ \(.*bios.bin.*\)#${newfd_checksum}\ \2#" > ${temp_version}
261 sudo cp ${temp_version} ${shellball_dir}/VERSION 272 sudo cp ${temp_version} ${shellball_dir}/VERSION
262 273
263 # Re-generate firmware_update.tgz and copy over encoded archive in 274 # Re-generate firmware_update.tgz and copy over encoded archive in
264 # the original shell ball. 275 # the original shell ball.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 333
323 verify_image_rootfs "${INPUT_IMAGE}" 334 verify_image_rootfs "${INPUT_IMAGE}"
324 335
325 # TODO(gauravsh): Check embedded firmware AU signatures. 336 # TODO(gauravsh): Check embedded firmware AU signatures.
326 } 337 }
327 338
328 # Generate the SSD image 339 # Generate the SSD image
329 sign_for_ssd() { 340 sign_for_ssd() {
330 ${SCRIPT_DIR}/resign_image.sh ${INPUT_IMAGE} ${OUTPUT_IMAGE} \ 341 ${SCRIPT_DIR}/resign_image.sh ${INPUT_IMAGE} ${OUTPUT_IMAGE} \
331 ${KEY_DIR}/kernel_data_key.vbprivk \ 342 ${KEY_DIR}/kernel_data_key.vbprivk \
332 ${KEY_DIR}/kernel.keyblock 343 ${KEY_DIR}/kernel.keyblock \
344 "${KERNEL_VERSION}"
333 echo "Signed SSD image output to ${OUTPUT_IMAGE}" 345 echo "Signed SSD image output to ${OUTPUT_IMAGE}"
334 } 346 }
335 347
336 # Generate the USB image (direct boot) 348 # Generate the USB image (direct boot)
337 sign_for_usb() { 349 sign_for_usb() {
338 ${SCRIPT_DIR}/resign_image.sh ${INPUT_IMAGE} ${OUTPUT_IMAGE} \ 350 ${SCRIPT_DIR}/resign_image.sh ${INPUT_IMAGE} ${OUTPUT_IMAGE} \
339 ${KEY_DIR}/recovery_kernel_data_key.vbprivk \ 351 ${KEY_DIR}/recovery_kernel_data_key.vbprivk \
340 ${KEY_DIR}/recovery_kernel.keyblock 352 ${KEY_DIR}/recovery_kernel.keyblock \
353 "${KERNEL_VERSION}"
341 354
342 # Now generate the installer vblock with the SSD keys. 355 # Now generate the installer vblock with the SSD keys.
343 # The installer vblock is for KERN-A on direct boot images. 356 # The installer vblock is for KERN-A on direct boot images.
344 temp_kimagea=$(make_temp_file) 357 temp_kimagea=$(make_temp_file)
345 temp_out_vb=$(make_temp_file) 358 temp_out_vb=$(make_temp_file)
346 extract_image_partition ${OUTPUT_IMAGE} 2 ${temp_kimagea} 359 extract_image_partition ${OUTPUT_IMAGE} 2 ${temp_kimagea}
347 ${SCRIPT_DIR}/resign_kernel_partition.sh ${temp_kimagea} ${temp_out_vb} \ 360 ${SCRIPT_DIR}/resign_kernel_partition.sh ${temp_kimagea} ${temp_out_vb} \
348 ${KEY_DIR}/kernel_data_key.vbprivk \ 361 ${KEY_DIR}/kernel_data_key.vbprivk \
349 ${KEY_DIR}/kernel.keyblock 362 ${KEY_DIR}/kernel.keyblock \
363 "${KERNEL_VERSION}"
350 364
351 # Copy the installer vblock to the stateful partition. 365 # Copy the installer vblock to the stateful partition.
352 local stateful_dir=$(make_temp_dir) 366 local stateful_dir=$(make_temp_dir)
353 mount_image_partition ${OUTPUT_IMAGE} 1 ${stateful_dir} 367 mount_image_partition ${OUTPUT_IMAGE} 1 ${stateful_dir}
354 sudo cp ${temp_out_vb} ${stateful_dir}/vmlinuz_hd.vblock 368 sudo cp ${temp_out_vb} ${stateful_dir}/vmlinuz_hd.vblock
355 369
356 echo "Signed USB image output to ${OUTPUT_IMAGE}" 370 echo "Signed USB image output to ${OUTPUT_IMAGE}"
357 } 371 }
358 372
359 # Generate the USB (recovery + install) image 373 # Generate the USB (recovery + install) image
360 sign_for_recovery() { 374 sign_for_recovery() {
361 # Update the Kernel B hash in Kernel A command line 375 # Update the Kernel B hash in Kernel A command line
362 temp_kimageb=$(make_temp_file) 376 temp_kimageb=$(make_temp_file)
363 extract_image_partition ${INPUT_IMAGE} 4 ${temp_kimageb} 377 extract_image_partition ${INPUT_IMAGE} 4 ${temp_kimageb}
364 local kern_a_config=$(grab_kernel_config "${INPUT_IMAGE}" 2) 378 local kern_a_config=$(grab_kernel_config "${INPUT_IMAGE}" 2)
365 local kern_b_hash=$(sha1sum ${temp_kimageb} | cut -f1 -d' ') 379 local kern_b_hash=$(sha1sum ${temp_kimageb} | cut -f1 -d' ')
366 380
367 temp_configa=$(make_temp_file) 381 temp_configa=$(make_temp_file)
368 echo "$kern_a_config" | 382 echo "$kern_a_config" |
369 sed -e "s#\(kern_b_hash=\)[a-z0-9]*#\1${kern_b_hash}#" > ${temp_configa} 383 sed -e "s#\(kern_b_hash=\)[a-z0-9]*#\1${kern_b_hash}#" > ${temp_configa}
370 echo "New config for kernel partition 2 is" 384 echo "New config for kernel partition 2 is"
371 cat $temp_configa 385 cat $temp_configa
372 386
373 # Make a copy of the input image 387 # Make a copy of the input image
374 cp "${INPUT_IMAGE}" "${OUTPUT_IMAGE}" 388 cp "${INPUT_IMAGE}" "${OUTPUT_IMAGE}"
375 local temp_kimagea=$(make_temp_file) 389 local temp_kimagea=$(make_temp_file)
376 extract_image_partition ${OUTPUT_IMAGE} 2 ${temp_kimagea} 390 extract_image_partition ${OUTPUT_IMAGE} 2 ${temp_kimagea}
377 # Re-calculate kernel partition signature and command line. 391 # Re-calculate kernel partition signature and command line.
378 local updated_kimagea=$(make_temp_file) 392 local updated_kimagea=$(make_temp_file)
379 vbutil_kernel --repack ${updated_kimagea} \ 393 vbutil_kernel --repack ${updated_kimagea} \
380 --keyblock ${KEY_DIR}/recovery_kernel.keyblock \ 394 --keyblock ${KEY_DIR}/recovery_kernel.keyblock \
381 --signprivate ${KEY_DIR}/recovery_kernel_data_key.vbprivk \ 395 --signprivate ${KEY_DIR}/recovery_kernel_data_key.vbprivk \
396 --version "${KERNEL_VERSION}" \
382 --oldblob ${temp_kimagea} \ 397 --oldblob ${temp_kimagea} \
383 --config ${temp_configa} 398 --config ${temp_configa}
384 399
385 replace_image_partition ${OUTPUT_IMAGE} 2 ${updated_kimagea} 400 replace_image_partition ${OUTPUT_IMAGE} 2 ${updated_kimagea}
386 401
387 # Now generate the installer vblock with the SSD keys. 402 # Now generate the installer vblock with the SSD keys.
388 # The installer vblock is for KERN-B on recovery images. 403 # The installer vblock is for KERN-B on recovery images.
389 temp_out_vb=$(make_temp_file) 404 temp_out_vb=$(make_temp_file)
390 extract_image_partition ${OUTPUT_IMAGE} 4 ${temp_kimageb} 405 extract_image_partition ${OUTPUT_IMAGE} 4 ${temp_kimageb}
391 ${SCRIPT_DIR}/resign_kernel_partition.sh ${temp_kimageb} ${temp_out_vb} \ 406 ${SCRIPT_DIR}/resign_kernel_partition.sh ${temp_kimageb} ${temp_out_vb} \
392 ${KEY_DIR}/kernel_data_key.vbprivk \ 407 ${KEY_DIR}/kernel_data_key.vbprivk \
393 ${KEY_DIR}/kernel.keyblock 408 ${KEY_DIR}/kernel.keyblock \
409 "${KERNEL_VERSION}"
394 410
395 # Copy the installer vblock to the stateful partition. 411 # Copy the installer vblock to the stateful partition.
396 # TODO(gauravsh): Remove this if we get rid of the need to overwrite 412 # TODO(gauravsh): Remove this if we get rid of the need to overwrite
397 # the vblock during installs. Kern B could directly be signed by the 413 # the vblock during installs. Kern B could directly be signed by the
398 # SSD keys. 414 # SSD keys.
399 local stateful_dir=$(make_temp_dir) 415 local stateful_dir=$(make_temp_dir)
400 mount_image_partition ${OUTPUT_IMAGE} 1 ${stateful_dir} 416 mount_image_partition ${OUTPUT_IMAGE} 1 ${stateful_dir}
401 sudo cp ${temp_out_vb} ${stateful_dir}/vmlinuz_hd.vblock 417 sudo cp ${temp_out_vb} ${stateful_dir}/vmlinuz_hd.vblock
402 418
403 echo "Signed recovery image output to ${OUTPUT_IMAGE}" 419 echo "Signed recovery image output to ${OUTPUT_IMAGE}"
404 } 420 }
405 421
406 # Generate the factory install image. 422 # Generate the factory install image.
407 sign_for_factory_install() { 423 sign_for_factory_install() {
408 ${SCRIPT_DIR}/resign_image.sh ${INPUT_IMAGE} ${OUTPUT_IMAGE} \ 424 ${SCRIPT_DIR}/resign_image.sh ${INPUT_IMAGE} ${OUTPUT_IMAGE} \
409 ${KEY_DIR}/installer_kernel_data_key.vbprivk \ 425 ${KEY_DIR}/installer_kernel_data_key.vbprivk \
410 ${KEY_DIR}/installer_kernel.keyblock 426 ${KEY_DIR}/installer_kernel.keyblock \
427 "${KERNEL_VERSION}"
411 echo "Signed factory install image output to ${OUTPUT_IMAGE}" 428 echo "Signed factory install image output to ${OUTPUT_IMAGE}"
412 } 429 }
413 430
414 # Verification 431 # Verification
415 if [ "${TYPE}" == "verify" ]; then 432 if [ "${TYPE}" == "verify" ]; then
416 verify_image 433 verify_image
417 exit 0 434 exit 0
418 fi 435 fi
419 436
420 # Signing requires an output image name 437 # Signing requires an output image name
421 if [ -z "${OUTPUT_IMAGE}" ]; then 438 if [ -z "${OUTPUT_IMAGE}" ]; then
422 usage 439 usage
423 exit 1 440 exit 1
424 fi 441 fi
425 442
443 # If a version file was specified, read the firmware and kernel
444 # versions from there.
445 if [ -n "${VERSION_FILE}" ]; then
446 FIRMWARE_VERSION=$(sed -n 's#^firmware_version=\(.*\)#\1#pg' ${VERSION_FILE})
447 KERNEL_VERSION=$(sed -n 's#^kernel_version=\(.*\)#\1#pg' ${VERSION_FILE})
448 fi
449 echo "Using firmware version: ${FIRMWARE_VERSION}"
450 echo "Using kernel version: ${KERNEL_VERSION}"
426 451
427 if [ "${TYPE}" == "ssd" ]; then 452 if [ "${TYPE}" == "ssd" ]; then
428 resign_firmware_payload ${INPUT_IMAGE} 453 resign_firmware_payload ${INPUT_IMAGE}
429 update_rootfs_hash ${INPUT_IMAGE} \ 454 update_rootfs_hash ${INPUT_IMAGE} \
430 ${KEY_DIR}/kernel.keyblock \ 455 ${KEY_DIR}/kernel.keyblock \
431 ${KEY_DIR}/kernel_data_key.vbprivk \ 456 ${KEY_DIR}/kernel_data_key.vbprivk \
432 2 457 2
433 sign_for_ssd 458 sign_for_ssd
434 elif [ "${TYPE}" == "usb" ]; then 459 elif [ "${TYPE}" == "usb" ]; then
435 resign_firmware_payload ${INPUT_IMAGE} 460 resign_firmware_payload ${INPUT_IMAGE}
(...skipping 18 matching lines...) Expand all
454 resign_firmware_payload ${INPUT_IMAGE} 479 resign_firmware_payload ${INPUT_IMAGE}
455 update_rootfs_hash ${INPUT_IMAGE} \ 480 update_rootfs_hash ${INPUT_IMAGE} \
456 ${KEY_DIR}/installer_kernel.keyblock \ 481 ${KEY_DIR}/installer_kernel.keyblock \
457 ${KEY_DIR}/installer_kernel_data_key.vbprivk \ 482 ${KEY_DIR}/installer_kernel_data_key.vbprivk \
458 2 483 2
459 sign_for_factory_install 484 sign_for_factory_install
460 else 485 else
461 echo "Invalid type ${TYPE}" 486 echo "Invalid type ${TYPE}"
462 exit 1 487 exit 1
463 fi 488 fi
OLDNEW
« no previous file with comments | « scripts/image_signing/resign_kernel_partition.sh ('k') | scripts/image_signing/versions.default » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698