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 <michalx.berger@intel.com>
Change-Id: I0cbd2a47e7dbdcbe83d18e3fc3100fd2a2400983
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10132
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Michal Berger 2021-11-05 11:15:17 +01:00 committed by Jim Harris
parent 264e0a0a2b
commit 182adb70a7
2 changed files with 9 additions and 0 deletions

View File

@ -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)

View File

@ -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}"