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 # Load common constants. This should be the first executable line. | |
11 # The path to common.sh should be relative to your script's location. | |
12 . "/usr/lib/crosutils/common.sh" | |
13 | |
14 . "/usr/lib/installer/chromeos-common.sh" # for partoffset and partsize | |
15 | |
16 locate_gpt | |
17 | |
18 DEFINE_string from "chromiumos_image.bin" \ | |
19 "Input file name of Chrome OS image to re-sign." | |
20 | |
21 # Parse command line | |
22 FLAGS "$@" || exit 1 | |
23 eval set -- "${FLAGS_ARGV}" | |
24 | |
25 failure() { | |
26 echo "SIGNING HAD FAILED" | |
27 exit 1 | |
28 } | |
29 | |
30 # Abort on error | |
31 set -e | |
32 | |
33 trap "failure" EXIT | |
34 | |
35 if [ -z "${FLAGS_from}" ] || [ ! -f "${FLAGS_from}" ] ; then | |
36 echo "Error: invalid flag --from" | |
37 exit 1 | |
38 fi | |
39 | |
40 # Example commandline is as follows: | |
41 # ./sign_official_build.sh \ | |
42 # ssd \ | |
43 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_image.bin \ | |
44 # ../../tests/devkeys/ \ | |
45 # /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin | |
46 | |
47 VBOOT_DIR="$(dirname "$0")/../../platform/vboot_reference" | |
48 if [ ! -d "${VBOOT_DIR}" ]; then | |
49 die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .." | |
50 fi | |
51 | |
52 TMP_IMAGE=$(mktemp) | |
53 VBOOT_KEYS="${VBOOT_DIR}/tests/devkeys" | |
54 if [ ! -d "${VBOOT_KEYS}" ]; then | |
55 die "VBOOT KEYS NOT FOUND at \'${VBOOT_KEYS}\' .." | |
56 fi | |
57 | |
58 VBOOT_SIGN="${VBOOT_DIR}/scripts/image_signing/sign_official_build.sh" | |
59 if [ ! -x "${VBOOT_SIGN}" ]; then | |
60 die "VBOOT TOOL sign_official_build.sh NOT FOUND at \'${VBOOT_SIGN}\' .." | |
61 fi | |
62 | |
63 cp "${FLAGS_from}" "${TMP_IMAGE}" | |
64 | |
65 ${VBOOT_SIGN} ssd "${TMP_IMAGE}" "${VBOOT_KEYS}" "${FLAGS_from}" | |
66 | |
67 rm "${TMP_IMAGE}" | |
68 | |
69 set +e | |
70 trap - EXIT | |
OLD | NEW |