From 39951946ca11a1ac4aa6293a1cc7aa49e3ebca9b Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 28 Apr 2014 19:52:24 -0400 Subject: [PATCH 1/5] 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}" < Date: Mon, 28 Apr 2014 23:24:30 -0400 Subject: [PATCH 2/5] 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 --- build_library/release_util.sh | 14 ++++++++++++++ build_library/vm_image_util.sh | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/build_library/release_util.sh b/build_library/release_util.sh index f5dba907cb..0210d1e958 100644 --- a/build_library/release_util.sh +++ b/build_library/release_util.sh @@ -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" +} diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 5fefafaf61..43731cd0f0 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -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}" < Date: Tue, 29 Apr 2014 00:25:35 -0400 Subject: [PATCH 3/5] maint(set_lsb_release): Remove gentoo-release (again) We now require Vagrant 1.5.0 both in documentation and in code which uses os-release instead of gentoo-release. --- build_library/set_lsb_release | 3 --- 1 file changed, 3 deletions(-) diff --git a/build_library/set_lsb_release b/build_library/set_lsb_release index 1a2d7552d1..b74c93aca7 100755 --- a/build_library/set_lsb_release +++ b/build_library/set_lsb_release @@ -67,6 +67,3 @@ sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/update.conf" < Date: Tue, 29 Apr 2014 01:00:45 -0400 Subject: [PATCH 4/5] fix(common): Switch to os-release style names in version.txt The existing version.txt is kinda annoying. The common case of referring to the current version requires joining three values and the names of those values only make sense in ChromeOS. Instead just use version as a string, using VERSION, VERSION_ID, and BUILD_ID just as they appear in os-release. It is up to the few scripts that need the individual parts to break the version apart. The old values remain for the sake of compatibility. --- build_image | 3 +++ common.sh | 11 ++++++++--- image_to_vm.sh | 2 +- tag_release | 18 +++++++++++------- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/build_image b/build_image index 32eb1caf61..e54d727a1b 100755 --- a/build_image +++ b/build_image @@ -177,6 +177,9 @@ tee "${BUILD_DIR}/version.txt" < Date: Tue, 29 Apr 2014 03:37:09 -0400 Subject: [PATCH 5/5] fix(vm_image_util): Fix building vagrant vmware fusion images. --- build_library/vm_image_util.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 43731cd0f0..61234cd970 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -535,7 +535,10 @@ usb.generic.autoconnect = "FALSE" usb.present = "TRUE" rtc.diffFromUTC = 0 EOF - VM_GENERATED_FILES+=( "${vmx_path}" ) + # Only upload the vmx if it won't be bundled + if [[ -z "$(_get_vm_opt BUNDLE_FORMAT)" ]]; then + VM_GENERATED_FILES+=( "${vmx_path}" ) + fi } _write_vmware_zip_conf() { @@ -722,6 +725,11 @@ _write_box_bundle() { mv "${VM_DST_IMG}" "${VM_TMP_DIR}/box" tar -czf "${box}" -C "${VM_TMP_DIR}/box" . + local provider="virtualbox" + if [[ "${VM_IMG_TYPE}" == vagrant_vmware_fusion ]]; then + provider="vmware_fusion" + fi + cat >"${json}" <