Empty values break pacman's db format, as an empty line indicates an end of section.
---
I've seen this out in the wild: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=vim-coc-highlight-git...
diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in index 1bc49722..22f5fbbb 100644 --- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in @@ -31,7 +31,7 @@ lint_pkgbuild_functions+=('lint_variable')
lint_variable() { - local i a pkg out bad ret=0 + local i a pkg out bad array var ret=0
# global variables for i in ${pkgbuild_schema_arrays[@]}; do @@ -93,5 +93,62 @@ lint_variable() { done done
+ # ensure lists don't contain empty values + for i in ${pkgbuild_schema_arrays[@]}; do + if declare -p $i > /dev/null 2>&1; then + array_build "array" "$i" + for var in "${array[@]}"; do + if [[ -z "$var" ]]; then + error "$(gettext "%s is not allowed to be empty")" "$i" + ret=1 + fi + done + fi + done + + for a in ${arch[@]}; do + [[ $a == "any" ]] && continue + + for i in ${pkgbuild_schema_arch_arrays[@]}; do + if declare -p "${i}_${a}" > /dev/null 2>&1; then + array_build "array" "${i}_${a}" + for var in "${array[@]}"; do + if [[ -z "$var" ]]; then + error "$(gettext "%s is not allowed to be empty")" "${i}_${a}" + ret=1 + fi + done + fi + done + done + + for pkg in ${pkgname[@]}; do + for i in ${pkgbuild_schema_arrays[@]}; do + if extract_function_variable "package_$pkg" $i 1 out; then + for val in "${out[@]}" ;do + if [[ -z "$val" ]]; then + error "$(gettext "%s is not allowed to be empty")" "$i" + ret=1 + fi + done + fi + done + + for a in ${arch[@]}; do + [[ $a == "any" ]] && continue + + for i in ${pkgbuild_schema_arch_arrays[@]}; do + if extract_function_variable "package_$pkg" "${i}_${a}" 1 out; then + for val in "${out[@]}" ;do + if [[ -z "$val" ]]; then + error "$(gettext "%s is not allowed to be empty")" "${i}_${a}" + ret=1 + fi + done + fi + done + done + done + return $ret }
On 28/10/20 11:39 am, morganamilo wrote:
Empty values break pacman's db format, as an empty line indicates an end of section.
I've seen this out in the wild: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=vim-coc-highlight-git...
diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in index 1bc49722..22f5fbbb 100644 --- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in @@ -31,7 +31,7 @@ lint_pkgbuild_functions+=('lint_variable')
lint_variable() {
- local i a pkg out bad ret=0
local i a pkg out bad array var ret=0
# global variables for i in ${pkgbuild_schema_arrays[@]}; do
@@ -93,5 +93,62 @@ lint_variable() { done done
- # ensure lists don't contain empty values
- for i in ${pkgbuild_schema_arrays[@]}; do
if declare -p $i > /dev/null 2>&1; then
array_build "array" "$i"
for var in "${array[@]}"; do
if [[ -z "$var" ]]; then
error "$(gettext "%s is not allowed to be empty")" "$i"
The array here is not empty, but a value in the array. I think this would be a better error message.
"$(gettext "%s is not allowed to contain empty values")" "$i"
ret=1
fi
done
fi
- done
- for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if declare -p "${i}_${a}" > /dev/null 2>&1; then
array_build "array" "${i}_${a}"
for var in "${array[@]}"; do
if [[ -z "$var" ]]; then
error "$(gettext "%s is not allowed to be empty")" "${i}_${a}"
ret=1
fi
done
fi
done
- done
- for pkg in ${pkgname[@]}; do
for i in ${pkgbuild_schema_arrays[@]}; do
if extract_function_variable "package_$pkg" $i 1 out; then
for val in "${out[@]}" ;do
Switched from var to val here.
if [[ -z "$val" ]]; then
error "$(gettext "%s is not allowed to be empty")" "$i"
ret=1
fi
done
fi
done
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if extract_function_variable "package_$pkg" "${i}_${a}" 1 out; then
for val in "${out[@]}" ;do
if [[ -z "$val" ]]; then
error "$(gettext "%s is not allowed to be empty")" "${i}_${a}"
ret=1
fi
done
fi
done
done
- done
- return $ret
}
pacman-dev@lists.archlinux.org