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 resign the kernel partition generated in the output of build_image | 7 # Script to resign the kernel partition generated in the output of build_image |
8 # with SSD keys. | 8 # with SSD keys. |
9 | 9 |
10 # Load common constants. This should be the first executable line. | 10 # --- BEGIN COMMON.SH BOILERPLATE --- |
11 # The path to common.sh should be relative to your script's location. | 11 # Load common CrOS utilities. Inside the chroot this file is installed in |
12 . "$(dirname "$0")/../common.sh" | 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 |
13 | 17 |
14 . "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize | 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" |
15 | 37 |
16 locate_gpt | 38 locate_gpt |
17 | 39 |
18 DEFINE_string from "chromiumos_image.bin" \ | 40 DEFINE_string from "chromiumos_image.bin" \ |
19 "Input file name of Chrome OS image to re-sign." | 41 "Input file name of Chrome OS image to re-sign." |
20 | 42 |
21 # Parse command line | 43 # Parse command line |
22 FLAGS "$@" || exit 1 | 44 FLAGS "$@" || exit 1 |
23 eval set -- "${FLAGS_ARGV}" | 45 eval set -- "${FLAGS_ARGV}" |
24 | 46 |
(...skipping 12 matching lines...) Expand all Loading... |
37 exit 1 | 59 exit 1 |
38 fi | 60 fi |
39 | 61 |
40 # Example commandline is as follows: | 62 # Example commandline is as follows: |
41 # ./sign_official_build.sh \ | 63 # ./sign_official_build.sh \ |
42 # ssd \ | 64 # ssd \ |
43 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_image.bin \ | 65 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_image.bin \ |
44 # ../../tests/devkeys/ \ | 66 # ../../tests/devkeys/ \ |
45 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin | 67 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin |
46 | 68 |
47 VBOOT_DIR="$(dirname "$0")/../../platform/vboot_reference" | 69 VBOOT_DIR="${SRC_ROOT}/platform/vboot_reference" |
48 if [ ! -d "${VBOOT_DIR}" ]; then | 70 if [ ! -d "${VBOOT_DIR}" ]; then |
49 die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .." | 71 die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .." |
50 fi | 72 fi |
51 | 73 |
52 TMP_IMAGE=$(mktemp) | 74 TMP_IMAGE=$(mktemp) |
53 VBOOT_KEYS="${VBOOT_DIR}/tests/devkeys" | 75 VBOOT_KEYS="${VBOOT_DIR}/tests/devkeys" |
54 if [ ! -d "${VBOOT_KEYS}" ]; then | 76 if [ ! -d "${VBOOT_KEYS}" ]; then |
55 die "VBOOT KEYS NOT FOUND at \'${VBOOT_KEYS}\' .." | 77 die "VBOOT KEYS NOT FOUND at \'${VBOOT_KEYS}\' .." |
56 fi | 78 fi |
57 | 79 |
58 VBOOT_SIGN="${VBOOT_DIR}/scripts/image_signing/sign_official_build.sh" | 80 VBOOT_SIGN="${VBOOT_DIR}/scripts/image_signing/sign_official_build.sh" |
59 if [ ! -x "${VBOOT_SIGN}" ]; then | 81 if [ ! -x "${VBOOT_SIGN}" ]; then |
60 die "VBOOT TOOL sign_official_build.sh NOT FOUND at \'${VBOOT_SIGN}\' .." | 82 die "VBOOT TOOL sign_official_build.sh NOT FOUND at \'${VBOOT_SIGN}\' .." |
61 fi | 83 fi |
62 | 84 |
63 cp "${FLAGS_from}" "${TMP_IMAGE}" | 85 cp "${FLAGS_from}" "${TMP_IMAGE}" |
64 | 86 |
65 ${VBOOT_SIGN} ssd "${TMP_IMAGE}" "${VBOOT_KEYS}" "${FLAGS_from}" | 87 ${VBOOT_SIGN} ssd "${TMP_IMAGE}" "${VBOOT_KEYS}" "${FLAGS_from}" |
66 | 88 |
67 rm "${TMP_IMAGE}" | 89 rm "${TMP_IMAGE}" |
68 | 90 |
69 set +e | 91 set +e |
70 trap - EXIT | 92 trap - EXIT |
OLD | NEW |