--- /dev/null
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# All Vagrant configuration is done below. The "2" in Vagrant.configure
+# configures the configuration version (we support older styles for
+# backwards compatibility). Please don't change it unless you know what
+# you're doing.
+Vagrant.configure("2") do |config|
+ # The most common configuration options are documented and commented below.
+ # For a complete reference, please see the online documentation at
+ # https://docs.vagrantup.com.
+
+ # Every Vagrant development environment requires a box. You can search for
+ # boxes at https://vagrantcloud.com/search.
+# config.vm.box = "debian/buster64"
+# config.vm.box = "ubuntu/focal64"
+ config.vm.box = "ubuntu/bionic64"
+
+ # Disable automatic box update checking. If you disable this, then
+ # boxes will only be checked for updates when the user runs
+ # `vagrant box outdated`. This is not recommended.
+ # config.vm.box_check_update = false
+
+ # Create a forwarded port mapping which allows access to a specific port
+ # within the machine from a port on the host machine. In the example below,
+ # accessing "localhost:8080" will access port 80 on the guest machine.
+ # NOTE: This will enable public access to the opened port
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
+
+ # Create a forwarded port mapping which allows access to a specific port
+ # within the machine from a port on the host machine and only allow access
+ # via 127.0.0.1 to disable public access
+ config.vm.network "forwarded_port", guest: 2222, host: 2223, host_ip: "127.0.0.1"
+
+ # Create a private network, which allows host-only access to the machine
+ # using a specific IP.
+ # config.vm.network "private_network", ip: "192.168.33.10"
+
+ # Create a public network, which generally matched to bridged network.
+ # Bridged networks make the machine appear as another physical device on
+ # your network.
+ # config.vm.network "public_network"
+
+ # Share an additional folder to the guest VM. The first argument is
+ # the path on the host to the actual folder. The second argument is
+ # the path on the guest to mount the folder. And the optional third
+ # argument is a set of non-required options.
+ # config.vm.synced_folder "../data", "/vagrant_data"
+ config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
+
+ # Provider-specific configuration so you can fine-tune various
+ # backing providers for Vagrant. These expose provider-specific options.
+ # Example for VirtualBox:
+ #
+ config.vm.provider "virtualbox" do |vb|
+ # # Display the VirtualBox GUI when booting the machine
+ # vb.gui = true
+ #
+ # # Customize the amount of memory on the VM:
+ vb.memory = "4096"
+ end
+ #
+ # View the documentation for the provider you are using for more
+ # information on available options.
+
+ # Enable provisioning with a shell script. Additional provisioners such as
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
+ # documentation for more information about their specific syntax and use.
+ config.vm.provision "shell", path: "bootstrap-toolchain-vm.sh", run: "always"
+end
--- /dev/null
+#!/bin/sh
+#
+# Runtime provisioning script for Vagrant-based training lab setup
+
+# Location of the runtime files. MANIFEST must exist there, and
+# describes what else needs to be downloaded: in the format:
+# <FILENAME>:<BYTES>:<SHA256>
+# Apart from the MANIFEST itself, all files should be compressed with
+# gzip. In each case, the script will download $FILENAME.gz,
+# decompress it and then validate the checksum
+RUNTIME_DL=http://www.einval.org/share/arm-security/
+
+# Abort on errors
+set -e
+# set -x
+
+# Make sure we have updates applied, and all our needed packages
+apt-get update
+apt-get dist-upgrade -y
+apt-get install -y qemu-system-arm gcc-aarch64-linux-gnu
+echo "Toolchain VM running!"
+
+# Now grab the emulated runtime and start that
+cd /vagrant
+if [ ! -d runtime ]; then
+ mkdir runtime
+fi
+cd runtime
+
+echo "Checking / downloading files needed for the emulated runtime VM"
+# Grab all the files we need, and check they're valid
+echo " Downloading MANIFEST"
+wget -nv -O MANIFEST $RUNTIME_DL/MANIFEST
+for LINE in $(cat MANIFEST); do
+ FILENAME=$(echo $LINE | awk -F: '{print $1}')
+ MODE=$(echo $LINE | awk -F: '{print $2}')
+ BYTES=$(echo $LINE | awk -F: '{print $3}')
+ SHA=$(echo $LINE | awk -F: '{print $4}')
+ DL_NEEDED=1
+
+ # Quick and dirty - if the file exists and is the right size,
+ # we'll believe it
+ echo " Checking $FILENAME.gz"
+ if [ -f $FILENAME ]; then
+ SIZE=$(stat -c%s $FILENAME)
+ if [ $SIZE = $BYTES ]; then
+ DL_NEEDED=0
+ fi
+ fi
+
+ if [ $DL_NEEDED = 1 ]; then
+ # Grab a compressed version of the file, and extract it as we
+ # go
+ echo " Downloading $FILENAME.gz"
+ wget -nv -O- $RUNTIME_DL/$FILENAME.gz | gzip -cd > $FILENAME
+ SHA_FILE=$(sha256sum $FILENAME | awk '{print $1}')
+ if [ $SHA_FILE != $SHA ]; then
+ echo "Failed to download $FILENAME.gz correctly. Abort"
+ exit 1
+ fi
+ fi
+ chmod $MODE $FILENAME
+done
+
+echo "Starting emulated runtime VM next"
+#./start_runtime