Skip to main content

max / mountaineer

1.6 KB · 51 lines History Blame Raw
1 #!/bin/sh
2 # vm-build.sh — rsync the Mountaineer-build repo into the builder VM,
3 # run ./build.sh inside it, copy artifacts back out to ./out/.
4 #
5 # Assumes the builder VM is running (./tools/qemu/vm-up.sh).
6
7 . "$(dirname "$0")/common.sh"
8
9 BUILDER_KEY="$KEYS_DIR/builder_ed25519"
10 REMOTE_PATH="${REMOTE_PATH:-/home/build/mountaineer-build}"
11
12 SSH_OPTS="-p $BUILDER_SSH_PORT \
13 -i $BUILDER_KEY \
14 -o StrictHostKeyChecking=accept-new \
15 -o UserKnownHostsFile=$VMS/known_hosts \
16 -o LogLevel=ERROR"
17
18 if [ ! -f "$BUILDER_KEY" ]; then
19 echo "error: builder ssh key not found at $BUILDER_KEY" >&2
20 echo " run tools/qemu/vm-up.sh first" >&2
21 exit 1
22 fi
23
24 # Sanity: is the VM reachable?
25 # shellcheck disable=SC2086
26 if ! ssh $SSH_OPTS -o ConnectTimeout=3 -o BatchMode=yes build@127.0.0.1 true 2>/dev/null; then
27 echo "error: cannot reach builder VM at 127.0.0.1:$BUILDER_SSH_PORT" >&2
28 echo " start it with: tools/qemu/vm-up.sh" >&2
29 exit 1
30 fi
31
32 echo "==> syncing repo into builder VM at $REMOTE_PATH"
33 # shellcheck disable=SC2086
34 rsync -az --delete \
35 --exclude '.vms/' --exclude '.aports/' --exclude 'out/' --exclude '.work/' \
36 -e "ssh $SSH_OPTS" \
37 "$ROOT/" "build@127.0.0.1:$REMOTE_PATH/"
38
39 echo "==> running ./build.sh inside builder VM"
40 # shellcheck disable=SC2086
41 ssh $SSH_OPTS build@127.0.0.1 "cd $REMOTE_PATH && ./build.sh"
42
43 echo "==> copying artifacts back from builder VM"
44 mkdir -p "$ROOT/out"
45 # shellcheck disable=SC2086
46 rsync -az -e "ssh $SSH_OPTS" \
47 "build@127.0.0.1:$REMOTE_PATH/out/" "$ROOT/out/"
48
49 echo "==> done. artifacts:"
50 ls -lh "$ROOT/out/"
51