OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 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 |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # Script to resign the kernel partition generated in the output of build_image |
| 8 # with SSD keys. |
| 9 |
| 10 # --- BEGIN COMMON.SH BOILERPLATE --- |
| 11 # Load common CrOS utilities. Inside the chroot this file is installed in |
| 12 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 13 # location. |
| 14 find_common_sh() { |
| 15 local common_paths=(/usr/lib/crosutils "$(dirname "$(readlink -f "$0")")/..") |
| 16 local path |
| 17 |
| 18 SCRIPT_ROOT= |
| 19 for path in "${common_paths[@]}"; do |
| 20 if [ -r "${path}/common.sh" ]; then |
| 21 SCRIPT_ROOT=${path} |
| 22 break |
| 23 fi |
| 24 done |
| 25 } |
| 26 |
| 27 find_common_sh |
| 28 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 29 # --- END COMMON.SH BOILERPLATE --- |
| 30 |
| 31 # Need to be inside the chroot to load chromeos-common.sh |
| 32 assert_inside_chroot |
| 33 |
| 34 # Load functions and constants for chromeos-install |
| 35 . "/usr/lib/installer/chromeos-common.sh" || \ |
| 36 die "Unable to load /usr/lib/installer/chromeos-common.sh" |
| 37 |
| 38 locate_gpt |
| 39 |
| 40 DEFINE_string from "chromiumos_image.bin" \ |
| 41 "Input file name of Chrome OS image to re-sign." |
| 42 |
| 43 # Parse command line |
| 44 FLAGS "$@" || exit 1 |
| 45 eval set -- "${FLAGS_ARGV}" |
| 46 |
| 47 failure() { |
| 48 echo "SIGNING HAD FAILED" |
| 49 exit 1 |
| 50 } |
| 51 |
| 52 # Abort on error |
| 53 set -e |
| 54 |
| 55 trap "failure" EXIT |
| 56 |
| 57 if [ -z "${FLAGS_from}" ] || [ ! -f "${FLAGS_from}" ] ; then |
| 58 echo "Error: invalid flag --from" |
| 59 exit 1 |
| 60 fi |
| 61 |
| 62 # Example commandline is as follows: |
| 63 # ./sign_official_build.sh \ |
| 64 # ssd \ |
| 65 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_image.bin \ |
| 66 # ../../tests/devkeys/ \ |
| 67 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin |
| 68 |
| 69 VBOOT_DIR="${SRC_ROOT}/platform/vboot_reference" |
| 70 if [ ! -d "${VBOOT_DIR}" ]; then |
| 71 die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .." |
| 72 fi |
| 73 |
| 74 TMP_IMAGE=$(mktemp) |
| 75 VBOOT_KEYS="${VBOOT_DIR}/tests/devkeys" |
| 76 if [ ! -d "${VBOOT_KEYS}" ]; then |
| 77 die "VBOOT KEYS NOT FOUND at \'${VBOOT_KEYS}\' .." |
| 78 fi |
| 79 |
| 80 VBOOT_SIGN="${VBOOT_DIR}/scripts/image_signing/sign_official_build.sh" |
| 81 if [ ! -x "${VBOOT_SIGN}" ]; then |
| 82 die "VBOOT TOOL sign_official_build.sh NOT FOUND at \'${VBOOT_SIGN}\' .." |
| 83 fi |
| 84 |
| 85 cp "${FLAGS_from}" "${TMP_IMAGE}" |
| 86 |
| 87 ${VBOOT_SIGN} ssd "${TMP_IMAGE}" "${VBOOT_KEYS}" "${FLAGS_from}" |
| 88 |
| 89 rm "${TMP_IMAGE}" |
| 90 |
| 91 set +e |
| 92 trap - EXIT |
OLD | NEW |