From 9783a402cc5a3bd17f6616dc6095b9d98205cc37 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Sat, 15 Oct 2016 13:59:56 +0100
Subject: [PATCH] Function checks

---
 src/freedombone-utils-selector | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/freedombone-utils-selector b/src/freedombone-utils-selector
index 16fb4122e..ec969d5f1 100755
--- a/src/freedombone-utils-selector
+++ b/src/freedombone-utils-selector
@@ -106,6 +106,8 @@ function item_in_array {
 # returns a list of available system variants
 # based upon the variants string in each app script
 function available_system_variants {
+    function_check item_in_array
+
     FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
 
     new_available_variants_list=()
@@ -127,6 +129,8 @@ function available_system_variants {
 function is_valid_variant {
     sys_type="$1"
     available_variants_list=()
+
+    function_check available_system_variants
     available_system_variants
 
     for variant_str in "${available_variants_list[@]}"
@@ -140,6 +144,8 @@ function is_valid_variant {
 
 function show_available_variants {
     available_variants_list=()
+
+    function_check available_system_variants
     available_system_variants
 
     for variant_str in "${available_variants_list[@]}"
@@ -250,6 +256,8 @@ function get_apps_installed_names {
 function detect_apps {
     FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
 
+    function_check item_in_array
+
     APPS_AVAILABLE=()
     APPS_CHOSEN=()
 
@@ -281,7 +289,9 @@ function detect_installable_apps {
     APPS_INSTALLED=()
     APPS_INSTALLED_NAMES=()
 
+    function_check app_variants
     function_check app_is_installed
+    function_check item_in_array
 
     # for all the app scripts
     for filename in $FILES
@@ -309,6 +319,10 @@ function detect_installable_apps {
 function choose_apps_for_variant {
     variant_name="$1"
 
+    function_check item_in_array
+    function_check app_variants
+    function_check app_is_removed
+
     if [ ${#variant_name} -eq 0 ]; then
         echo $"No variant name for choosing apps"
         exit 237567
@@ -370,9 +384,16 @@ function remove_apps {
         if [[ ${APPS_INSTALLED[$app_index]} == "1" ]]; then
             if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
                 echo $"Removing application: ${a}"
+
+                function_check app_load_variables
                 app_load_variables ${a}
+
+                function_check remove_app
                 remove_app ${a}
+
+                function_check remove_${a}
                 remove_${a}
+
                 echo $"${a} was removed"
             fi
         fi
@@ -417,8 +438,10 @@ function install_apps {
             if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
                 if [ ${is_interactive} ]; then
                     # clears any removal indicator
+                    function_check reinstall_app
                     reinstall_app ${a}
 
+                    function_check app_load_variables
                     app_load_variables ${a}
 
                     if [[ $(app_is_installed ${a}) == "1" ]]; then
@@ -430,7 +453,10 @@ function install_apps {
                         APP_INSTALLED=
                         install_${a}
                         if [ $APP_INSTALLED ]; then
+                            function_check app_save_variables
                             app_save_variables ${a}
+
+                            function_check install_completed
                             install_completed ${a}
                             echo $"${a} was installed from interactive"
                         else
@@ -440,6 +466,7 @@ function install_apps {
                 else
                     # check if the app was removed
                     if [[ $(app_is_removed ${a}) == "0" ]]; then
+                        function_check app_load_variables
                         app_load_variables ${a}
                         if [[ $(app_is_installed ${a}) == "1" ]]; then
                             echo $"Upgrading application: ${a}"
@@ -450,7 +477,10 @@ function install_apps {
                             APP_INSTALLED=
                             install_${a}
                             if [ $APP_INSTALLED ]; then
+                                function_check app_save_variables
                                 app_save_variables ${a}
+
+                                function_check install_completed
                                 install_completed ${a}
                                 echo $"${a} was installed"
                             else
@@ -466,6 +496,7 @@ function install_apps {
         app_index=$[app_index+1]
     done
 
+    function_check update_installed_apps_list
     update_installed_apps_list
 }
 
-- 
GitLab