feat(build_image): Optionally generate update payload with prod images.

This commit is contained in:
Michael Marineau 2014-04-30 19:35:13 -07:00
parent e1d7b29436
commit 4e85b172df
2 changed files with 26 additions and 11 deletions

View File

@ -35,6 +35,8 @@ DEFINE_string disk_layout "base" \
"The disk layout type to use for this image."
DEFINE_string group "${DEFAULT_GROUP}" \
"The update group."
DEFINE_boolean generate_update "${FLAGS_FALSE}" \
"Generate update payload. (prod only)"
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
@ -160,15 +162,15 @@ if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME}
setup_prod_image ${COREOS_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT}
upload_image "${BUILD_DIR}/${COREOS_PRODUCTION_IMAGE_NAME}"
if [[ ${FLAGS_generate_update} -eq ${FLAGS_TRUE} ]]; then
generate_update "${COREOS_PRODUCTION_IMAGE_NAME}" ${DISK_LAYOUT}
fi
fi
if ! should_build_image ${PRISTINE_IMAGE_NAME}; then
rm -f "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}"
fi
# Generating AU generator zip file to run outside chroot
generate_au_zip || echo "Failed generating AU zip file - ignoring Error..."
# Write out a version.txt file, this will be used by image_to_vm.sh
tee "${BUILD_DIR}/version.txt" <<EOF
COREOS_BUILD=${COREOS_BUILD}
@ -177,8 +179,7 @@ COREOS_PATCH=${COREOS_PATCH}
COREOS_SDK_VERSION=${COREOS_SDK_VERSION}
EOF
upload_image -d "${BUILD_DIR}/au-generator.zip.DIGESTS" \
"${BUILD_DIR}/au-generator.zip" "${BUILD_DIR}/version.txt"
upload_image "${BUILD_DIR}/version.txt"
# Create a named symlink.
LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}"

View File

@ -135,14 +135,28 @@ delete_prompt() {
fi
}
generate_au_zip () {
local lgenerateauzip="${BUILD_LIBRARY_DIR}/generate_au_zip.py"
local largs="-o ${BUILD_DIR}"
test ! -d "${BUILD_DIR}" && mkdir -p "${BUILD_DIR}"
info "Running ${lgenerateauzip} ${largs} for generating AU updater zip file"
generate_update() {
local image_name="$1"
local disk_layout="$2"
local update_prefix="${image_name%_image.bin}_update"
local update="${BUILD_DIR}/${update_prefix}"
local devkey="/usr/share/update_engine/update-payload-key.key.pem"
echo "Generating update payload, signed with a dev key"
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${disk_layout}" \
extract "${BUILD_DIR}/${image_name}" "USR-A" "${update}.bin"
delta_generator -private_key "${devkey}" \
-new_image "${update}.bin" -out_file "${update}.gz"
delta_generator -private_key "${devkey}" \
-in_file "${update}.gz" -out_metadata "${update}.meta"
info "Generating update tools zip"
# Make sure some vars this script needs are exported
export REPO_MANIFESTS_DIR SCRIPTS_DIR
$lgenerateauzip $largs
"${BUILD_LIBRARY_DIR}/generate_au_zip.py" \
--output-dir "${BUILD_DIR}" --zip-name "${update_prefix}.zip"
upload_image -d "${update}.DIGESTS" "${update}".{bin,gz,meta,zip}
}
# Basic command to emerge binary packages into the target image.