From 344c318464d32ec173c1a6a4ba32732f3d0c00a3 Mon Sep 17 00:00:00 2001 From: Maciej Wawryk Date: Thu, 13 Feb 2020 08:07:21 +0100 Subject: [PATCH] scripts/vagrant: Create prebuild box and allow using spdk boxes Build local vagrant box and add it to local vagrant box list. Check if spdk box exist and use it instead of generic boxes. Signed-off-by: Maciej Wawryk Change-Id: Ib3b87c9783354680657f96b5b5adea1706712c5e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/848 Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Tomasz Zawadzki Reviewed-by: Paul Luse Reviewed-by: Jim Harris --- scripts/vagrant/Vagrantfile | 11 ++++++++++- scripts/vagrant/create_vbox.sh | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 72b9afd60..84878dfee 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -1,12 +1,21 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +require 'open3' def checkboxtype(distro) + localboxes, stderr, status = Open3.capture3("vagrant box list") + if localboxes.include? "spdk/"+distro + return "spdk/"+distro + else + return "generic/"+distro + end +end + Vagrant.configure(2) do |config| # Pick the right distro and bootstrap, default is fedora30 distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "fedora30") provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox") - config.vm.box = "generic/"+distro + config.vm.box = checkboxtype(distro) config.vm.box_check_update = false # Copy in the .gitconfig if it exists diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 9d7b8c032..a7d369775 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -320,6 +320,9 @@ EOF vagrant ssh -c 'sudo pkg clean -ay' fi vagrant ssh -c 'cat /dev/null > ~/.bash_history && history -c' + vagrant package --output spdk_${SPDK_VAGRANT_DISTRO}.box + vagrant box add spdk/${SPDK_VAGRANT_DISTRO} spdk_${SPDK_VAGRANT_DISTRO}.box && + rm spdk_${SPDK_VAGRANT_DISTRO}.box fi echo "" echo " SUCCESS!"