#!/bin/bash

if [ "$1" == "--push" ]; then
  yujin_rsync_installspace --push
  exit 0
fi

if [ $# -gt 0 ]; then
  echo ""
  echo "This builds and installs the groot workspace into /opt/yujin/indigo."
  echo ""
  echo "    Options:"
  echo "        --pre-clean : pre-cleans with yujin_make each source workspace"
  echo "        --push      : do not build, just rsync to the file server"
  echo ""
  echo "    Current workspaces:"
  echo "        ecto"
  echo "        ecl"
  echo "        navi"
  echo "        dslam"
  echo "        gopher"
  echo ""
  exit 0
fi


OPTIONS=
if [ "$1" == "--pre-clean" ]; then
  OPTIONS=--pre-clean
fi

GROOT=/opt/groot
REPOS=(ecto ecl navi dslam gopher)
#rm -rf /opt/yujin/indigo 
for ws in "${REPOS[@]}"; do
  WS_ROOT=${GROOT}/${ws}_ws
  WS_SRC=${WS_ROOT}/src
  cd ${WS_SRC}
  wstool update -j5
  cd ${WS_ROOT}
  yujin_make ${OPTIONS}
  yujin_make --install
done


