mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-29 06:21:46 +01:00
feat(build_image): Add upload support for official builds
This commit is contained in:
parent
34bbdc1996
commit
b4252985f2
10
build_image
10
build_image
@ -34,6 +34,9 @@ DEFINE_string usb_disk /dev/sdb4 \
|
|||||||
DEFINE_string enable_serial "" \
|
DEFINE_string enable_serial "" \
|
||||||
"Enable serial port for printks. Example values: ttyS0"
|
"Enable serial port for printks. Example values: ttyS0"
|
||||||
|
|
||||||
|
# include upload options
|
||||||
|
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
|
||||||
|
|
||||||
FLAGS_HELP="USAGE: build_image [flags] [list of images to build].
|
FLAGS_HELP="USAGE: build_image [flags] [list of images to build].
|
||||||
This script is used to build a CoreOS image. CoreOS comes in many
|
This script is used to build a CoreOS image. CoreOS comes in many
|
||||||
different forms. This scripts can be used to build the following:
|
different forms. This scripts can be used to build the following:
|
||||||
@ -86,6 +89,8 @@ eval set -- "${FLAGS_ARGV}"
|
|||||||
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
||||||
switch_to_strict_mode
|
switch_to_strict_mode
|
||||||
|
|
||||||
|
check_gsutil_opts
|
||||||
|
|
||||||
# N.B. Ordering matters for some of the libraries below, because
|
# N.B. Ordering matters for some of the libraries below, because
|
||||||
# some of the files contain initialization used by later files.
|
# some of the files contain initialization used by later files.
|
||||||
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
|
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
|
||||||
@ -146,6 +151,7 @@ mkdir -p "${BUILD_DIR}"
|
|||||||
# Create the base image.
|
# Create the base image.
|
||||||
create_base_image ${PRISTINE_IMAGE_NAME} ${FLAGS_enable_rootfs_verification} \
|
create_base_image ${PRISTINE_IMAGE_NAME} ${FLAGS_enable_rootfs_verification} \
|
||||||
${FLAGS_enable_bootcache}
|
${FLAGS_enable_bootcache}
|
||||||
|
upload_image "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}"
|
||||||
|
|
||||||
# Running board-specific setup if any exists.
|
# Running board-specific setup if any exists.
|
||||||
if type board_setup &>/dev/null; then
|
if type board_setup &>/dev/null; then
|
||||||
@ -157,22 +163,26 @@ if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} \
|
|||||||
${CHROMEOS_TEST_IMAGE_NAME}; then
|
${CHROMEOS_TEST_IMAGE_NAME}; then
|
||||||
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${CHROMEOS_DEVELOPER_IMAGE_NAME}
|
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${CHROMEOS_DEVELOPER_IMAGE_NAME}
|
||||||
install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME}
|
install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME}
|
||||||
|
upload_image "${BUILD_DIR}/${CHROMEOS_DEVELOPER_IMAGE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then
|
if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then
|
||||||
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME}
|
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME}
|
||||||
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
|
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
|
||||||
${COREOS_PRODUCTION_IMAGE_NAME}
|
${COREOS_PRODUCTION_IMAGE_NAME}
|
||||||
|
upload_image "${BUILD_DIR}/${COREOS_PRODUCTION_IMAGE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# From a developer image create a test|factory_test image.
|
# From a developer image create a test|factory_test image.
|
||||||
if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then
|
if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then
|
||||||
copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${CHROMEOS_TEST_IMAGE_NAME}
|
copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${CHROMEOS_TEST_IMAGE_NAME}
|
||||||
mod_image_for_test ${CHROMEOS_TEST_IMAGE_NAME}
|
mod_image_for_test ${CHROMEOS_TEST_IMAGE_NAME}
|
||||||
|
upload_image "${BUILD_DIR}/${CHROMEOS_TEST_IMAGE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generating AU generator zip file to run outside chroot
|
# Generating AU generator zip file to run outside chroot
|
||||||
generate_au_zip || echo "Failed generating AU zip file - ignoring Error..."
|
generate_au_zip || echo "Failed generating AU zip file - ignoring Error..."
|
||||||
|
upload_image "${BUILD_DIR}/au-generator.zip"
|
||||||
|
|
||||||
# Create a named symlink.
|
# Create a named symlink.
|
||||||
LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}"
|
LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}"
|
||||||
|
|||||||
@ -9,6 +9,9 @@ if [[ ${COREOS_OFFICIAL:-0} -eq 1 ]]; then
|
|||||||
UPLOAD_DEFAULT=${FLAGS_TRUE}
|
UPLOAD_DEFAULT=${FLAGS_TRUE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
IMAGE_ZIPPER="lbzip2 --compress --keep"
|
||||||
|
IMAGE_ZIPEXT=".bz2"
|
||||||
|
|
||||||
DEFINE_boolean parallel ${FLAGS_TRUE} \
|
DEFINE_boolean parallel ${FLAGS_TRUE} \
|
||||||
"Enable parallelism in gsutil."
|
"Enable parallelism in gsutil."
|
||||||
DEFINE_boolean upload ${UPLOAD_DEFAULT} \
|
DEFINE_boolean upload ${UPLOAD_DEFAULT} \
|
||||||
@ -35,3 +38,43 @@ upload_packages() {
|
|||||||
info "Uploading packages"
|
info "Uploading packages"
|
||||||
gsutil ${GSUTIL_OPTS} cp -R "${BOARD_PACKAGES}"/* "${UPLOAD_PATH}"
|
gsutil ${GSUTIL_OPTS} cp -R "${BOARD_PACKAGES}"/* "${UPLOAD_PATH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
make_digests() {
|
||||||
|
local dirname=$(dirname "$1")
|
||||||
|
local filename=$(basename "$1")
|
||||||
|
cd "${dirname}"
|
||||||
|
info "Computing DIGESTS for ${filename}"
|
||||||
|
echo -n > "${filename}.DIGESTS"
|
||||||
|
for hash in md5 sha1 sha512; do
|
||||||
|
echo "# $hash HASH" | tr "a-z" "A-Z" >> "${filename}.DIGESTS"
|
||||||
|
${hash}sum "${filename}" >> "${filename}.DIGESTS"
|
||||||
|
done
|
||||||
|
cd -
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_image() {
|
||||||
|
[[ ${FLAGS_upload} -eq ${FLAGS_TRUE} ]] || return 0
|
||||||
|
[[ -n "${BOARD}" ]] || die "board_options.sh must be sourced first"
|
||||||
|
|
||||||
|
local BUILT_IMAGE="$1"
|
||||||
|
local UPLOAD_PATH="${UPLOAD_ROOT}/${BOARD}/${COREOS_VERSION_STRING}/"
|
||||||
|
|
||||||
|
if [[ ! -f "${BUILT_IMAGE}" ]]; then
|
||||||
|
die "Image '${BUILT_IMAGE}' does not exist!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compress raw images
|
||||||
|
if [[ "${BUILT_IMAGE}" =~ \.(img|bin)$ ]]; then
|
||||||
|
info "Compressing ${BUILT_IMAGE##*/}"
|
||||||
|
$IMAGE_ZIPPER "${BUILT_IMAGE}"
|
||||||
|
BUILT_IMAGE="${BUILT_IMAGE}${IMAGE_ZIPEXT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For consistency generate a .DIGESTS file similar to the one catalyst
|
||||||
|
# produces for the SDK tarballs and up upload it too.
|
||||||
|
make_digests "${BUILT_IMAGE}"
|
||||||
|
|
||||||
|
info "Uploading ${BUILT_IMAGE##*/}"
|
||||||
|
gsutil ${GSUTIL_OPTS} cp "${BUILT_IMAGE}" \
|
||||||
|
"${BUILT_IMAGE}.DIGESTS" "${UPLOAD_PATH}"
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user