From a0bebcc38b882fefb1264f9c0094eec466cf605a Mon Sep 17 00:00:00 2001 From: David Michael Date: Thu, 18 May 2017 18:17:59 -0700 Subject: [PATCH] build_image: copy torcx images into the vendor store This adds the option --torcx_store to specify the path to a directory containing torcx images to be baked into the OS image. A blank string can be given instead of a path to restore the previous behavior and leave an empty vendor store. The default value is the default path created by build_torcx_store, which is used when build_packages updates torcx images. This means that the current pattern "./build_packages && ./build_image prod" should result in a fully updated OS image with all torcx images available in the vendor store. --- build_image | 7 +++++++ build_library/build_image_util.sh | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/build_image b/build_image index d7f09fef37..c9d80c9e6c 100755 --- a/build_image +++ b/build_image @@ -32,6 +32,8 @@ DEFINE_string base_pkg "coreos-base/coreos" \ "The base portage package to base the build off of (only applies to prod images)" DEFINE_string base_dev_pkg "coreos-base/coreos-dev" \ "The base portage package to base the build off of (only applies to dev images)" +DEFINE_string torcx_store "${DEFAULT_BUILD_ROOT}/torcx/${DEFAULT_BOARD}/latest" \ + "Directory of torcx images to copy into the vendor store (or blank for none)" DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ "Directory in which to place image result directories (named by version)" DEFINE_string disk_layout "" \ @@ -86,6 +88,11 @@ switch_to_strict_mode check_gsutil_opts +# Patch around default values not being able to depend on other flags. +if [ "x${FLAGS_torcx_store}" = "x${DEFAULT_BUILD_ROOT}/torcx/${DEFAULT_BOARD}/latest" ]; then + FLAGS_torcx_store="${DEFAULT_BUILD_ROOT}/torcx/${FLAGS_board}/latest" +fi + # If downloading packages is enabled ensure the board is configured properly. if [[ ${FLAGS_getbinpkg} -eq ${FLAGS_TRUE} ]]; then "${SRC_ROOT}/scripts/setup_board" --board="${FLAGS_board}" \ diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 1e19fcb792..def5ab03c8 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -424,6 +424,12 @@ finish_image() { local install_grub=0 local disk_img="${BUILD_DIR}/${image_name}" + # Copy in a vendor torcx store if requested. + if [ -n "${FLAGS_torcx_store}" ]; then + sudo cp -dt "${root_fs_dir}"/usr/share/torcx/store \ + "${FLAGS_torcx_store}"/*.torcx.tgz + fi + # Only enable rootfs verification on prod builds. local disable_read_write="${FLAGS_FALSE}" if [[ "${IMAGE_BUILD_TYPE}" == "prod" ]]; then