[pacman-dev,5/7] libmakepkg: disallow using any as an architecture specific variable

Message ID 20180608181859.20724-6-morganamilo@gmail.com
State Superseded, archived
Headers show
Series Improve linting for makepkg | expand

Commit Message

morganamilo June 8, 2018, 6:18 p.m. UTC
Signed-off-by: morganamilo <morganamilo@gmail.com>
---
 scripts/libmakepkg/lint_pkgbuild/variable.sh.in | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Allan McRae June 19, 2018, 1:05 p.m. UTC | #1
On 09/06/18 04:18, morganamilo wrote:
> Signed-off-by: morganamilo <morganamilo@gmail.com>
> ---
>  scripts/libmakepkg/lint_pkgbuild/variable.sh.in | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
> index b9264768..6b7da4a2 100644
> --- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
> +++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
> @@ -57,12 +57,15 @@ lint_variable() {
>  	done
>  
>  	for a in ${arch[@]}; do
> -		[[ $a == "any" ]] && continue
> -
>  		for i in ${arch_array[@]}; do
>  			v="${i}_${a}"
>  			eval "keys=(\"\${!${v}[@]}\")"
>  			if (( ${#keys[*]} > 0 )); then
> +				if [[ $a == "any" ]]; then
> +					error "$(gettext "%s_%s any can not be used for an architecture specific variable")" "$i" "$a"


I'm trying to see if this message can be clearer. How about this for the
error message?

("Can not provide architecture specific variables for the '%s' arch:
%s_%s") "any" "$i "$a

A

Patch

diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index b9264768..6b7da4a2 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -57,12 +57,15 @@  lint_variable() {
 	done
 
 	for a in ${arch[@]}; do
-		[[ $a == "any" ]] && continue
-
 		for i in ${arch_array[@]}; do
 			v="${i}_${a}"
 			eval "keys=(\"\${!${v}[@]}\")"
 			if (( ${#keys[*]} > 0 )); then
+				if [[ $a == "any" ]]; then
+					error "$(gettext "%s_%s any can not be used for an architecture specific variable")" "$i" "$a"
+					ret=1
+				fi
+
 				if ! is_array $v; then
 					error "$(gettext "%s_%s should be an array")" "$i" "$a"
 					ret=1
@@ -111,6 +114,11 @@  lint_variable() {
 
 			for i in ${array[@]}; do
 				if extract_function_variable "package_$pkg" "${i}_${a}" 1 out; then
+					if [[ $a == "any" ]]; then
+						error "$(gettext "%s_%s any can not be used for an architecture specific variable")" "$i" "$a"
+						ret=1
+					fi
+
 					error "$(gettext "%s_%s can not be architecture specific")" "$i" "$a"
 					ret=1
 				fi