Thomas Vachuska | 21112ad | 2018-08-06 14:28:10 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Tool to perform a cell-based remote bazel build using a borrowed test cell. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | # Check environment |
| 7 | [ -z "$OCN" ] && echo "Cell environment not established" && exit 1 |
| 8 | |
| 9 | # Check arguments and environment |
| 10 | baseCommit=${1:-$(git log | grep origin/master | head -n1 | cut -d\ -f2)} |
| 11 | |
| 12 | # Create a patch file |
| 13 | git diff --cached --staged --binary $baseCommit > /tmp/$baseCommit.patch |
| 14 | |
| 15 | # Copy patch file to the remote build machine |
| 16 | scp /tmp/$baseCommit.patch $ONOS_USER@$OCN:/tmp |
| 17 | |
| 18 | ssh -t -t $ONOS_USER@$OCN " |
| 19 | source ~/.bash_aliases |
| 20 | cd \$ONOS_ROOT |
| 21 | |
| 22 | # Make sure the remote build machine is on the same commit hash as the local one |
| 23 | remoteCommit=\$(git log -n 1 | head -n1 | cut -d\ -f2) |
| 24 | |
| 25 | if [ "\$remoteCommit" != "$baseCommit" ]; then |
| 26 | git checkout master |
| 27 | git pull |
| 28 | git checkout $baseCommit |
| 29 | fi |
| 30 | |
| 31 | # Apply the patch |
| 32 | git clean -f |
| 33 | git stash |
| 34 | git apply --no-add /tmp/$baseCommit.patch |
| 35 | |
| 36 | # Run the build |
| 37 | SHLVL=1 bazel build onos |
| 38 | " |