diff --git a/build_image b/build_image index c9d80c9e6c..b7e63861b4 100755 --- a/build_image +++ b/build_image @@ -32,8 +32,10 @@ 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 torcx_manifest "${DEFAULT_BUILD_ROOT}/torcx/${DEFAULT_BOARD}/latest/torcx_manifest.json" \ + "The torcx manifest describing torcx packages for this image (or blank for none)" +DEFINE_string torcx_root "${DEFAULT_BUILD_ROOT}/torcx" \ + "Directory in which torcx packages can be found" DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ "Directory in which to place image result directories (named by version)" DEFINE_string disk_layout "" \ @@ -89,8 +91,8 @@ 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" +if [ "x${FLAGS_torcx_manifest}" = "x${DEFAULT_BUILD_ROOT}/torcx/${DEFAULT_BOARD}/latest/torcx_manifest.json" ]; then + FLAGS_torcx_manifest="${DEFAULT_BUILD_ROOT}/torcx/${FLAGS_board}/latest/torcx_manifest.json" fi # If downloading packages is enabled ensure the board is configured properly. @@ -107,6 +109,7 @@ fi . "${BUILD_LIBRARY_DIR}/prod_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/dev_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1 +. "${BUILD_LIBRARY_DIR}/torcx_manifest.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1 PROD_IMAGE=0 diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index def5ab03c8..c70e2b0fe1 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -424,10 +424,25 @@ 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 + # Copy in packages from the torcx store that are marked as being on disk + if [ -n "${FLAGS_torcx_manifest}" ]; then + for pkg in $(torcx_manifest::get_pkg_names "${FLAGS_torcx_manifest}"); do + local default_version="$(torcx_manifest::default_version "${FLAGS_torcx_manifest}" "${pkg}")" + for version in $(torcx_manifest::get_versions "${FLAGS_torcx_manifest}" "${pkg}"); do + local on_disk_path="$(torcx_manifest::local_store_path "${FLAGS_torcx_manifest}" "${pkg}" "${version}")" + if [[ -n "${on_disk_path}" ]]; then + local casDigest="$(torcx_manifest::get_digest "${FLAGS_torcx_manifest}" "${pkg}" "${version}")" + sudo cp "${FLAGS_torcx_root}/pkgs/${BOARD}/${pkg}/${casDigest}/${pkg}:${version}.torcx.tgz" \ + "${root_fs_dir}${on_disk_path}" + + if [[ "${version}" == "${default_version}" ]]; then + # Create the default symlink for this package + sudo ln -fns "${on_disk_path##*/}" \ + "${root_fs_dir}/${on_disk_path%/*}/${pkg}:com.coreos.cl.torcx.tgz" + fi + fi + done + done fi # Only enable rootfs verification on prod builds.