[pacman-dev] [PATCH] makepkg: check overrides for pkgrel and pkgver

Allan McRae allan at archlinux.org
Fri Jul 22 08:02:57 EDT 2011


Enforce syntax checking for pkgrel and pkgver overrides in package
functions.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 scripts/makepkg.sh.in |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index ec5b388..19e8b8c 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1439,15 +1439,21 @@ check_sanity() {
 		ret=1
 	fi
 
-	if [[ $pkgver =~ [[:space:]:-] ]]; then
-		error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
-		ret=1
-	fi
+	awk -F'=' '/^[[:space:]]*pkgver=/ { $1=""; print $0 }' "$BUILDFILE" |
+	while read i; do
+		if [[ $i =~ [[:space:]:-] ]]; then
+			error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
+			return 1
+		fi
+	done || ret=1
 
-	if [[ $pkgrel =~ [[:space:]-] ]]; then
-		error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel"
-		ret=1
-	fi
+	awk -F'=' '/^[[:space:]]*pkgrel=/ { $1=""; print $0 }' "$BUILDFILE" |
+	while read i; do
+		if [[ $i =~ [[:space:]-] ]]; then
+			error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel"
+			return 1
+		fi
+	done || ret=1
 
 	if [[ ! $epoch =~ ^[0-9]*$ ]]; then
 		error "$(gettext "%s must be an integer.")" "epoch"
-- 
1.7.6



More information about the pacman-dev mailing list