From 39951946ca11a1ac4aa6293a1cc7aa49e3ebca9b Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 28 Apr 2014 19:52:24 -0400 Subject: [PATCH] feat(vm_image_util): Add new build steps, update vagrant builds This adds two new optional build steps. The first user of these is the vagrant images but many of the targets can be simplified now. - fs_hook: Anything that needs to happen before unmounting the image. This happens after the OEM is installed but before disk images are made. It can be used to copy any data out of the image. - bundle_format: Many VM types ship as some sort of archive format rather than plain disk images as this script originally assumed. Adding this final step lets us stop using the conf step awkwardly. Vagrant now ships with a Vagrantfile and related code included in the OEM package. This lets us version our vagrant-side code along with the images themselves as well making the coreos-vagrant repo optional again. The coreos-vagrant code will still be useful for handling the fancier cluster configuration stuff but no longer has to carry the plugin code. --- build_library/virtualbox_ovf.sh | 10 --- build_library/vm_image_util.sh | 124 ++++++++++++++++---------------- image_to_vm.sh | 2 + 3 files changed, 62 insertions(+), 74 deletions(-) diff --git a/build_library/virtualbox_ovf.sh b/build_library/virtualbox_ovf.sh index 6a430a7894..06609927f2 100755 --- a/build_library/virtualbox_ovf.sh +++ b/build_library/virtualbox_ovf.sh @@ -51,18 +51,8 @@ datez() { if [[ -n "${FLAGS_output_vagrant}" ]]; then cat >"${FLAGS_output_vagrant}" < "${VM_TMP_DIR}"/metadata.json < "${VM_TMP_DIR}"/box/metadata.json < "${VM_README}" <= 1.2.3 is required. Use something like the following to get started: -vagrant box add coreos path/to/$(basename "${box}") -vagrant init coreos -vagrant up -vagrant ssh - -You will get a warning about "No guest additions were detected...", -this is expected and should be ignored. SSH should work just dandy. -EOF - - # Replace list, not append, since we packaged up the disk image. - VM_GENERATED_FILES=( "${box}" "${VM_README}" ) } _write_vagrant_vmware_fusion_conf() { local vm_mem="${1:-$(_get_vm_opt MEM)}" - local src_name=$(basename "$VM_SRC_IMG") - local dst_name=$(basename "$VM_DST_IMG") - local dst_dir=$(dirname "$VM_DST_IMG") - local vmx_path="${dst_dir}/$(_src_to_dst_name "${src_name}" ".vmx")" - local vmx_file=$(basename "${vmx_path}") - local vfile="${VM_TMP_DIR}/Vagrantfile" - local box="${dst_dir}/$(_src_to_dst_name "${src_name}" ".box")" - - # Move the disk image to tmp, it won't be a final output file - mv "${VM_DST_IMG}" "${VM_TMP_DIR}/${dst_name}" + local vmx=$(_dst_path ".vmx") + mkdir -p "${VM_TMP_DIR}/box" _write_vmx_conf ${vm_mem} - "${BUILD_LIBRARY_DIR}/virtualbox_ovf.sh" \ - --vm_name "$VM_NAME" \ - --disk_vmdk "${VM_TMP_DIR}/${dst_name}" \ - --memory_size "$vm_mem" \ - --output_vagrant "$vfile" + mv "${vmx}" "${VM_TMP_DIR}/box" - cat > "${VM_TMP_DIR}"/metadata.json < "${VM_TMP_DIR}"/box/metadata.json < "${VM_README}" <