From 75aae126c423dcc9b215aef57daff9e7bd8f5f6b Mon Sep 17 00:00:00 2001 From: morganamilo Date: Wed, 30 Jan 2019 18:07:20 +0000 Subject: libmakepkg: centralise random arrays of pkgbuild variables Refactor many of the different arrays of pkgbuild variables into scripts/libmakepkg/util/schema.sh.in. Signed-off-by: morganamilo Signed-off-by: Allan McRae --- scripts/libmakepkg/lint_pkgbuild/variable.sh.in | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'scripts/libmakepkg/lint_pkgbuild/variable.sh.in') diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in index a975b024..512bed7b 100644 --- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in @@ -25,22 +25,16 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/message.sh" source "$LIBRARY/util/pkgbuild.sh" +source "$LIBRARY/util/schema.sh" lint_pkgbuild_functions+=('lint_variable') lint_variable() { - # TODO: refactor - similar arrays are used elsewhere - local array=(arch backup groups license noextract options validpgpkeys) - local arch_array=(checkdepends conflicts depends makedepends md5sums - optdepends provides replaces sha1sums sha224sums - sha256sums sha384sums sha512sums source) - local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url) - local i a pkg out bad ret=0 # global variables - for i in ${array[@]} ${arch_array[@]}; do + for i in ${pkgbuild_schema_arrays[@]}; do if declare -p $i > /dev/null 2>&1; then if ! is_array $i; then error "$(gettext "%s should be an array")" "$i" @@ -52,7 +46,7 @@ lint_variable() { for a in ${arch[@]}; do [[ $a == "any" ]] && continue - for i in ${arch_array[@]}; do + for i in ${pkgbuild_schema_arch_arrays[@]}; do if declare -p "${i}_${a}" > /dev/null 2>&1; then if ! is_array ${i}_${a}; then error "$(gettext "%s should be an array")" "${i}_${a}" @@ -62,7 +56,7 @@ lint_variable() { done done - for i in ${string[@]}; do + for i in ${pkgbuild_schema_strings[@]}; do if declare -p "$i" > /dev/null 2>&1; then if is_array $i; then error "$(gettext "%s should not be an array")" "$i" @@ -73,7 +67,7 @@ lint_variable() { # package function variables for pkg in ${pkgname[@]}; do - for i in ${array[@]} ${arch_array[@]}; do + for i in ${pkgbuild_schema_arrays[@]}; do if extract_function_variable "package_$pkg" $i 0 out; then error "$(gettext "%s should be an array")" "$i" ret=1 @@ -83,7 +77,7 @@ lint_variable() { for a in ${arch[@]}; do [[ $a == "any" ]] && continue - for i in ${arch_array[@]}; do + for i in ${pkgbuild_schema_arch_arrays[@]}; do if extract_function_variable "package_$pkg" "${i}_${a}" 0 out; then error "$(gettext "%s should be an array")" "${i}_${a}" ret=1 @@ -91,7 +85,7 @@ lint_variable() { done done - for i in ${string[@]}; do + for i in ${pkgbuild_schema_strings[@]}; do if extract_function_variable "package_$pkg" $i 1 out; then error "$(gettext "%s should not be an array")" "$i" ret=1 -- cgit v1.2.3-54-g00ecf