diff options
author | Mike Frysinger <vapier@chromium.org> | 2012-12-12 16:55:52 -0500 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-12-12 14:57:17 -0800 |
commit | b55c538fca8939e58d20c127a9f42ce4eba7282c (patch) | |
tree | c9137ddf444d99eb5a210aa64f9d6c208f059336 | |
parent | dd7a7743440846d706583bc2db9317ef1bbf3d45 (diff) | |
download | vboot-b55c538fca8939e58d20c127a9f42ce4eba7282c.tar.gz |
sign_official_build: add a dump_config helper and clean up argument processing
For debugging purposes, we like to see the kernel command line that a
particular kernel is using. We have all the tools to do this already,
but not easy to leverage (you have to manually extract/etc...). So
add a "dump_config" helper to help people out.
Further, the existing argc processing is incomplete and not terribly
friendly. Add some useful error messages explaining why we quit.
BUG=None
TEST=`./sign_official_build.sh dump_config <bin>` works
TEST=`./sign_official_build.sh verify <bin>` works
TEST=`./sign_official_build.sh` shows usage
TEST=`./sign_official_build.sh recovery <bin>` shows usage
TEST=`./sign_official_build.sh recovery <bin> / /tmp/foo` tries to sign
BRANCH=None
Change-Id: I9f94250b8c299783bdcba704733974c6a5491101
Reviewed-on: https://gerrit.chromium.org/gerrit/39603
Reviewed-by: Paul Taysom <taysom@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
-rwxr-xr-x | scripts/image_signing/sign_official_build.sh | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/scripts/image_signing/sign_official_build.sh b/scripts/image_signing/sign_official_build.sh index 0f9691ff..d6073dd3 100755 --- a/scripts/image_signing/sign_official_build.sh +++ b/scripts/image_signing/sign_official_build.sh @@ -41,12 +41,33 @@ If you are signing an image, you must specify an [output_image] and optionally, a [version_file]. EOF + if [[ $# -gt 0 ]]; then + error "$*" + exit 1 + fi + exit 0 } -if [ $# -lt 3 ] || [ $# -gt 5 ]; then - usage - exit 1 -fi +# Verify we have as many arguments as we expect, else show usage & quit. +# Usage: +# check_argc <number args> <exact number> +# check_argc <number args> <lower bound> <upper bound> +check_argc() { + case $# in + 2) + if [[ $1 -ne $2 ]]; then + usage "command takes exactly $2 args" + fi + ;; + 3) + if [[ $1 -lt $2 || $1 -gt $3 ]]; then + usage "command takes $2 to $3 args" + fi + ;; + *) + die "check_argc: incorrect number of arguments" + esac +} # Abort on errors. set -e @@ -610,16 +631,30 @@ sign_for_factory_install() { } # Verification -if [ "${TYPE}" == "verify" ]; then +case ${TYPE} in +dump_config) + check_argc $# 2 + for partnum in 2 4; do + echo "kernel config in partition number ${partnum}:" + grab_kernel_config "${INPUT_IMAGE}" ${partnum} + echo + done + exit 0 + ;; +verify) + check_argc $# 2 verify_image exit 0 -fi - -# Signing requires an output image name -if [ -z "${OUTPUT_IMAGE}" ]; then - usage - exit 1 -fi + ;; +*) + # All other signing commands take 4 to 5 args. + if [ -z "${OUTPUT_IMAGE}" ]; then + # Friendlier message. + usage "Missing output image name" + fi + check_argc $# 4 5 + ;; +esac # If a version file was specified, read the firmware and kernel # versions from there. |