From 048b3cecdf531a32a95d7929e861c76d436d13af Mon Sep 17 00:00:00 2001 From: Don Garrett Date: Mon, 11 Mar 2013 13:24:26 -0700 Subject: [PATCH 1/6] Update generate_au_zip.py location for cgpt. Cgpt was moved and a symlink based wrapper was added. That wrapper will be improved soon, when when that's true we'll need to change this back. A specific note... cgpt is currently statically linked. If that wrapper does not remain statically linked, then a simple revert won't be enough. BUG=chromium-os:39814 TEST=Manual au-generate.zip creation. Change-Id: I2705b1eddd8ef28c7eb099512513daf80f586218 Reviewed-on: https://gerrit.chromium.org/gerrit/45128 Reviewed-by: Chris Sosa Commit-Queue: Don Garrett Tested-by: Don Garrett --- build_library/generate_au_zip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_library/generate_au_zip.py b/build_library/generate_au_zip.py index 52392373d1..7c24295ec5 100755 --- a/build_library/generate_au_zip.py +++ b/build_library/generate_au_zip.py @@ -18,7 +18,7 @@ import tempfile # GLOBALS image_sign_dir = '~/trunk/src/platform/vboot_reference/scripts/image_signing' -STATIC_FILES = ['/usr/bin/cgpt', +STATIC_FILES = ['/usr/bin/old_bins/cgpt', '~/trunk/src/scripts/common.sh', '/usr/bin/cros_generate_update_payload', '~/trunk/src/scripts/chromeos-common.sh', From 12149d84216cd4945082555674acf35bc150fad2 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 8 Jul 2013 18:29:10 -0700 Subject: [PATCH 2/6] fix(generate_au_zip): Remove unused scripts from au-generator.zip We have no need to ship convert_recovery_to_ssd.sh with builds. --- build_library/generate_au_zip.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build_library/generate_au_zip.py b/build_library/generate_au_zip.py index 7c24295ec5..61717eb73c 100755 --- a/build_library/generate_au_zip.py +++ b/build_library/generate_au_zip.py @@ -17,13 +17,10 @@ import sys import tempfile # GLOBALS -image_sign_dir = '~/trunk/src/platform/vboot_reference/scripts/image_signing' STATIC_FILES = ['/usr/bin/old_bins/cgpt', - '~/trunk/src/scripts/common.sh', '/usr/bin/cros_generate_update_payload', '~/trunk/src/scripts/chromeos-common.sh', - os.path.join(image_sign_dir, 'convert_recovery_to_ssd.sh'), - os.path.join(image_sign_dir, 'common_minimal.sh'), + '~/trunk/src/scripts/common.sh', ] DYNAMIC_EXECUTABLES = ['/usr/bin/delta_generator', From 12935743b63fbe3432c182f11cdd5b24b45d5c0d Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 8 Jul 2013 18:30:10 -0700 Subject: [PATCH 3/6] fix(common.sh): Fallback to loading version.txt from current directory. This makes version handling continue to work normally with au-generator.zip --- build_library/generate_au_zip.py | 1 + common.sh | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build_library/generate_au_zip.py b/build_library/generate_au_zip.py index 61717eb73c..d943d73f05 100755 --- a/build_library/generate_au_zip.py +++ b/build_library/generate_au_zip.py @@ -19,6 +19,7 @@ import tempfile # GLOBALS STATIC_FILES = ['/usr/bin/old_bins/cgpt', '/usr/bin/cros_generate_update_payload', + '~/trunk/.repo/manifests/version.txt', '~/trunk/src/scripts/chromeos-common.sh', '~/trunk/src/scripts/common.sh', ] diff --git a/common.sh b/common.sh index a72e7a8451..010334b33b 100644 --- a/common.sh +++ b/common.sh @@ -305,7 +305,10 @@ BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library" # Source COREOS_* from manifest for version information. COREOS_VERSION_FILE="${GCLIENT_ROOT}/.repo/manifests/version.txt" -source "$COREOS_VERSION_FILE" || die "Cannot source $COREOS_VERSION_FILE" +if [[ ! -f "${COREOS_VERSION_FILE}" ]]; then + COREOS_VERSION_FILE="${SCRIPT_LOCATION}/version.txt" +fi +source "$COREOS_VERSION_FILE" || die "Cannot source version.txt" # Official builds must set COREOS_OFFICIAL=1 to use an official version. if [ ${COREOS_OFFICIAL:-0} -ne 1 ]; then From c9a6956f6f0c24e95d3222caff265b65f13c083a Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 8 Jul 2013 19:03:02 -0700 Subject: [PATCH 4/6] fix(core_upload_update): Add to au-generator.zip, move some operations. Add core_upload_update to au-generator.zip which requires some extra logic to make it runnable anywhere it may be. To organize the code a little better all the delta_generator calls have been moved to cros_generate_update_payload. core_upload_update is now just a wrapper around cros_generate_update_payload and core-admin. --- build_library/generate_au_zip.py | 1 + core_upload_update | 35 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/build_library/generate_au_zip.py b/build_library/generate_au_zip.py index d943d73f05..d6ffe9763f 100755 --- a/build_library/generate_au_zip.py +++ b/build_library/generate_au_zip.py @@ -22,6 +22,7 @@ STATIC_FILES = ['/usr/bin/old_bins/cgpt', '~/trunk/.repo/manifests/version.txt', '~/trunk/src/scripts/chromeos-common.sh', '~/trunk/src/scripts/common.sh', + '~/trunk/src/scripts/core_upload_update', ] DYNAMIC_EXECUTABLES = ['/usr/bin/delta_generator', diff --git a/core_upload_update b/core_upload_update index 199a2769ed..e1424702cf 100755 --- a/core_upload_update +++ b/core_upload_update @@ -5,6 +5,9 @@ # found in the LICENSE file. SCRIPT_ROOT=$(dirname $(readlink -f "$0")) +# We have to simple-mindedly set GCLIENT_ROOT in case we're running from +# au-generator.zip because common.sh will fail while auto-detect it. +export GCLIENT_ROOT=$(readlink -f "${SCRIPT_ROOT}/../../") . "${SCRIPT_ROOT}/common.sh" || exit 1 DEFINE_string image "${SRC_ROOT}/build/images/amd64-generic/latest/${COREOS_BASE_IMAGE_NAME}" \ @@ -42,24 +45,24 @@ switch_to_strict_mode [[ -z "${FLAGS_private_key}" ]] && die "--private_key is required" [[ -z "${FLAGS_public_key}" ]] && die "--public_key is required" -# Put our public key in a place that update_engine can find it -${SRC_ROOT}/platform/vboot_reference/scripts/image_signing/insert_au_publickey.sh ${FLAGS_image} ${FLAGS_public_key} +OUTPUT_DIR=$(mktemp -d) +trap "rm -rf ${OUTPUT_DIR}" INT TERM EXIT # Generate a payload and sign it with our private key -cros_generate_update_payload --image ${FLAGS_image} --output /tmp/update.gz \ - --private_key ${FLAGS_private_key} - -# Verify that the payload signature is OK -delta_generator -in_file /tmp/update.gz -public_key ${FLAGS_public_key} - -# Generate the metadata payload -delta_generator -out_metadata /tmp/update.metadata -private_key ${FLAGS_private_key} \ - -in_file /tmp/update.gz +cros_generate_update_payload \ + --image "${FLAGS_image}" \ + --output "${OUTPUT_DIR}/update.gz" \ + --metadata_output "${OUTPUT_DIR}/update.metadata" \ + --private_key "${FLAGS_private_key}" \ + --public_key "${FLAGS_public_key}" \ + --outside_chroot MD5SUM=$(md5sum ${FLAGS_image} | cut -f1 -d" ") -gsutil cp /tmp/update.gz gs://update-storage.core-os.net/${FLAGS_track}/$MD5SUM/update.gz +gsutil cp "${OUTPUT_DIR}/update.gz" \ + gs://update-storage.core-os.net/${FLAGS_track}/$MD5SUM/update.gz CORE_UPDATE_URL="https://core-api.appspot.com" core-admin new-version \ - -k ${FLAGS_api_key} -v ${FLAGS_version} \ - -a ${FLAGS_app_id} \ - -m /tmp/update.metadata \ - -t ${FLAGS_track} -p $MD5SUM /tmp/update.gz + -k ${FLAGS_api_key} \ + -a ${FLAGS_app_id} \ + -v ${FLAGS_version} \ + -m "${OUTPUT_DIR}/update.metadata" \ + -t ${FLAGS_track} -p $MD5SUM "${OUTPUT_DIR}/update.gz" From ea8ed8f5dad61b949723689611f64342c6817d4f Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 8 Jul 2013 21:50:22 -0700 Subject: [PATCH 5/6] fix(core_upload_update): Set PATH for au-generator.zip bundles. The tools provided by au-generator.zip are expected to be in the PATH by this script and the scripts it calls. Make it so. --- core_upload_update | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core_upload_update b/core_upload_update index e1424702cf..47d24c2dad 100755 --- a/core_upload_update +++ b/core_upload_update @@ -45,6 +45,15 @@ switch_to_strict_mode [[ -z "${FLAGS_private_key}" ]] && die "--private_key is required" [[ -z "${FLAGS_public_key}" ]] && die "--public_key is required" +# Add the current directory to $PATH if we seem to be from a au bundle +if ! which cros_generate_update_payload &>/dev/null; then + if [[ -e "${SCRIPT_ROOT}/cros_generate_update_payload" ]]; then + export PATH="${SCRIPT_ROOT}:${PATH}" + else + die_notrace "Cannot find cros_generate_update_payload" + fi +fi + OUTPUT_DIR=$(mktemp -d) trap "rm -rf ${OUTPUT_DIR}" INT TERM EXIT From ef7aea86a939ac86083ffc3ec2177dfed4e9c641 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 8 Jul 2013 21:54:57 -0700 Subject: [PATCH 6/6] fix(generate_au_zip): Add core-admin to au-generator.zip Forgot to add this in previous commits, so here it is! --- build_library/generate_au_zip.py | 1 + 1 file changed, 1 insertion(+) diff --git a/build_library/generate_au_zip.py b/build_library/generate_au_zip.py index d6ffe9763f..9dc24d1fb4 100755 --- a/build_library/generate_au_zip.py +++ b/build_library/generate_au_zip.py @@ -26,6 +26,7 @@ STATIC_FILES = ['/usr/bin/old_bins/cgpt', ] DYNAMIC_EXECUTABLES = ['/usr/bin/delta_generator', + '/usr/bin/core-admin', '/usr/bin/bsdiff', '/usr/bin/bspatch']