From 3e56d7456e55b46ceb1dbca6a8f5cbc5150e18f5 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Fri, 4 Mar 2016 14:33:32 +0900 Subject: Add qemu image build scripts --- scripts/build-qemu-image | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/build-qemu-image (limited to 'scripts/build-qemu-image') diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image new file mode 100755 index 00000000..8643508a --- /dev/null +++ b/scripts/build-qemu-image @@ -0,0 +1,30 @@ +#!/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 . +# +# File: build-qemu-image +# Purpose: +# Build VyOS raw image for qemu. + + +export ISO_IMAGE=./build/live-image-amd64.hybrid.iso +export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} + +packer build -only=qemu scripts/packer.json -- cgit v1.2.3 From 7ba48ff801e98f25053b048e834b8b073fe21ad3 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Mon, 7 Mar 2016 00:00:33 +0900 Subject: Add build scripts for VMware OVF (ref T14) --- Makefile | 7 +++ scripts/build-qemu-image | 2 +- scripts/build-vmware-ovf | 45 ++++++++++++++ scripts/packer-scripts/vmware.sh | 29 +++++++++ scripts/packer.json | 33 ++++++++++ scripts/template.ovf | 131 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 246 insertions(+), 1 deletion(-) create mode 100755 scripts/build-vmware-ovf create mode 100644 scripts/packer-scripts/vmware.sh create mode 100644 scripts/template.ovf (limited to 'scripts/build-qemu-image') diff --git a/Makefile b/Makefile index 86f0c27d..adce002c 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,13 @@ qemu: @scripts/check-vm-build-env @scripts/build-qemu-image +.PHONY: vmware-ovf +.ONESHELL: +vmware-ovf: + @set -e + @scripts/check-vm-build-env + @scripts/build-vmware-ovf + .PHONY: clean .ONESHELL: clean: diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 8643508a..4a67f0f3 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -27,4 +27,4 @@ export PACKER_LOG=1 mkdir -p ${PACKER_BUILD_DIR} -packer build -only=qemu scripts/packer.json +packer build -only=qemu-image scripts/packer.json 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 . +# +# 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 diff --git a/scripts/packer-scripts/vmware.sh b/scripts/packer-scripts/vmware.sh new file mode 100644 index 00000000..60c4db7e --- /dev/null +++ b/scripts/packer-scripts/vmware.sh @@ -0,0 +1,29 @@ +#!/bin/vbash +source /opt/vyatta/etc/functions/script-template + +# Add Debian Jessie repository +set system package repository jessie url 'http://ftp.nl.debian.org/debian/' +set system package repository jessie distribution 'jessie' +set system package repository jessie components 'main contrib non-free' +commit +save + +# Install open-vm-tools +sudo apt-get update +sudo apt-get -y install open-vm-tools + +# Delete Debian Jessie repository +delete system package repository jessie +commit +save + +# Removing leftover leases and persistent rules +sudo rm -f /var/lib/dhcp3/* + +# Removing apt caches +sudo rm -rf /var/cache/apt/* + +# Removing hw-id +delete interfaces ethernet eth0 hw-id +commit +save diff --git a/scripts/packer.json b/scripts/packer.json index 6d487353..e54dc74e 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -7,6 +7,7 @@ "builders": [ { + "name": "qemu-image", "type": "qemu", "iso_url": "{{user `iso_url`}}", "iso_checksum": "{{user `iso_checksum`}}", @@ -57,6 +58,38 @@ "save", "exit" ] + }, + { + "name": "vmware-image", + "type": "qemu", + "iso_url": "{{user `output_directory`}}/qemu/vyos_qemu_image.img", + "iso_checksum_type": "none", + "output_directory": "{{user `output_directory`}}/vmware", + "shutdown_command": "sudo halt -p", + "disk_image": true, + "disk_size": 4096, + "format": "raw", + "headless": false, + "accelerator": "tcg", + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + "ssh_username": "vyos", + "ssh_password": "vyos", + "ssh_port": 22, + "ssh_wait_timeout": "300s", + "vm_name": "vyos_vmware_image.img", + "net_device": "virtio-net", + "disk_interface": "virtio", + "boot_wait": "5s" + } + ], + "provisioners": [ + { + "type": "shell", + "only": ["vmware-image"], + "scripts": [ + "scripts/packer-scripts/vmware.sh" + ] } ] } diff --git a/scripts/template.ovf b/scripts/template.ovf new file mode 100644 index 00000000..2250eb55 --- /dev/null +++ b/scripts/template.ovf @@ -0,0 +1,131 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The VM Network network + + + + A virtual machine + vyos + + The kind of installed guest operating system + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + vyos + vmx-08 + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + 512MB of memory + 2 + 4 + 512 + + + 0 + USB Controller (EHCI) + usb + 3 + vmware.usb.ehci + 23 + + + + 0 + SCSI Controller + scsiController0 + 4 + lsilogic + 6 + + + 1 + IDE Controller + ideController1 + 5 + 5 + + + true + serial0 + 6 + 21 + + + + 0 + false + cdrom0 + 7 + 5 + 15 + + + 0 + disk0 + ovf:/disk/vmdisk1 + 8 + 4 + 17 + + + 2 + true + VM Network + VMXNET3 ethernet adapter on "nat" + ethernet0 + 9 + VMXNET3 + 10 + + + + false + sound + 10 + vmware.soundcard.ensoniq1371 + 1 + + + false + video + 11 + 24 + + + false + vmci + 12 + vmware.vmci + 1 + + + + + + + + + -- cgit v1.2.3 From 607dcde9bce70b17fbd24df7d441e6a1924983e9 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 26 Jan 2017 21:27:12 -0500 Subject: Account for different architectures in ISO naming. --- Makefile | 3 ++- scripts/build-qemu-image | 5 ++++- scripts/copy-image | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 scripts/copy-image (limited to 'scripts/build-qemu-image') diff --git a/Makefile b/Makefile index 501ab041..088a3474 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,8 @@ iso: clean prepare @echo "It's not like I'm building this specially for you or anything!" cd $(build_dir) lb build 2>&1 | tee build.log - ln -nsf live-image-amd64.hybrid.iso vyos-`cat version`-`dpkg --print-architecture`.iso + cd .. + @scripts/copy-image .PHONY: prepare-package-env .ONESHELL: diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 4a67f0f3..59a42f07 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -18,8 +18,11 @@ # Purpose: # Build VyOS raw image for qemu. +BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) +VERSION=$(cat $BUILD_DIR/version) -export ISO_IMAGE=./build/live-image-amd64.hybrid.iso +export ISO_IMAGE=./build/live-image-$BUILD_ARCH.hybrid.iso export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') export PACKER_BUILD_DIR=packer_build export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build.log diff --git a/scripts/copy-image b/scripts/copy-image new file mode 100755 index 00000000..01af511d --- /dev/null +++ b/scripts/copy-image @@ -0,0 +1,7 @@ +#!/bin/sh + +BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) +VERSION=$(cat $BUILD_DIR/version) + +ln -nsf $BUILD_DIR/live-image-$BUILD_ARCH.hybrid.iso $BUILD_DIR/vyos-$VERSION-$BUILD_ARCH.iso -- cgit v1.2.3 From bff1f61f47f228fbd8eae18586667779ccb27a31 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Fri, 28 Jul 2017 23:17:42 +0900 Subject: Add script for building Vagrant libvirt box --- scripts/Vagrantfile | 12 ++++++++++++ scripts/build-qemu-image | 2 +- scripts/build-vmware-image | 4 ++-- scripts/packer.json | 27 +++++++++++++++++++++++++-- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 scripts/Vagrantfile (limited to 'scripts/build-qemu-image') diff --git a/scripts/Vagrantfile b/scripts/Vagrantfile new file mode 100644 index 00000000..7c89422d --- /dev/null +++ b/scripts/Vagrantfile @@ -0,0 +1,12 @@ +Vagrant.configure("2") do |config| + config.vm.synced_folder './', '/vagrant', + type: "rsync", + owner: 'vyos', + group: 'users', + mount_options: ['dmode=775,fmode=775'] + config.ssh.username = "vyos" + config.ssh.password = "vyos" + config.vm.provider :libvirt do |libvirt| + libvirt.driver = "kvm" + end +end diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image index 59a42f07..29cb6cf1 100755 --- a/scripts/build-qemu-image +++ b/scripts/build-qemu-image @@ -20,7 +20,7 @@ BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) -VERSION=$(cat $BUILD_DIR/version) +export VERSION=$(cat $BUILD_DIR/version) export ISO_IMAGE=./build/live-image-$BUILD_ARCH.hybrid.iso export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') diff --git a/scripts/build-vmware-image b/scripts/build-vmware-image index e665e0b5..1730d7a3 100755 --- a/scripts/build-vmware-image +++ b/scripts/build-vmware-image @@ -37,12 +37,12 @@ export PACKER_BUILD_DIR=packer_build DST_DIR=${PACKER_BUILD_DIR}/vmware mkdir -p ${DST_DIR} -# Convert raw image to VMDK +# Convert qcow2 image to VMDK source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img tmp_vmdk=${DST_DIR}/tmp.vmdk vmdk=${DST_DIR}/vyos_vmware_image.vmdk ovf=${DST_DIR}/vyos_vmware_image.ovf -qemu-img convert -f raw ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +qemu-img convert -f qcow2 ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} vmdk-convert ${tmp_vmdk} ${vmdk} # Generate OVF diff --git a/scripts/packer.json b/scripts/packer.json index 83df10c5..39ab423b 100644 --- a/scripts/packer.json +++ b/scripts/packer.json @@ -2,7 +2,11 @@ "variables": { "iso_url": "{{env `ISO_IMAGE`}}", "iso_checksum": "{{env `ISO_MD5_SUM`}}", - "output_directory": "{{env `PACKER_BUILD_DIR`}}" + "output_directory": "{{env `PACKER_BUILD_DIR`}}", + "box_tag": "{{env `VAGRANT_BOX_NAME`}}", + "cloud_token": "{{env `VAGRANT_CLOUD_ACCESS_TOKEN`}}", + "version": "{{env `VERSION`}}", + "box_base_url": "{{env `BOX_BASE_URL`}}" }, "builders": [ @@ -15,7 +19,7 @@ "output_directory": "{{user `output_directory`}}/qemu", "shutdown_command": "sudo halt -p", "disk_size": 4096, - "format": "raw", + "format": "qcow2", "headless": true, "ssh_host_port_min": 2222, "ssh_host_port_max": 2229, @@ -90,5 +94,24 @@ "scripts/packer-scripts/vmware.sh" ] } + ], + "post-processors": [ + [ + { + "type": "vagrant", + "only": ["qemu-image"], + "vagrantfile_template": "scripts/Vagrantfile", + "output": "{{user `output_directory`}}/vagrant-libvirt/vyos_vagrant_libvirt.box", + "keep_input_artifact": "true" + }, + { + "type": "vagrant-cloud", + "only": ["qemu-image"], + "box_tag": "{{user `box_tag`}}", + "access_token": "{{user `cloud_token`}}", + "version": "{{user `version`}}", + "box_download_url": "{{user `box_base_url`}}/vyos-{{user `version`}}-vagrant-libvirt.box" + } + ] ] } -- cgit v1.2.3