From 8a15840d6a4c3af92d08f634d4589cb0fe054e12 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 29 Jan 2014 16:38:48 -0800 Subject: [PATCH] fix(vm_image_util): Use more consistent names for vm .DIGESTS Switch from naming DIGESTS based in disk image name to a common prefix. old: coreos_production_qemu_image.img.DIGESTS -> new: coreos_production_qemu.DIGESTS The old behavior wasn't very consistent since plain disk images aren't used by all types and the code implementing that was easy to brake, namely by mistake coreos_production_pxe_image.cpio.gz.DIGESTS became coreos_production_pxe.vmlinuz.DIGESTS a couple releases ago. The old names will continue to exist as well for the time being to avoid breaking existing install/download scripts and the original pxe DIGESTS name is back. --- build_library/vm_image_util.sh | 35 +++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 0c8cb46d62..f6b1da68d0 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -632,8 +632,41 @@ vm_cleanup() { } vm_upload() { - local digests="${VM_GENERATED_FILES[0]}.DIGESTS" + local digests="$(_dst_dir)/$(_dst_name .DIGESTS)" upload_image -d "${digests}" "${VM_GENERATED_FILES[@]}" + + # FIXME(marineam): Temporary alternate name for .DIGESTS + # This used to be derived from the first file listed in + # ${VM_GENERATED_FILES[@]}", usually $VM_DST_IMG or similar. + # Since not everything actually uploads $VM_DST_IMG this was not very + # consistent and relying on ordering was breakable. + # Now the common prefix, output by $(_dst_name) is used above. + # Some download/install scripts may still refer to the old name. + local uploaded legacy_digests + for uploaded in "${VM_GENERATED_FILES[@]}"; do + if [[ "${uploaded}" == "${VM_DST_IMG}" ]]; then + legacy_digests="$(_dst_dir)/$(basename ${VM_DST_IMG}).DIGESTS" + break + fi + done + + # Since depending on the ordering of $VM_GENERATED_FILES is brittle only + # use it if $VM_DST_IMG isn't included in the uploaded files. + if [[ -z "${legacy_digests}" ]]; then + legacy_digests="${VM_GENERATED_FILES[0]}.DIGESTS" + fi + + [[ "${legacy_digests}" != "${digests}" ]] || return + + local legacy_uploads=( "${legacy_digests}" ) + cp "${digests}" "${legacy_digests}" + if [[ -e "${digests}.asc" ]]; then + legacy_uploads+=( "${legacy_digests}.asc" ) + cp "${digests}.asc" "${legacy_digests}.asc" + fi + + local def_upload_path="${UPLOAD_ROOT}/${BOARD}/${COREOS_VERSION_STRING}" + upload_files "$(_dst_name)" "${def_upload_path}" "" "${legacy_uploads[@]}" } print_readme() {