@@ -0,0 +1,82 @@
1+#!/bin/sh
2+
3+# Spin up an ARM build machine using aws cli, build pandoc, and
4+# download the artifact.
5+#
6+# We need to use us-east-2; since my us-west-1 has EC2-classic.
7+# docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-classic-platform.html
8+
9+aws configure set default.region us-east-2
10+
11+# Now start instance with volume 16GB.
12+# note, the AMI id is different for different regions.
13+# for us east-2 the Debian Buster ARM AMI is ami-0fa8979d18f69948b:
14+
15+echo "Creating instance..."
16+
17+aws ec2 run-instances --image-id ami-0fa8979d18f69948b --count 1 --instance-type t4g.2xlarge --block-device-mapping 'DeviceName=/dev/xvda,Ebs={VolumeSize=16}' --key-name debian-arm-us-east-2 --security-group-ids sg-086ffbadc286c5c00 > ec2.json
18+
19+# Now get the public IP address.
20+
21+INSTANCEID=$(jq '.Instances[0].InstanceId' ec2.json | sed -e 's/"//g')
22+IPADDR=$(aws ec2 describe-instances --instance-ids="$INSTANCEID" --query 'Reservations[0].Instances[0].PublicIpAddress' | sed -e 's/"//g')
23+
24+clean_up() {
25+ echo "Terminating the instance..."
26+ aws ec2 terminate-instances --instance-ids "$INSTANCEID"
27+}
28+trap clean_up EXIT
29+
30+echo "Waiting for instance to start up..."
31+
32+STATUS=none
33+while [ "$STATUS" != "running" ]
34+do
35+ sleep 20
36+ STATUS=$(aws ec2 describe-instance-status --instance-id "$INSTANCEID" | jq '.InstanceStatuses[0].InstanceState.Name' | sed -e 's/"//g')
37+ echo "...$STATUS"
38+done
39+
40+# At this point you can connect via SSH, or run this script:
41+# $ ssh -i ~/.ssh/debian-arm-us-east-2.pem admin@$IPADDR
42+
43+SSH="ssh -i ~/.ssh/debian-arm-us-east-2.pem admin@$IPADDR"
44+
45+echo "Provisioning..."
46+
47+$SSH <<EOF
48+sudo apt-get update
49+sudo apt-get upgrade -y
50+sudo apt-get install -y apt-transport-https ca-certificates curl gnupg git make
51+curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
52+echo \
53+ "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
54+ \$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
55+sudo apt-get update
56+sudo apt-get install -y docker-ce docker-ce-cli containerd.io
57+sudo groupadd docker
58+sudo usermod -aG docker admin
59+EOF
60+
61+echo "Building..."
62+
63+($SSH <<EOF
64+mkdir src
65+cd src || exit
66+git clone https://github.com/jgm/pandoc
67+cd pandoc || exit
68+make debpkg
69+EOF
70+) &
71+
72+# Now we need to wait for the build to complete (this can take 3 hours).
73+
74+while true
75+do
76+ sleep 60
77+ $SSH "tail -n1 src/pandoc/docker.log && free -h"
78+ # Check to see if the artifact has been produced
79+ $SSH "ls -l linux/artifacts/*.tar.gz" && break
80+done
81+
82+