From 39086358bfd314538e13176819f31d196c2f72f1 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 27 Mar 2014 16:59:19 -0700 Subject: [PATCH] refactor(build_image): Build dev and prod images independently We need some more control over exactly what lands in dev vs prod images which will require letting them diverge in what is currently the common base image step. There isn't any real need for the base image in the first place other than to speed up building both dev and prod images at the same time but that isn't common enough to worry about. As part of this cleanup also remove references to CHROMEOS_* variables and the recovery image that never actually existed in CoreOS. --- build_image | 58 +++++----------- build_library/build_image_util.sh | 65 ----------------- common.sh | 10 +-- image_to_vm.sh | 2 +- security_test_image | 112 ------------------------------ 5 files changed, 21 insertions(+), 226 deletions(-) delete mode 100755 security_test_image diff --git a/build_image b/build_image index de058d63b3..8b7c7ec0b7 100755 --- a/build_image +++ b/build_image @@ -74,7 +74,7 @@ DEFINE_string version "" \ # Parse command line. FLAGS "$@" || exit 1 -eval set -- "${FLAGS_ARGV}" +eval set -- "${FLAGS_ARGV:-dev}" # Only now can we die on error. shflags functions leak non-zero error codes, # so will die prematurely if 'switch_to_strict_mode' is specified before now. @@ -92,14 +92,18 @@ check_gsutil_opts . "${BUILD_LIBRARY_DIR}/dev_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1 -parse_build_image_args +PROD_IMAGE=0 +DEV_IMAGE=0 +for arg in "$@"; do + case "${arg}" in + prod) PROD_IMAGE=1 ;; + dev) DEV_IMAGE=1 ;; + *) die_notrace "Unknown image type ${arg}" ;; + esac +done BASE_PACKAGE="coreos-base/coreos" -PRISTINE_IMAGE_NAME=${CHROMEOS_BASE_IMAGE_NAME} - -DEVKEYSDIR="/usr/share/vboot/devkeys" - eclean-$BOARD -d packages if [[ ${skip_blacklist_check} -ne 1 ]]; then @@ -134,31 +138,14 @@ mkdir -p "${BUILD_DIR}" DISK_LAYOUT="${FLAGS_disk_layout:-base}" -# Create the base image. -create_base_image "${PRISTINE_IMAGE_NAME}" "${DISK_LAYOUT}" "${FLAGS_group}" -if should_build_image ${PRISTINE_IMAGE_NAME}; then - upload_image "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" +if [[ "${DEV_IMAGE}" -eq 1 ]]; then + create_base_image ${COREOS_DEVELOPER_IMAGE_NAME} ${DISK_LAYOUT} ${FLAGS_group} + install_dev_packages ${COREOS_DEVELOPER_IMAGE_NAME} ${DISK_LAYOUT} + upload_image "${BUILD_DIR}/${COREOS_DEVELOPER_IMAGE_NAME}" fi -# Running board-specific setup if any exists. -if type board_setup &>/dev/null; then - board_setup "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" -fi - -# Create a developer image if an image that is based on it is requested. -if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME}; then - if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then - cp "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" \ - "${BUILD_DIR}/${CHROMEOS_DEVELOPER_IMAGE_NAME}" - else - copy_image ${PRISTINE_IMAGE_NAME} ${CHROMEOS_DEVELOPER_IMAGE_NAME} - fi - install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${DISK_LAYOUT} - upload_image "${BUILD_DIR}/${CHROMEOS_DEVELOPER_IMAGE_NAME}" -fi - -if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then - copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME} +if [[ "${PROD_IMAGE}" -eq 1 ]]; then + create_base_image ${COREOS_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} ${FLAGS_group} 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 @@ -166,10 +153,6 @@ if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then fi fi -if ! should_build_image ${PRISTINE_IMAGE_NAME}; then - rm -f "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" -fi - # Write out a version.txt file, this will be used by image_to_vm.sh tee "${BUILD_DIR}/version.txt" <