Use bash array syntax for DEPENDENCIES.

Using an array is better than an expanded string.
This commit is contained in:
Simon Howard 2016-06-18 16:31:18 -04:00
parent 7c11c2a33b
commit 2820b9a1d9
2 changed files with 15 additions and 14 deletions

View file

@ -58,16 +58,17 @@ description() {
}
dependencies() {
DEPENDENCIES+=" $*"
DEPENDENCIES+=("$@")
}
dependencies_for_native() {
for dep in $DEPENDENCIES; do
set_dependencies_native() {
local i=0
while [ $i -lt ${#DEPENDENCIES[@]} ]; do
dep="${DEPENDENCIES[$i]}"
if [[ "$PACKAGE_TYPE" = native ]] && ! [[ "$dep" =~ native: ]]; then
echo "native:$dep"
else
echo "$dep"
DEPENDENCIES[$i]="native:$dep"
fi
i=$((i + 1))
done
}
@ -127,7 +128,7 @@ configure_for_package() {
# Defaults before loading package file.
PACKAGE_DESCRIPTION="Package $package"
DEPENDENCIES=""
DEPENDENCIES=()
PACKAGE_DIR_NAME=$package
ALL_VARIANTS=()
@ -159,7 +160,7 @@ configure_for_package() {
# When installing a native package, all its dependencies are
# necessarily native as well.
DEPENDENCIES=$(dependencies_for_native)
set_dependencies_native
;;
*)
error_exit "Unknown package type $PACKAGE_TYPE"
@ -204,7 +205,7 @@ setup_build_environment() {
}
install_dependencies() {
for dep in $DEPENDENCIES; do
for dep in "${DEPENDENCIES[@]:0}"; do
chocpkg install "$dep"
done
}
@ -309,7 +310,7 @@ cmd_info() {
}
cmd_dependencies() {
for dep in $DEPENDENCIES; do
for dep in "${DEPENDENCIES[@]:0}"; do
echo "$dep"
chocpkg dependencies "$dep"
done | sort | uniq

View file

@ -17,20 +17,20 @@ do_build() {
# Installing a package group means installing all its packages; we don't
# trigger the build step like 'install' usually does (we don't have one).
cmd_install() {
for package in $DEPENDENCIES; do
for package in "${DEPENDENCIES[@]:0}"; do
chocpkg install "$package"
done
}
# Reinstalling a package group means reinstalling *all* its packages.
cmd_reinstall() {
for package in $DEPENDENCIES; do
for package in "${DEPENDENCIES[@]:0}"; do
chocpkg reinstall "$package"
done
}
cmd_dependencies() {
for package in $DEPENDENCIES; do
for package in "${DEPENDENCIES[@]:0}"; do
echo "$package"
chocpkg dependencies "$package"
done | sort | uniq
@ -38,7 +38,7 @@ cmd_dependencies() {
# Package group is installed if all its packages are installed.
cmd_installed() {
for package in $DEPENDENCIES; do
for package in "${DEPENDENCIES[@]:0}"; do
chocpkg installed "$package"
done
}