diff --git a/setup.sh b/setup.sh index 9089ca7ce295c10c35c03379757d18b54c40f633..248c3f25a67482c8c98437ceacfa0326562f0e5e 100644 --- a/setup.sh +++ b/setup.sh @@ -55,79 +55,51 @@ function initial_setup() { } function manage_plugins() { - plugins=( - "likert scale plugin" - "Logging Plugin" - "nDisplayExtensions" - "NDisplay Launch Button" - "UniversalLogging" - "Unreal Cave Overlay" - "Unreal-Study-Framework" - "Unreal VA Plugin" - "UnrealVisPlugin" - "Widget Interaction Plugin" - ) - - plugin_repositories=( - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/likert-scale-plugin.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/logging-plugin.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/ndisplayextensions.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/NDisplayLaunchButton.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/universallogging.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-cave-overlay.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-study-framework.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unreal-va-plugin.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unrealvisplugin.git" - "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/widgetinteraction.git" - ) - - if [ "$1" == "initial_setup" ] - then - plugin_branches=( - "" - "" - "master" - "" - "" - "master" - "" - "" - "" - "" - ) - else - plugin_branches=( - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - ) - - for i in ${!plugins[@]} - do - repo_name_with_extension=${plugin_repositories[$i]##*/} - repo_name=${repo_name_with_extension%*.git} - path=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.path") + SAVEIFS=$IFS + IFS=$'\n' + plugin_list=($(git config -f Plugins/UnrealPlugins/plugins.config --name-only --get-regexp ".*.name")) + IFS=$SAVEIFS + + declare -a plugin_ids + declare -a plugins + declare -a plugin_repositories + declare -a plugin_branches + + for i in ${!plugin_list[@]} + do + plugin_id=${plugin_list[$i]%.name} + plugin_ids+=("$plugin_id") + plugin_name=$(git config -f Plugins/UnrealPlugins/plugins.config --get "$plugin_id.name") + plugins+=("${plugin_name}") + plugin_repositories+=($(git config -f Plugins/UnrealPlugins/plugins.config --get "$plugin_id.url")) + + if [ "$1" == "initial_setup" ] + then + branch=($(git config -f Plugins/UnrealPlugins/plugins.config --get "$plugin_id.default-branch")) if [ $? == 0 ] then - branch=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.branch") + plugin_branches+=("$branch") + else + plugin_branches+=("") + fi + else + path=$(git config -f .gitmodules --get "submodule.Plugins/${plugin_id}.path") + if [ $? == 0 ] + then + branch=$(git config -f .gitmodules --get "submodule.Plugins/${plugin_id}.branch") if [ $? -ne 0 ] then - plugin_branches[$i]="master" + plugin_branches+=("master") else - plugin_branches[$i]="$branch" + plugin_branches+=("$branch") fi + else + plugin_branches+=("") fi - done - fi + fi + done function toggle_branch() { case ${plugin_branches[$1]} in @@ -178,6 +150,7 @@ function manage_plugins() { echo "[Enter] Continue" echo "[Esc] Cancel" + SAVEIFS=$IFS IFS='' escape_char=$(printf "\u1b") escape=false @@ -186,6 +159,7 @@ function manage_plugins() { escape=true read -rsn2 -t 0.1 mode # read 2 more chars fi + IFS=$SAVEIFS case $mode in "") if [ "$escape" == true ]; then cancel=true; fi; exit=true ;; " ") toggle_branch $selection ;; @@ -193,6 +167,7 @@ function manage_plugins() { "[B") if [ "$selection" -lt "$num_plugins_minus_one" ]; then let selection+=1; fi ;; *) >&2 ;; esac + done if [ "$cancel" != true ] @@ -204,9 +179,7 @@ function manage_plugins() { for i in ${!plugins[@]} do # Check if plugin is already present - repo_name_with_extension=${plugin_repositories[$i]##*/} - repo_name=${repo_name_with_extension%*.git} - path=$(git config -f .gitmodules --get "submodule.Plugins/${repo_name}.path") + path=$(git config -f .gitmodules --get "submodule.Plugins/${plugin_ids[$i]}.path") if [ $? -ne 0 ] then plugin_present=false @@ -226,7 +199,7 @@ function manage_plugins() { else # Updating existing plugin echo "Update plugin: ${plugins[$i]}" - cd Plugins/$repo_name + cd "Plugins/${plugin_ids[$i]}" git fetch git checkout ${plugin_branches[$i]} git pull @@ -236,7 +209,7 @@ function manage_plugins() { if [ "$plugin_present" == true ] then # Remove plugin! - git rm -f "Plugins/$repo_name" + git rm -f "Plugins/${plugin_ids[$i]}" fi fi done @@ -281,6 +254,7 @@ function show_main_menu() { echo "[Enter] Select" echo "[Esc] Quit" + SAVEIFS=$IFS IFS='' escape_char=$(printf "\u1b") escape=false @@ -289,6 +263,7 @@ function show_main_menu() { escape=true read -rsn2 -t 0.1 mode # read 2 more chars fi + IFS=$SAVEIFS case $mode in "") if [ "$escape" = true ]; then quit=true; fi; exit=true ;; "[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;;