diff options
author | Yuya Kusakabe <yuya.kusakabe@gmail.com> | 2016-03-07 00:00:33 +0900 |
---|---|---|
committer | Yuya Kusakabe <yuya.kusakabe@gmail.com> | 2016-03-07 00:03:14 +0900 |
commit | 7ba48ff801e98f25053b048e834b8b073fe21ad3 (patch) | |
tree | f79c21976b2d228ade907706d2aee418480498f0 /scripts/build-vmware-ovf | |
parent | c3a238ff2000ba4c27c791e66a9a4aaba9576a8f (diff) | |
download | vyos-build-7ba48ff801e98f25053b048e834b8b073fe21ad3.tar.gz vyos-build-7ba48ff801e98f25053b048e834b8b073fe21ad3.zip |
Add build scripts for VMware OVF (ref T14)
Diffstat (limited to 'scripts/build-vmware-ovf')
-rwxr-xr-x | scripts/build-vmware-ovf | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/build-vmware-ovf b/scripts/build-vmware-ovf new file mode 100755 index 00000000..ff2a5464 --- /dev/null +++ b/scripts/build-vmware-ovf @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-vmware-ovf +# Purpose: +# Build VyOS OVF for VMware. + +if [ ! $(which vmdk-convert) ]; then + echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." + exit 1 +else + echo "Your system has vmdk-convert." +fi + +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build_vmware_ovf.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} + +packer build -only=vmware-image scripts/packer.json + +# Convert raw image to VMDK +source_image=${PACKER_BUILD_DIR}/vmware/vyos_vmware_image.img +tmp_vmdk=${PACKER_BUILD_DIR}/vmware/tmp.vmdk +vmdk=${PACKER_BUILD_DIR}/vmware/vyos_vmware_image.vmdk +qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +vmdk-convert ${tmp_vmdk} ${vmdk} + +# Generate OVF +vmdk_file_size=$(du --bytes ${vmdk} | awk '{print $1}') +cat scripts/template.ovf | sed "s/{{vmdk_file_size}}/${vmdk_file_size}/" > packer_build/vmware/vyos_vmware_image.ovf |