mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
66 lines
2.4 KiB
Bash
Executable File
66 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright (c) 2013 The CoreOS 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_ROOT=$(dirname $(readlink -f "$0"))
|
|
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
|
|
|
DEFINE_string image "${SRC_ROOT}/build/images/amd64-generic/latest/${COREOS_BASE_IMAGE_NAME}" \
|
|
"Path to the basic image (not qemu/xen/etc)"
|
|
DEFINE_string version "${COREOS_VERSION_STRING}" \
|
|
"Version number of this build."
|
|
DEFINE_string track "dev-channel" \
|
|
"Track that this update goes into."
|
|
DEFINE_string api_key "" \
|
|
"API secret key for access to the administrative interface."
|
|
DEFINE_string public_key "" \
|
|
"Path to the public RSA key that will sign this build."
|
|
DEFINE_string private_key "" \
|
|
"Path to the private RSA key that will sign this build."
|
|
DEFINE_string app_id "{e96281a6-d1af-4bde-9a0a-97b76e56dc57}" \
|
|
"GUID of the app that this update is for."
|
|
|
|
FLAGS_HELPS="usage: $SCRIPTNAME [flags]
|
|
|
|
Setting everything up for use\n
|
|
|
|
1) Run 'gsutil config' and use project id coreos.com:core-update-storage\n
|
|
2) Ensure core-admin is installed, it is a recent addition\n
|
|
|
|
NOTE: Use the chromiumos_image.bin not a qemu/xen/etc image for generating the
|
|
update.
|
|
"
|
|
|
|
# Parse flags
|
|
FLAGS "$@" || exit 1
|
|
eval set -- "${FLAGS_ARGV}"
|
|
switch_to_strict_mode
|
|
|
|
[[ -z "${FLAGS_api_key}" ]] && die "--api_key is required"
|
|
[[ -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}
|
|
|
|
# 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
|
|
|
|
MD5SUM=$(md5sum ${FLAGS_image} | cut -f1 -d" ")
|
|
gsutil cp /tmp/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
|