From 71c20597424f92252e11aea32775887637600b28 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Fri, 11 May 2018 13:43:54 +0100
Subject: [PATCH] Some apps will not install on arm

---
 src/freedombone-app-rocketchat |  1 +
 src/freedombone-utils-selector | 91 +++++++++++++++++++++-------------
 2 files changed, 57 insertions(+), 35 deletions(-)

diff --git a/src/freedombone-app-rocketchat b/src/freedombone-app-rocketchat
index 6884b49a3..4846952c9 100755
--- a/src/freedombone-app-rocketchat
+++ b/src/freedombone-app-rocketchat
@@ -29,6 +29,7 @@ VARIANTS='full full-vim'
 
 IN_DEFAULT_INSTALL=0
 SHOW_ON_ABOUT=1
+NOT_ON_ARM=1
 
 ROCKETCHAT_DOMAIN_NAME=
 ROCKETCHAT_CODE=
diff --git a/src/freedombone-utils-selector b/src/freedombone-utils-selector
index 25ed118e8..99aaab1b6 100755
--- a/src/freedombone-utils-selector
+++ b/src/freedombone-utils-selector
@@ -286,6 +286,19 @@ function app_not_on_onion_only {
     echo "1"
 }
 
+function app_not_on_arm {
+    app_name="$1"
+
+    if grep -q "NOT_ON_ARM=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
+        archtype=$(uname -m)
+        if [[ "$archtype" == 'arm'* ]]; then
+            echo "0"
+            return
+        fi
+    fi
+    echo "1"
+}
+
 function enough_ram_for_app {
     app_name="$1"
 
@@ -320,10 +333,12 @@ function detect_apps {
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
         if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
             if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
-                # shellcheck disable=SC2068
-                if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
-                    APPS_AVAILABLE+=("${app_name}")
-                    APPS_CHOSEN+=("0")
+                if [[ $(app_not_on_arm "$app_name") != "0" ]]; then
+                    # shellcheck disable=SC2068
+                    if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
+                        APPS_AVAILABLE+=("${app_name}")
+                        APPS_CHOSEN+=("0")
+                    fi
                 fi
             fi
         fi
@@ -356,16 +371,18 @@ function detect_installable_apps {
 
         if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
             if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
-                # shellcheck disable=SC2068
-                if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
-                    variants_list=$(app_variants "$filename")
-                    # check for empty string
-                    if [ ${#variants_list} -gt 0 ]; then
-                        APPS_AVAILABLE+=("${app_name}")
-                        APPS_CHOSEN+=("0")
-                        APPS_INSTALLED+=("$(app_is_installed "$app_name")")
-                        if [[ $(app_is_installed "$app_name") == "1" ]]; then
-                            APPS_INSTALLED_NAMES+=("$app_name")
+                if [[ $(app_not_on_arm "$app_name") != "0" ]]; then
+                    # shellcheck disable=SC2068
+                    if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
+                        variants_list=$(app_variants "$filename")
+                        # check for empty string
+                        if [ ${#variants_list} -gt 0 ]; then
+                            APPS_AVAILABLE+=("${app_name}")
+                            APPS_CHOSEN+=("0")
+                            APPS_INSTALLED+=("$(app_is_installed "$app_name")")
+                            if [[ $(app_is_installed "$app_name") == "1" ]]; then
+                                APPS_INSTALLED_NAMES+=("$app_name")
+                            fi
                         fi
                     fi
                 fi
@@ -392,13 +409,15 @@ function detect_installed_apps {
 
         if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
             if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
-                if [[ $(app_is_installed "$app_name") == "1" ]]; then
-                    # shellcheck disable=SC2068
-                    if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
-                        variants_list=$(app_variants "$filename")
-                        if [ ${#variants_list} -gt 0 ]; then
-                            APPS_AVAILABLE+=("${app_name}")
-                            APPS_INSTALLED_NAMES+=("$app_name")
+                if [[ $(app_not_on_arm "$app_name") != "0" ]]; then
+                    if [[ $(app_is_installed "$app_name") == "1" ]]; then
+                        # shellcheck disable=SC2068
+                        if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
+                            variants_list=$(app_variants "$filename")
+                            if [ ${#variants_list} -gt 0 ]; then
+                                APPS_AVAILABLE+=("${app_name}")
+                                APPS_INSTALLED_NAMES+=("$app_name")
+                            fi
                         fi
                     fi
                 fi
@@ -431,26 +450,28 @@ function choose_apps_for_variant {
         app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
         if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
             if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
-                # shellcheck disable=SC2068
-                if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
-                    if grep -q "VARIANTS=" "${filename}"; then
-                        variants_list=$(app_variants "$filename")
-                        if [[ "${variants_list}" == 'all'* || \
-                                  "${variants_list}" == "$variant_name" || \
-                                  "${variants_list}" == "$variant_name "* || \
-                                  "${variants_list}" == *" $variant_name "* || \
-                                  "${variants_list}" == *" $variant_name" ]]; then
-                            if [[ $(app_is_removed "${a}") == "0" ]]; then
-                                #echo $"${app_name} chosen"
-                                APPS_CHOSEN+=("1")
+                if [[ $(app_not_on_arm "$app_name") != "0" ]]; then
+                    # shellcheck disable=SC2068
+                    if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
+                        if grep -q "VARIANTS=" "${filename}"; then
+                            variants_list=$(app_variants "$filename")
+                            if [[ "${variants_list}" == 'all'* || \
+                                      "${variants_list}" == "$variant_name" || \
+                                      "${variants_list}" == "$variant_name "* || \
+                                      "${variants_list}" == *" $variant_name "* || \
+                                      "${variants_list}" == *" $variant_name" ]]; then
+                                if [[ $(app_is_removed "${a}") == "0" ]]; then
+                                    #echo $"${app_name} chosen"
+                                    APPS_CHOSEN+=("1")
+                                else
+                                    APPS_CHOSEN+=("0")
+                                fi
                             else
                                 APPS_CHOSEN+=("0")
                             fi
                         else
                             APPS_CHOSEN+=("0")
                         fi
-                    else
-                        APPS_CHOSEN+=("0")
                     fi
                 fi
             fi
-- 
GitLab