feat(vm_image_util): Add Vagrant metadata file

This is required for Vagrant to recognize box versions:
http://docs.vagrantup.com/v2/boxes/versioning.html
This commit is contained in:
Michael Marineau 2014-04-28 23:24:30 -04:00
parent 39951946ca
commit 8183430f6c
2 changed files with 32 additions and 1 deletions

View File

@ -174,3 +174,17 @@ upload_image() {
local def_upload_path="${UPLOAD_ROOT}/${BOARD}/${COREOS_VERSION_STRING}"
upload_files "${log_msg}" "${def_upload_path}" "" "${uploads[@]}"
}
# Translate the configured upload URL to a download URL
# Usage: download_image_url "path/suffix"
download_image_url() {
if [[ ${FLAGS_upload} -ne ${FLAGS_TRUE} ]]; then
echo "$1"
return 0
fi
local upload_path="${UPLOAD_ROOT}/${BOARD}/${COREOS_VERSION_STRING}"
if [[ -n "${UPLOAD_PATH}" ]]; then
upload_path="${UPLOAD_PATH}"
fi
echo "http://${upload_path#gs://}/$1"
}

View File

@ -717,10 +717,27 @@ write_vm_bundle() {
_write_box_bundle() {
local box=$(_dst_path ".box")
local json=$(_dst_path ".json")
mv "${VM_DST_IMG}" "${VM_TMP_DIR}/box"
tar -czf "${box}" -C "${VM_TMP_DIR}/box" .
VM_GENERATED_FILES+=( "${box}" )
cat >"${json}" <<EOF
{
"name": "coreos-alpha",
"description": "CoreOS alpha",
"versions": [{
"version": "${COREOS_VERSION_ID}",
"providers": [{
"name": "virtualbox",
"url": "$(download_image_url "$(_dst_name ".box")")",
"checksum_type": "sha256",
"checksum": "$(sha256sum "${box}" | awk '{print $1}')"
}]
}]
}
EOF
VM_GENERATED_FILES+=( "${box}" "${json}" )
}
vm_cleanup() {