From 83e8207766bf34933a7401d0c54274a3de5c63fe Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Fri, 26 Apr 2024 15:01:29 +0200 Subject: [PATCH] [ros2] update env vars --- ros2/install.bash | 16 +++++++++------- ros2/setup | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ros2/install.bash b/ros2/install.bash index 64222e0c7..d845bc280 100644 --- a/ros2/install.bash +++ b/ros2/install.bash @@ -1,20 +1,22 @@ #! /usr/bin/env bash # shellcheck disable=SC1090 -if [ -z "$TUE_ROS_DISTRO" ] +[[ -v TUE_ENV_ROS_DISTRO || -v TUE_ROS_DISTRO ]] || { TUE_ENV_ROS_DISTRO=${TUE_ROS_DISTRO}; tue-install-warning "Change the config of your environment to use 'TUE_ENV_ROS_DISTRO' instead of 'TUE_ROS_DISTRO'"; } +if [[ -z "${TUE_ENV_ROS_DISTRO}" ]] then - tue-install-error "TUE_ROS_DISTRO was not set" + tue-install-error "TUE_ENV_ROS_DISTRO was not set" return 1 fi # Install basic ROS packages and eProsima DDS implementation. -tue-install-system-now ros-"$TUE_ROS_DISTRO"-ros-core ros-"$TUE_ROS_DISTRO"-rmw-fastrtps-cpp +tue-install-system-now ros-"${TUE_ENV_ROS_DISTRO}"-ros-core ros-"${TUE_ENV_ROS_DISTRO}"-rmw-fastrtps-cpp # Setup the build environment -mkdir -p "$TUE_SYSTEM_DIR" +mkdir -p "${TUE_ENV_WS_DIR}" -if [ ! -f "$TUE_SYSTEM_DIR"/install/setup.bash ] +if [ ! -f "$TUE_ENV_WS_DIR"/install/setup.bash ] then - [[ -z "${TUE_ROS_VERSION}" ]] && { tue-install-warning "tue-env variable TUE_ROS_VERSION is not set. This will not be allowed in the future.\nSetting TUE_ROS_VERSION=2 temporarily."; } - TUE_ROS_VERSION=2 tue-make || tue-install-error "Error in building the ROS2 system workspace" + [[ -v TUE_ENV_ROS_VERSION || -v TUE_ROS_VERSION ]] || { TUE_ENV_ROS_VERSION=${TUE_ROS_VERSION}; tue-install-warning "Change the config of your environment to use 'TUE_ENV_ROS_DISTRO' instead of 'TUE_ROS_DISTRO'"; } + [[ -z "${TUE_ENV_ROS_VERSION}" ]] && { tue-install-warning "tue-env variable TUE_ENV_ROS_VERSION is not set. This will not be allowed in the future.\nSetting TUE_ENV_ROS_VERSION=2 temporarily."; } + TUE_ENV_ROS_VERSION=2 tue-make || tue-install-error "Error in building the ROS2 system workspace" fi diff --git a/ros2/setup b/ros2/setup index ae813c877..7d5832e49 100644 --- a/ros2/setup +++ b/ros2/setup @@ -1,26 +1,27 @@ #! /usr/bin/env bash -if [ -z "$TUE_ROS_DISTRO" ] +[[ -v TUE_ENV_ROS_DISTRO || -v TUE_ROS_DISTRO ]] || { TUE_ENV_ROS_DISTRO=${TUE_ROS_DISTRO}; >&2 echo "Change the config of your environment to use 'TUE_ENV_ROS_DISTRO' instead of 'TUE_ROS_DISTRO'"; } +if [[ -z "${TUE_ENV_ROS_DISTRO}" ]] then - echo "[ros2] TUE_ROS_DISTRO was not set" + echo "[ros2] TUE_ENV_ROS_DISTRO was not set" return 1 fi # Add ROS sourcing to the shell startup script -if [ -f "/opt/ros/${TUE_ROS_DISTRO}/setup.bash" ] +if [[ -f "/opt/ros/${TUE_ENV_ROS_DISTRO}/setup.bash" ]] then # shellcheck disable=SC1090 - source "/opt/ros/${TUE_ROS_DISTRO}/setup.bash" + source "/opt/ros/${TUE_ENV_ROS_DISTRO}/setup.bash" else - echo -e "\033[33;1m[ros2] ROS 2 ${TUE_ROS_DISTRO} setup.bash not found. \033[0m" + echo -e "\033[33;1m[ros2] ROS 2 ${TUE_ENV_ROS_DISTRO} setup.bash not found. \033[0m" fi -if [ -f "${TUE_SYSTEM_DIR}/install/local_setup.bash" ] +if [[ -f "${TUE_ENV_WS_DIR}/install/local_setup.bash" ]] then # shellcheck disable=SC1091 - source "${TUE_SYSTEM_DIR}/install/local_setup.bash" + source "${TUE_ENV_WS_DIR}/install/local_setup.bash" else - echo -e "\033[33;1m[ros2] ${TUE_SYSTEM_DIR}/install/local_setup.bash not found. \033[0m" + echo -e "\033[33;1m[ros2] ${TUE_ENV_WS_DIR}/install/local_setup.bash not found. \033[0m" fi # Add Colcon sourcing to the shell startup script @@ -29,7 +30,7 @@ then # shellcheck disable=SC1091 source /usr/share/colcon_cd/function/colcon_cd.sh # shellcheck disable=SC2016 - export _colcon_cd_root="${TUE_SYSTEM_DIR}" + export _colcon_cd_root="${TUE_ENV_WS_DIR}" else echo -e "\033[33;5;1m[ros2] colcon_cd setup not found. colcon_cd command disabled. \033[0m" fi