From 0e5a6a38bc46171d022e1ac3668213841ef8a33c Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Fri, 5 Nov 2021 11:15:17 +0100 Subject: [PATCH] scripts/vagrant: Add option to specify box version From the CI perspective, this allows for proper binding of given VM builds to specific tasks (e.g. use this image for LTS, this one for release, etc.) since by default vagrant always uses the "latest" version of given box. Signed-off-by: Michal Berger Change-Id: I0cbd2a47e7dbdcbe83d18e3fc3100fd2a2400983 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10132 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Krzysztof Karas Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- scripts/vagrant/Vagrantfile | 3 +++ scripts/vagrant/create_vbox.sh | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 6c4424344..ea1fc0ba6 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -306,6 +306,9 @@ Vagrant.configure(2) do |config| config.vm.box = distro_to_use config.vm.box_check_update = false config.vm.synced_folder '.', '/vagrant', disabled: true + if ENV['VAGRANT_BOX_VERSION'] + config.vm.box_version = ENV['VAGRANT_BOX_VERSION'] + end # Copy in the .gitconfig if it exists copy_gitconfig(config) diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index e7f478123..f8e1cde36 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -49,6 +49,7 @@ display_help() { echo " -h help" echo " -v verbose" echo " -f Force use of given distro, regardless if it's supported by the script or not." + echo " --box-version Version of the vagrant box to select for given distro." echo " Examples:" echo echo " $0 -x http://user:password@host:port fedora33" @@ -87,6 +88,7 @@ VAGRANT_PACKAGE_BOX=0 VAGRANT_HUGE_MEM=0 VAGRANTFILE=$DIR/Vagrantfile FORCE_DISTRO=false +VAGRANT_BOX_VERSION="" while getopts ":b:n:s:x:p:uvcraldoHhf-:" opt; do case "${opt}" in @@ -96,6 +98,7 @@ while getopts ":b:n:s:x:p:uvcraldoHhf-:" opt; do qemu-emulator=*) SPDK_QEMU_EMULATOR="${OPTARG#*=}" ;; vagrantfiles-dir=*) VAGRANTFILE_DIR="${OPTARG#*=}" ;; vagrantfile=*) [[ -n ${OPTARG#*=} ]] && VAGRANTFILE="${OPTARG#*=}" ;; + box-version=*) [[ -n ${OPTARG#*=} ]] && VAGRANT_BOX_VERSION="${OPTARG#*=}" ;; *) echo "Invalid argument '$OPTARG'" ;; esac ;; @@ -231,6 +234,7 @@ if [ ${VERBOSE} = 1 ]; then echo VAGRANT_PACKAGE_BOX=$VAGRANT_PACKAGE_BOX echo VAGRANTFILE=$VAGRANTFILE echo FORCE_DISTRO=$FORCE_DISTRO + echo VAGRANT_BOX_VERSION=$VAGRANT_BOX_VERSION echo fi @@ -250,6 +254,7 @@ export NVME_FILE export VAGRANT_PASSWORD_AUTH export VAGRANT_HUGE_MEM export FORCE_DISTRO +export VAGRANT_BOX_VERSION if [ -n "$SPDK_VAGRANT_PROVIDER" ]; then provider="--provider=${SPDK_VAGRANT_PROVIDER}" @@ -279,6 +284,7 @@ if [ ${DRY_RUN} = 1 ]; then printenv VAGRANT_HUGE_MEM printenv VAGRANTFILE printenv FORCE_DISTRO + printenv VAGRANT_BOX_VERSION fi if [ -z "$VAGRANTFILE_DIR" ]; then VAGRANTFILE_DIR="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}"