diff --git a/script/README.md b/script/README.md index c296e7d..e8845ca 100644 --- a/script/README.md +++ b/script/README.md @@ -62,3 +62,9 @@ Delete all packages in the workspace. Use catkin to build the workspace. ### usage 1. ```CATKIN_MAKE_SARA``` + +# Using ssh +To use ssh instead of https, you need to set SARA_FORCE_SSH=true. +To make this permanent, add this line to your .bashrc: +```SARA_FORCE_SSH=true``` +Note that when forcing ssh, the .rosinstall file will still show https but ssh will be used nevertheless. diff --git a/script/_switch_https_ssh.sh b/script/_switch_https_ssh.sh new file mode 100644 index 0000000..b2c49f3 --- /dev/null +++ b/script/_switch_https_ssh.sh @@ -0,0 +1,13 @@ +#!/bin/bash +while getopts "sh" arg; do + case $arg in + s) + # Switch to ssh + sed "s/https:\/\/github\.com\/walkingmachine/git@github\.com\:WalkingMachine/g" src/.rosinstall > /tmp/sara_install && mv /tmp/sara_install src/.rosinstall + ;; + h) + # Switch to https + sed "s/git@github\.com\:WalkingMachine/https:\/\/github\.com\/walkingmachine/g" src/.rosinstall > /tmp/sara_install && mv /tmp/sara_install src/.rosinstall + ;; + esac +done diff --git a/script/install.sh b/script/install.sh index facbcf4..7784b2d 100644 --- a/script/install.sh +++ b/script/install.sh @@ -51,6 +51,16 @@ source "$WSDIR/script/setup.sh" # Move to the workspace cd "$WSDIR" + +###################################### +## Set to ssh if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + echo "SARA_FORCE_SSH is true. Forcing ssh mode." + bash -c "source script/_switch_https_ssh.sh -s" +fi + + ###################################### ## Remove extra repos @@ -80,6 +90,15 @@ set +v ###################################### ## End + +###################################### +## Set back to https if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + bash -c "source script/_switch_https_ssh.sh -h" +fi + + # Get the right setup for the shell source $WSDIR/devel/setup.$SHELL_EXTENSION # Move back to the original position diff --git a/script/scrape_config.sh b/script/scrape_config.sh index de8f53b..06343bd 100644 --- a/script/scrape_config.sh +++ b/script/scrape_config.sh @@ -50,6 +50,15 @@ fi cd "$WSDIR" +###################################### +## Set to ssh if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + echo "SARA_FORCE_SSH is true. Forcing ssh mode." + bash -c "source script/_switch_https_ssh.sh -s" +fi + + ###################################### ## Scrape all packages using wstool and some gawk magics. @@ -65,9 +74,9 @@ echo "By Branch:" wstool info -t src --data-only | sed -r 's/\ [XLVCM][XLVCM]?\ /\ /' | sed 's/([^(]*)/\ /'g | tac > /tmp/sara_install_ws gawk 'BEGIN { FS = " " } ; $2=="git" {print "- "$2":\n\ local-name: "$1"\n\ - uri: https://"$5"\n\ - version: "$3}' /tmp/sara_install_ws > src/.rosinstall - + uri: "$5"\n\ + version: "$3}' /tmp/sara_install_ws > /tmp/sara_install_ws2 + sed "s/github.com\//https:\/\/github.com\//g" /tmp/sara_install_ws2 > src/.rosinstall echo "here is a summary of all packages in src:" gawk 'BEGIN { FS = " " } ; $2=="git" {print " - "$1" "$3""}' /tmp/sara_install_ws | column -t else @@ -75,9 +84,9 @@ echo "By commit:" wstool info -t src --only=scmtype,localname,revision,uri | tr , \ | tac > /tmp/sara_install_ws gawk '$2=="git" {print "- "$1":\n\ local-name: "$2"\n\ - uri: https://"$4"\n\ - version: "$3}' /tmp/sara_install_ws > src/.rosinstall - + uri: "$4"\n\ + version: "$3}' /tmp/sara_install_ws > /tmp/sara_install_ws2 + sed "s/github.com\//https:\/\/github.com\//g" /tmp/sara_install_ws2 > src/.rosinstall echo "here is a summary of all packages in src:" gawk '$2=="git" {print " - "$2" ("$3")"}' /tmp/sara_install_ws @@ -86,6 +95,14 @@ fi #rm /tmp/sara_install_ws +###################################### +## Set back to https if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + bash -c "source script/_switch_https_ssh.sh -h" +fi + + ###################################### ## End diff --git a/script/status.sh b/script/status.sh index 38b559f..d7e6482 100644 --- a/script/status.sh +++ b/script/status.sh @@ -48,6 +48,16 @@ source "$WSDIR/script/setup.sh" # Move to the workspace cd "$WSDIR" + +###################################### +## Set to ssh if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + echo "SARA_FORCE_SSH is true. Forcing ssh mode." + bash -c "source script/_switch_https_ssh.sh -s" +fi + + ###################################### ## Status report @@ -73,6 +83,15 @@ echo "*" echo -e "*****************************************\n\n" ###################################### + +###################################### +## Set back to https if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + bash -c "source script/_switch_https_ssh.sh -h" +fi + + ## End # Move back to the original position diff --git a/script/update.sh b/script/update.sh index f1a457d..7bf0ed7 100644 --- a/script/update.sh +++ b/script/update.sh @@ -52,6 +52,15 @@ source "$WSDIR/script/setup.sh" cd "$WSDIR" +###################################### +## Set to ssh if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + echo "SARA_FORCE_SSH is true. Forcing ssh mode." + bash -c "source script/_switch_https_ssh.sh -s" +fi + + ###################################### ## Update all packages @@ -68,6 +77,17 @@ set +v ###################################### ## End + + +###################################### +## Set back to https if needed +if [[ $SARA_FORCE_SSH == "true" ]] +then + bash -c "source script/_switch_https_ssh.sh -h" +fi + + + # Get the right setup for the shell source $WSDIR/devel/setup.$SHELL_EXTENSION # Move back to the original position