flatcar-scripts/bin/cros_sign_to_ssd
Nick Sanders b801bec71a fix sign_to_ssd
Change-Id: If642d664163f36b79e3b6d845de0025cc3dc0372

BUG=6264
TEST="resign an image"

Review URL: http://codereview.chromium.org/3273011
2010-08-31 23:05:07 -07:00

71 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Script to resign the kernel partition generated in the output of build_image
# with SSD keys.
# Load common constants. This should be the first executable line.
# The path to common.sh should be relative to your script's location.
. "$(dirname "$0")/../common.sh"
. "$(dirname "$0")/../chromeos-common.sh" # for partoffset and partsize
locate_gpt
DEFINE_string from "chromiumos_image.bin" \
"Input file name of Chrome OS image to re-sign."
# Parse command line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
failure() {
echo "SIGNING HAD FAILED"
exit 1
}
# Abort on error
set -e
trap "failure" EXIT
if [ -z "${FLAGS_from}" ] || [ ! -f "${FLAGS_from}" ] ; then
echo "Error: invalid flag --from"
exit 1
fi
# Example commandline is as follows:
# ./sign_official_build.sh \
# ssd \
# /.../build/images/x86-mario/0.8.68.2/chromiumos_test_image.bin \
# ../../tests/devkeys/ \
# /.../build/images/x86-mario/0.8.68.2/chromiumos_test_ssd_image.bin
VBOOT_DIR="$(dirname "$0")/../../platform/vboot_reference"
if [ ! -d "${VBOOT_DIR}" ]; then
die "VBOOT DIR NOT FOUND at \'${VBOOT_DIR}\' .."
fi
TMP_IMAGE=$(mktemp)
VBOOT_KEYS="${VBOOT_DIR}/tests/devkeys"
if [ ! -d "${VBOOT_KEYS}" ]; then
die "VBOOT KEYS NOT FOUND at \'${VBOOT_KEYS}\' .."
fi
VBOOT_SIGN="${VBOOT_DIR}/scripts/image_signing/sign_official_build.sh"
if [ ! -x "${VBOOT_SIGN}" ]; then
die "VBOOT TOOL sign_official_build.sh NOT FOUND at \'${VBOOT_SIGN}\' .."
fi
cp "${FLAGS_from}" "${TMP_IMAGE}"
${VBOOT_SIGN} ssd "${TMP_IMAGE}" "${VBOOT_KEYS}" "${FLAGS_from}"
rm "${TMP_IMAGE}"
set +e
trap - EXIT