Make setup_roborio.sh run under bazel run
Also cleaned up some of the ssh failure reasoning because even with
the (now added) set -Eeo pipefail, pipes won't fail inside an if
statement, meaning that the script wouldn't exit (as it should)
but would instead spam failed ssh commands.
Change-Id: Ibeb73887d7c96e637a491106399fd855c7677619
diff --git a/aos/config/BUILD b/aos/config/BUILD
new file mode 100644
index 0000000..07394d4
--- /dev/null
+++ b/aos/config/BUILD
@@ -0,0 +1,14 @@
+filegroup(
+ name = 'rio_robotCommand',
+ srcs = [ 'robotCommand' ],
+)
+
+sh_binary(
+ name = 'setup_roborio',
+ srcs = [ 'setup_roborio.sh' ],
+ visibility = [ '//visibility:public' ],
+ data = [
+ ':rio_robotCommand',
+ '@arm_frc_linux_gnueabi_repo//:compiler_pieces',
+ ],
+)
diff --git a/setup_roborio.sh b/aos/config/setup_roborio.sh
similarity index 61%
rename from setup_roborio.sh
rename to aos/config/setup_roborio.sh
index 833dac6..8b8bae7 100755
--- a/setup_roborio.sh
+++ b/aos/config/setup_roborio.sh
@@ -1,8 +1,5 @@
#!/bin/bash
-cd $(dirname $0)
-pwd
-
-set -e
+set -Eeuo pipefail
if [ $# != 1 ];
then
@@ -12,11 +9,14 @@
readonly ROBOT_HOSTNAME="$1"
-bazel build -c opt @arm_frc_linux_gnueabi_repo//...
-
echo "Looking to see if l is aliased right."
-if $(ssh "admin@${ROBOT_HOSTNAME}" "cat /etc/profile" | grep -Fq "alias l");
-then
+
+readonly HAS_ALIAS=$(ssh "admin@${ROBOT_HOSTNAME}" "cat /etc/profile" | grep -Fq "alias l")
+
+if [[ $? -ne 0 ]]; then
+ echo "ssh command failed remotely"
+ exit 1
+elif $HAS_ALIAS
echo "Already has l alias"
else
echo "Adding l alias"
@@ -28,4 +28,4 @@
echo "Deploying robotCommand startup script"
scp aos/config/robotCommand "admin@${ROBOT_HOSTNAME}:/home/lvuser/"
-scp bazel-971-Robot-Code/external/arm_frc_linux_gnueabi_repo/usr/arm-frc-linux-gnueabi/lib/libstdc++.so.6.0.21 "admin@${ROBOT_HOSTNAME}:/usr/lib/"
+scp external/arm_frc_linux_gnueabi_repo/usr/arm-frc-linux-gnueabi/lib/libstdc++.so.6.0.21 "admin@${ROBOT_HOSTNAME}:/usr/lib/"