From 7c3f930a8f169a4a1950cba16e11d8b97a15db95 Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Thu, 28 Mar 2019 23:24:30 +0100 Subject: [PATCH] Add ros prefix in dependency 'graph' --- installer/tue-install-impl.bash | 86 ++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/installer/tue-install-impl.bash b/installer/tue-install-impl.bash index 867aaa547..83a330eff 100755 --- a/installer/tue-install-impl.bash +++ b/installer/tue-install-impl.bash @@ -125,6 +125,27 @@ function tue-install-target-now return $? } +function _set_dependencies +{ + local parent_target=$1 + local target=$2 + + # If the target has a parent target, add target as a dependency to the parent target + if [ -n "$parent_target" ] && [ "$parent_target" != "main-loop" ] + then + + if [ "$parent_target" != "$target" ] + then + tue-install-debug "echo $target >> $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target" + tue-install-debug "echo $parent_target >> $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target" + echo "$target" >> "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" + echo "$parent_target" >> "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" + sort "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" -u -o "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" + sort "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" -u -o "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" + fi + fi +} + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # function tue-install-rosdep @@ -143,49 +164,51 @@ function tue-install-rosdep then tue-install-debug "Target '$target' has not yet been resolved by rosdep, going to installation procedure" - # Also make sure ros is installed - tue-install-target ros || tue-install-error "Failed to install target 'ROS'" - # Check if target can be resolved by rosdep tue-install-debug "rosdep resolve $target" rosdep_res=($(rosdep resolve $target 2>&1)) if [ $? -eq 0 ] then - tue-install-debug "rosdep correctly resolved to: ${rosdep_res[@]}" - - # If the target has a parent target, add target as a dependency to the parent target - if [ -n "$parent_target" ] - then - if [ "$parent_target" != "$target" ] - then - echo "$target" >> $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target - echo "$parent_target" >> $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target - sort $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target -u -o $TUE_INSTALL_DEPENDENCIES_DIR/$parent_target - sort $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target -u -o $TUE_INSTALL_DEPENDENCIES_ON_DIR/$target - fi - fi + tue-install-debug "rosdep correctly resolved to: ${rosdep_res[*]}" case ${rosdep_res[0]} in "#apt") tue-install-system ${rosdep_res[1]} ;; "#pip") tue-install-pip ${rosdep_res[1]} ;; - *) tue-install-debug "Unsupported rosdep output: ${rosdep_res[@]}"; TUE_INSTALL_CURRENT_TARGET=$parent_target; return 1 + *) tue-install-debug "Unsupported rosdep output: ${rosdep_res[*]}"; + TUE_INSTALL_CURRENT_TARGET=$parent_target; + TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target; + return 1 ;; esac + if [[ ${rosdep[1]} == "ros-"* ]] + then + # Also make sure ros is installed + tue-install-target ros || tue-install-error "Failed to install target 'ROS'" + fi + + _set_dependencies $parent_target $target + touch $TUE_INSTALL_STATE_DIR/$target TUE_INSTALL_CURRENT_TARGET=$parent_target + TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target return 0 else - tue-install-debug "Could not be resolved by rosdep. error: ${rosdep_res[@]}" + tue-install-debug "Could not be resolved by rosdep. error: ${rosdep_res[*]}" TUE_INSTALL_CURRENT_TARGET=$parent_target + TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target return 1 fi else tue-install-debug "Target '$target' already resolved correctly by rosdep, skipping it this time." + + _set_dependencies $parent_target $target + TUE_INSTALL_CURRENT_TARGET=$parent_target + TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$parent_target return 0 fi } @@ -204,11 +227,18 @@ function tue-install-target # Check if valid target received as input if [ ! -d $TUE_INSTALL_TARGETS_DIR/$target ] then - # Check if can be resolved by rosdep - tue-install-rosdep $target - if [ $? -eq 0 ] + # Targets starting with 'ros-' will never be resolved by rosdep + if [[ "$target" != "ros-"* ]] then - return 0 + # Check if can be resolved by rosdep + tue-install-rosdep $target + if [ $? -eq 0 ] + then + return 0 + else + tue-install-debug "Target '$target' does not exist." + return 1 + fi else tue-install-debug "Target '$target' does not exist." return 1 @@ -219,17 +249,7 @@ function tue-install-target TUE_INSTALL_CURRENT_TARGET=$target TUE_INSTALL_CURRENT_TARGET_DIR=$TUE_INSTALL_TARGETS_DIR/$target - # If the target has a parent target, add target as a dependency to the parent target - if [ -n "$parent_target" ] && [ "$parent_target" != "main-loop" ] - then - if [ "$parent_target" != "$target" ] - then - echo "$target" >> "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" - echo "$parent_target" >> "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" - sort "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" -u -o "$TUE_INSTALL_DEPENDENCIES_DIR"/"$parent_target" - sort "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" -u -o "$TUE_INSTALL_DEPENDENCIES_ON_DIR"/"$target" - fi - fi + _set_dependencies $parent_target $target local state_file="$TUE_INSTALL_STATE_DIR"/"$target" local state_file_now="${state_file}-now"