#!/bin/bash DIR_PRJ="$1" DIR_ELY="ely" DIR_LUIS="luis" DIR_TEST="leaDvt" DIR_TOOLS="leaTls" DIR_CLOUD="leaCld" ERROR_HOME_EMPTY=1 ERROR_WORKSPACE_REJECTED=2 ERROR_WORKSPACE_MD=3 ERROR_WORKSPACE_CD=4 OK=N toUpper() { echo $(echo "$1" | tr '[:lower:]' '[:upper:]') } # clone with submodules ## IMPORTANT: Not using for now. function module() { if [[ "$1" == "" ]]; then return; fi if [[ "$2" == "" ]]; then return; fi if [[ "$3" == "" ]]; then return; fi REPO=$1 FLDR=$2 LNLOC=$3 LNSRC=$FLDR echo "<<<<< Adding module $LNSRC in $LNLOC started" cd $LNLOC git submodule add git@bitbucket.org:diality-cloud/$REPO.git $FLDR git submodule update --init --recursive echo ">>>>> Adding module $LNSRC in $LNLOC done" echo cd .. } # clones the given repo in the given folder function clone () { REPO=$1 FLDR=$2 echo "<<<<< clonning $REPO in $PWD/$FLDR started" git clone git@bitbucket.org:diality-cloud/$REPO.git $FLDR echo ">>>>> clonning $REPO in $PWD/$FLDR done" echo if [[ "$3" == "" ]]; then return; fi LNLOC=$3 LNSRC=$FLDR echo " <<<<< creating symlink of $LNSRC in $LNLOC started" if [[ "$4" != "" ]]; then LNSRC="$4" fi cd $LNLOC ln -s ../$LNSRC $FLDR cd .. echo " >>>>> creating symlink of $LNSRC in $LNLOC done" } # clone Embedded Leahi Yocto function cloneEly() { mkdir $DIR_ELY cd $DIR_ELY echo "----- cloning the Embedded Leahi Yocto (ELY) repositories" clone leahi-distro-manifest manifest clone leahi-distro-layer layer clone leahi-distro-image images clone leahi-distro-manufact manufact cd .. } # clone Leahi User Interface SubSystem function cloneLuis() { mkdir $DIR_LUIS cd $DIR_LUIS echo "----- cloning the Leahi User Interface SubSystem (Luis) repositories" clone leahi-application application clone leahi-common common application clone leahi-sw.config config application clone leahi-sw.scripts scripts application clone leahi-sw.resources ressources application clone leahi-sw.plugins.app plugins application cd .. } # clone Leahi test function cloneLeaDvt() { mkdir $DIR_TEST cd $DIR_TEST clone leahi-simulator simulator clone leahi-sw.plugins.sim plugins simulator clone leahi-dialin dialin simulator dialin/dialin clone leahi-testsuites testsuites clone leahi-unittests unittests cd .. } # clone Leahi utility function cloneLeaTls() { mkdir $DIR_TOOLS cd $DIR_TOOLS clone leahi-scripts scripts clone alarmmapping alarmmapping cd .. } # clone Leahi cloud function cloneLeaCld() { mkdir $DIR_CLOUD cd $DIR_CLOUD clone leahi-cloudsync cloudsync clone leahi-drtserver drtserver cd .. } function checkParams() { if [ "$HOME" = "" ]; then echo "ERROR_HOME_EMPTY" exit $ERROR_HOME_EMPTY fi if [ "$DIR_PRJ" = "" ]; then DIR_PRJ="$PWD" fi } function workspace() { WKS=$DIR_PRJ mkdir -p $WKS; if (( $? )); then echo "ERROR_WORKSPACE_MD"; exit $ERROR_WORKSPACE_MD; fi cd $WKS; if (( $? )); then echo "ERROR_WORKSPACE_CD"; exit $ERROR_WORKSPACE_CD; fi } function confirm() { echo "All the required Leahi repositories will be cloned in the following given folder:" echo $DIR_PRJ read -p "Are you sure? " -n 1 OK echo "" if [ "$(toUpper $OK)" != "Y" ]; then echo "ERROR_WORKSPACE_REJECTED" exit $ERROR_WORKSPACE_REJECTED fi } checkParams confirm workspace cloneEly cloneLuis cloneLeaDvt cloneLeaTls cloneLeaCld