From d3017ec76c8d5d14dcc99b88b2942fe4ca4c8474 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Wed, 6 May 2026 12:22:18 +0100 Subject: [PATCH] vm_image_util: Share the Vagrant metadata JSON between providers We currently publish separate metadata for each provider, VirtualBox and Parallels, but you're supposed to combine these and let Vagrant choose the provider. Rewriting an existing output file is a little weird, but this use of jq makes it relatively safe. Signed-off-by: James Le Cuirot --- build_library/vm_image_util.sh | 55 +++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 0543ea6840..32399068c2 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -954,9 +954,15 @@ write_vm_bundle() { _write_box_bundle() { local box=$(_dst_path ".box") - local json=$(_dst_path ".json") local image=${VM_DST_IMG} - local provider="virtualbox" + + # Share the metadata JSON between providers. + local json=${VM_SRC_IMG##*/} + json=$(_dst_dir)/${json%_image.bin}_vagrant.json + + local -xI FLATCAR_VERSION FLATCAR_VERSION_ID VM_GROUP + local -x provider="virtualbox" + local -x arch=${BOARD%-usr} if [[ "${VM_IMG_TYPE}" == vagrant_parallels ]]; then provider="parallels" @@ -966,28 +972,37 @@ _write_box_bundle() { mv "$(_dst_path ".pvs")" "${image}"/config.pvs fi - cat > "${VM_TMP_DIR}"/box/metadata.json < "${VM_TMP_DIR}"/box/metadata.json mv "${image}" "${VM_TMP_DIR}/box" tar -czf "${box}" -C "${VM_TMP_DIR}/box" . - cat >"${json}" < "${json}" + VM_GENERATED_FILES+=( "${box}" "${json}" ) }