Skip to content

Commit

Permalink
api: read_packages_file set output to null if not all required pack…
Browse files Browse the repository at this point in the history
…ages are available
  • Loading branch information
theofficialgman committed Feb 29, 2024
1 parent 3e3526c commit 1eb8aa6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,7 @@ app_type() { #there are 'standard' apps, and there are 'package' apps - an alias
}

read_packages_file() { #Returns which packages are to be installed from a package-app - handle the '|' separater
#if all packages are not available that are needed to be installed, returns no output
local app="$1"
[ -z "$app" ] && error "read_packages_file(): no app specified!"

Expand All @@ -1485,16 +1486,27 @@ read_packages_file() { #Returns which packages are to be installed from a packag
if [[ "$word" == *'|'* ]];then
IFS='|'
local package
local available="no"
for package in $word ;do
if package_available "$package" ;then
packages+="$package "
available="yes"
break
fi
done
if [ "$available" == "no" ]; then
#no package in the OR is available so set the output as empty

This comment has been minimized.

Copy link
@Botspot

Botspot Feb 29, 2024

Owner

does OR stand for something?

This comment has been minimized.

Copy link
@Botspot

Botspot Feb 29, 2024

Owner

oh I understand it now

This comment has been minimized.

Copy link
@theofficialgman

theofficialgman Feb 29, 2024

Author Collaborator

the package names listed may also include lists of alternative package names, separated by vertical bar (pipe) symbols |. In such a case, that part of the dependency can be satisfied by any one of the alternative packages.

the | is what I am calling OR. basically a space separated list is AND (all are required) and a | separated list is OR (where only one is required).

packages=''
break
fi
else
if package_available "$word" ;then
#no separator, so return it without change
packages+="$word "
else
#one package in the AND is not available so set the output as empty
packages=''
break
fi
fi
done
Expand Down

0 comments on commit 1eb8aa6

Please sign in to comment.