makepkg will now error if disallowed variables are set inside of
the package function.

Disallowed variables are variables that do exist, like 'makedepends'
and 'pkgver' but can not be set inside of a package function.

Signed-off-by: morganamilo <morganam...@gmail.com>
---
 .../libmakepkg/lint_pkgbuild/variable.sh.in   | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in 
b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index 1ee3c834..ad3ffd8e 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -38,6 +38,11 @@ lint_variable() {
                          source)
        local string=(changelog epoch install pkgbase pkgdesc pkgrel pkgver url)
 
+       local no_package_string=(epoch pkgbase pkgname pkgrel pkgver)
+
+       local no_package_array=(checkdepends makedepends md5sums noextract
+                       sha1sums sha224sums sha256sums sha384sums sha512sums
+                       source validpgpkeys)
        local i a pkg out bad ret=0
 
        # global variables
@@ -84,6 +89,21 @@ lint_variable() {
                for a in ${arch[@]}; do
                        [[ $a == "any" ]] && continue
 
+                       for i in ${no_package_string[@]}; do
+                               if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
+                                       error "$(gettext "%s_%s can not be set 
inside a package function")" "$i" "$a"
+                                       ret=1
+                               fi
+                       done
+
+                       for i in ${no_package_array[@]}; do
+                               if extract_function_variable "package_$pkg" 
"${i}_${a}" 1 out; then
+                                       error "$(gettext "%s_%s can not be set 
inside a package function")" "$i" "$a"
+                                       ret=1
+                               fi
+
+                       done
+
                        for i in ${arch_array[@]}; do
                                if extract_function_variable "package_$pkg" 
"${i}_${a}" 0 out; then
                                        error "$(gettext "%s_%s should be an 
array")" "$i" "$a"
@@ -92,6 +112,20 @@ lint_variable() {
                        done
                done
 
+               for i in ${no_package_string[@]}; do
+                       if extract_function_variable "package_$pkg" "$i" 0 out; 
then
+                               error "$(gettext "%s can not be set inside a 
package function")" "$i"
+                               ret=1
+                       fi
+               done
+
+               for i in ${no_package_array[@]}; do
+                       if extract_function_variable "package_$pkg" "$i" 1 out; 
then
+                               error "$(gettext "%s can not be set inside a 
package function")" "$i"
+                               ret=1
+                       fi
+               done
+
                for i in ${string[@]}; do
                        if extract_function_variable "package_$pkg" $i 1 out; 
then
                                error "$(gettext "%s should not be an array")" 
"$i"
-- 
2.20.1

Reply via email to