3 # Runtime provisioning script for Vagrant-based training lab setup
5 # runtime type - arm32 (default) or arm64
7 if [ "$RUNTIME"x = ""x ]; then
11 # Location of the runtime files. MANIFEST must exist there, and
12 # describes what else needs to be downloaded: in the format:
13 # <FILENAME>:<MODE>:<BYTES>:<SHA256>
14 # Apart from the MANIFEST itself, all files should be compressed with
15 # gzip. In each case, the script will download $FILENAME.gz,
16 # decompress it and then validate the checksum
17 RUNTIME_DL=https://www.einval.com/arm/training-lab/$RUNTIME/
23 # Make sure we have updates applied, and all our needed packages. Kill
24 # inattended-upgrades if it's running, as it will clash here
25 killall unattended-upgrade unattended-upgrades
27 apt-get dist-upgrade -y
28 apt-get install -y qemu-system-arm gcc-aarch64-linux-gnu
29 echo "Toolchain VM running!"
31 # Now grab the emulated runtime and start that
33 if [ ! -d runtime ]; then
38 echo "Checking / downloading files needed for the emulated runtime VM"
39 # Grab all the files we need, and check they're valid
40 echo " Downloading MANIFEST"
41 wget -nv -O MANIFEST $RUNTIME_DL/MANIFEST
42 for LINE in $(cat MANIFEST); do
43 FILENAME=$(echo $LINE | awk -F: '{print $1}')
44 MODE=$(echo $LINE | awk -F: '{print $2}')
45 BYTES=$(echo $LINE | awk -F: '{print $3}')
46 SHA=$(echo $LINE | awk -F: '{print $4}')
49 # Quick and dirty - if the file exists and is the right size,
51 echo " Checking $FILENAME.gz"
52 if [ -f $FILENAME ]; then
53 SIZE=$(stat -c%s $FILENAME)
54 if [ $SIZE = $BYTES ]; then
59 if [ $DL_NEEDED = 1 ]; then
60 # Grab a compressed version of the file, and extract it as we
62 echo " Downloading $FILENAME.gz"
63 wget -nv -O- $RUNTIME_DL/$FILENAME.gz | gzip -cd > $FILENAME
64 SHA_FILE=$(sha256sum $FILENAME | awk '{print $1}')
65 if [ $SHA_FILE != $SHA ]; then
66 echo "Failed to download $FILENAME.gz correctly. Abort"
73 echo "Starting emulated runtime VM next"
74 MACH=$RUNTIME ./start_runtime