Skip to content
Snippets Groups Projects
Commit 38644d03 authored by Bob Mottram's avatar Bob Mottram
Browse files

Show only installable apps

Apps with an empty variants string are considered too experimental to be installable
parent 28d5909c
No related branches found
No related tags found
No related merge requests found
......@@ -172,7 +172,7 @@ if [ ! "$?" = "0" ]; then
exit 2
fi
detect_apps
detect_installable_apps
# if no applications were found
if [[ ${#APPS_AVAILABLE[@]} == 0 ]]; then
......
......@@ -40,6 +40,17 @@ APPS_CHOSEN=()
# A list of the names of installed apps
APPS_INSTALLED_NAMES=()
function app_variants {
filename=$1
variants_line=$(cat ${filename} | grep "VARIANTS=")
if [[ "$variants_line" == *"'"* ]]; then
variants_list=$(echo "$variants_line" | awk -F '=' '{print $2}' | awk -F "'" '{print $2}')
else
variants_list=$(echo "$variants_line" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
fi
echo "$variants_list"
}
function item_in_array {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
......@@ -98,6 +109,34 @@ function detect_apps {
get_apps_installed_names
}
function detect_installable_apps {
FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
APPS_AVAILABLE=()
APPS_CHOSEN=()
APPS_INSTALLED=()
APPS_INSTALLED_NAMES=()
function_check app_is_installed
# for all the app scripts
for filename in $FILES
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if [[ $(item_in_array ${app_name} ${APPS_AVAILABLE[@]}) != 0 ]]; then
variants_list=$(app_variants $filename)
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
done
}
# creates the APPS_AVAILABLE and APPS_CHOSEN arrays based on
# the given variant name
function choose_apps_for_variant {
......@@ -116,12 +155,7 @@ function choose_apps_for_variant {
APPS_AVAILABLE+=("${app_name}")
if grep -q "VARIANTS=" ${filename}; then
variants_line=$(cat ${filename} | grep "VARIANTS=")
if [[ "$variants_line" == *"'"* ]]; then
variants_list=$(echo "$variants_line" | awk -F '=' '{print $2}' | awk -F "'" '{print $2}')
else
variants_list=$(echo "$variants_line" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
fi
variants_list=$(app_variants $filename)
if [[ "${variants_list}" == 'all'* || \
"${variants_list}" == "$variant_name "* || \
"${variants_list}" == *" $variant_name "* || \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment