| 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 # Helper script that generates the signed kernel image | 7 # Helper script that generates the signed kernel image |
| 8 | 8 |
| 9 # --- BEGIN COMMON.SH BOILERPLATE --- | 9 # --- BEGIN COMMON.SH BOILERPLATE --- |
| 10 # Load common CrOS utilities. Inside the chroot this file is installed in | 10 # Load common CrOS utilities. Inside the chroot this file is installed in |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 "The path to the kernel (Default: vmlinuz)" | 40 "The path to the kernel (Default: vmlinuz)" |
| 41 DEFINE_string working_dir "/tmp/vmlinuz.working" \ | 41 DEFINE_string working_dir "/tmp/vmlinuz.working" \ |
| 42 "Working directory for in-progress files. (Default: /tmp/vmlinuz.working)" | 42 "Working directory for in-progress files. (Default: /tmp/vmlinuz.working)" |
| 43 DEFINE_boolean keep_work ${FLAGS_FALSE} \ | 43 DEFINE_boolean keep_work ${FLAGS_FALSE} \ |
| 44 "Keep temporary files (*.keyblock, *.vbpubk). (Default: false)" | 44 "Keep temporary files (*.keyblock, *.vbpubk). (Default: false)" |
| 45 DEFINE_string keys_dir "${SRC_ROOT}/platform/vboot_reference/tests/testkeys" \ | 45 DEFINE_string keys_dir "${SRC_ROOT}/platform/vboot_reference/tests/testkeys" \ |
| 46 "Directory with the RSA signing keys. (Defaults to test keys)" | 46 "Directory with the RSA signing keys. (Defaults to test keys)" |
| 47 DEFINE_boolean use_dev_keys ${FLAGS_FALSE} \ | 47 DEFINE_boolean use_dev_keys ${FLAGS_FALSE} \ |
| 48 "Use developer keys for signing. (Default: false)" | 48 "Use developer keys for signing. (Default: false)" |
| 49 # Note, to enable verified boot, the caller would manually pass: | 49 # Note, to enable verified boot, the caller would manually pass: |
| 50 # --boot_args='dm="... /dev/sd%D%P /dev/sd%D%P ..." \ | 50 # --boot_args='dm="... %U+1 %U+1 ..." \ |
| 51 # --root=/dev/dm-0 | 51 # --root=/dev/dm-0 |
| 52 DEFINE_string boot_args "noinitrd" \ | 52 DEFINE_string boot_args "noinitrd" \ |
| 53 "Additional boot arguments to pass to the commandline (Default: noinitrd)" | 53 "Additional boot arguments to pass to the commandline (Default: noinitrd)" |
| 54 # By default, we use a firmware enumerated value, but it isn't reliable for |
| 55 # production use. If +%d can be added upstream, then we can use: |
| 56 # root=PARTUID=uuid+1 |
| 54 DEFINE_string root "/dev/sd%D%P" \ | 57 DEFINE_string root "/dev/sd%D%P" \ |
| 55 "Expected device root (Default: root=/dev/sd%D%P)" | 58 "Expected device root partition" |
| 56 | |
| 57 # If provided, will automatically add verified boot arguments. | 59 # If provided, will automatically add verified boot arguments. |
| 58 DEFINE_string rootfs_image "" \ | 60 DEFINE_string rootfs_image "" \ |
| 59 "Optional path to the rootfs device or image.(Default: \"\")" | 61 "Optional path to the rootfs device or image.(Default: \"\")" |
| 60 DEFINE_string rootfs_hash "" \ | 62 DEFINE_string rootfs_hash "" \ |
| 61 "Optional path to output the rootfs hash to. (Default: \"\")" | 63 "Optional path to output the rootfs hash to. (Default: \"\")" |
| 62 DEFINE_integer verity_error_behavior 2 \ | 64 DEFINE_integer verity_error_behavior 2 \ |
| 63 "Verified boot error behavior [0: I/O errors, 1: reboot, 2: nothing] \ | 65 "Verified boot error behavior [0: I/O errors, 1: reboot, 2: nothing] \ |
| 64 (Default: 2)" | 66 (Default: 2)" |
| 65 DEFINE_integer verity_tree_depth 1 \ | 67 DEFINE_integer verity_tree_depth 1 \ |
| 66 "Optional Verified boot hash tree depth. (Default: 1)" | 68 "Optional Verified boot hash tree depth. (Default: 1)" |
| 67 DEFINE_integer verity_max_ios 1024 \ | 69 DEFINE_integer verity_max_ios -1 \ |
| 68 "Optional number of outstanding I/O operations. (Default: 1024)" | 70 "Optional number of outstanding I/O operations. (Default: -1)" |
| 69 DEFINE_string verity_hash_alg "sha1" \ | 71 DEFINE_string verity_hash_alg "sha1" \ |
| 70 "Cryptographic hash algorithm used for dm-verity. (Default: sha1)" | 72 "Cryptographic hash algorithm used for dm-verity. (Default: sha1)" |
| 71 | 73 |
| 72 # Parse flags | 74 # Parse flags |
| 73 FLAGS "$@" || exit 1 | 75 FLAGS "$@" || exit 1 |
| 74 eval set -- "${FLAGS_ARGV}" | 76 eval set -- "${FLAGS_ARGV}" |
| 75 | 77 |
| 76 # Die on error | 78 # Die on error |
| 77 set -e | 79 set -e |
| 78 | 80 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 101 ${root_fs_blocks} \ | 103 ${root_fs_blocks} \ |
| 102 ${FLAGS_rootfs_hash}) | 104 ${FLAGS_rootfs_hash}) |
| 103 if [[ -f "${FLAGS_rootfs_hash}" ]]; then | 105 if [[ -f "${FLAGS_rootfs_hash}" ]]; then |
| 104 sudo chmod a+r "${FLAGS_rootfs_hash}" | 106 sudo chmod a+r "${FLAGS_rootfs_hash}" |
| 105 fi | 107 fi |
| 106 # Don't claim the root device unless the root= flag is pointed to | 108 # Don't claim the root device unless the root= flag is pointed to |
| 107 # the verified boot device. Doing so will claim /dev/sdDP out from | 109 # the verified boot device. Doing so will claim /dev/sdDP out from |
| 108 # under the system. | 110 # under the system. |
| 109 if [[ ${FLAGS_root} = "/dev/dm-0" ]]; then | 111 if [[ ${FLAGS_root} = "/dev/dm-0" ]]; then |
| 110 if [[ "${FLAGS_arch}" = "x86" ]]; then | 112 if [[ "${FLAGS_arch}" = "x86" ]]; then |
| 111 base_root='/dev/sd%D%P' | 113 base_root='%U+1' # kern_guid + 1 |
| 112 elif [[ "${FLAGS_arch}" = "arm" ]]; then | 114 elif [[ "${FLAGS_arch}" = "arm" ]]; then |
| 113 base_root='/dev/${devname}${rootpart}' | 115 base_root='/dev/${devname}${rootpart}' |
| 114 fi | 116 fi |
| 115 table=${table//HASH_DEV/${base_root}} | 117 table=${table//HASH_DEV/${base_root}} |
| 116 table=${table//ROOT_DEV/${base_root}} | 118 table=${table//ROOT_DEV/${base_root}} |
| 117 fi | 119 fi |
| 118 verity_args="dm=\"vroot none ro,${table}\"" | 120 verity_args="dm=\"vroot none ro,${table}\"" |
| 119 info "dm-verity configuration: ${verity_args}" | 121 info "dm-verity configuration: ${verity_args}" |
| 120 fi | 122 fi |
| 121 | 123 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 info "Cleaning up temporary files: ${WORK}" | 272 info "Cleaning up temporary files: ${WORK}" |
| 271 rm ${WORK} | 273 rm ${WORK} |
| 272 rmdir ${FLAGS_working_dir} | 274 rmdir ${FLAGS_working_dir} |
| 273 fi | 275 fi |
| 274 | 276 |
| 275 info "Kernel partition image emitted: ${FLAGS_to}" | 277 info "Kernel partition image emitted: ${FLAGS_to}" |
| 276 | 278 |
| 277 if [[ -f ${FLAGS_rootfs_hash} ]]; then | 279 if [[ -f ${FLAGS_rootfs_hash} ]]; then |
| 278 info "Root filesystem hash emitted: ${FLAGS_rootfs_hash}" | 280 info "Root filesystem hash emitted: ${FLAGS_rootfs_hash}" |
| 279 fi | 281 fi |
| OLD | NEW |