Generalized remote build script.

This commit is contained in:
Ariel Antonitis 2021-03-24 18:17:27 -04:00
parent 6df5a71b0d
commit 5d18500a74

View file

@ -1,10 +1,15 @@
#!/bin/bash
# Rsync repo to build machine; build and scp the ROM back
# Push to SSH machine; build and scp build products back
set +v
set -e
git_branch=$(git branch --show-current)
git push build --force # ssh://merrbot:/home/ubuntu/pokeemerald
ssh merrbot "cd pokeemerald && git reset --hard && git checkout $git_branch && make"
scp merrbot:pokeemerald/pokeemerald.gba romhack.gba
# See https://unix.stackexchange.com/a/13472
remote_host=$(git remote get-url build | sed -nr -e "s/ssh:\/\/(\w+@?\w*):.*/\1/p") # Extract remote host
remote_path=$(git remote get-url build | sed -nr -e "s/ssh:\/\/\w+@?\w*://p") # Extract remote path
set -x
git push build --force
# `nproc` must be escaped so that it executes on the remote machine
ssh $remote_host "cd $remote_path && git reset --hard && git checkout $git_branch && \
echo \"Using \`nproc\` job(s)\" && make -j\`nproc\`"
scp "$remote_host:$remote_path/pokeemerald.gba" romhack.gba