[pacman-dev] [PATCH] makepkg: pkgver and pkgrel can not have whitespace
There is always someone who tries to break things (cough *Dave* cough...) Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0682e4f..ec5b388 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1438,12 +1438,14 @@ check_sanity() { error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" ret=1 fi - if [[ $pkgver =~ [:-] ]]; then - error "$(gettext "%s is not allowed to contain colons or hyphens.")" "pkgver" + + if [[ $pkgver =~ [[:space:]:-] ]]; then + error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver" ret=1 fi - if [[ $pkgrel != ${pkgrel//-/} ]]; then - error "$(gettext "%s is not allowed to contain hyphens.")" "pkgrel" + + if [[ $pkgrel =~ [[:space:]-] ]]; then + error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel" ret=1 fi -- 1.7.6
Enforce syntax checking for pkgrel and pkgver overrides in package functions. Signed-off-by: Allan McRae <allan@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
Check any overrides of the "arch" variable contain the required architecture. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 19e8b8c..4b8f167 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1471,6 +1471,21 @@ check_sanity() { fi fi + if (( ${#pkgname[@]} > 1 )); then + for i in ${pkgname[@]}; do + local arch_list="" + eval $(declare -f package_${i} | sed -n 's/\(^[[:space:]]*arch=\)/arch_list=/p') + if [[ ${arch_list[@]} && ${arch_list} != 'any' ]]; then + if ! in_array $CARCH ${arch_list[@]}; then + if (( ! IGNOREARCH )); then + error "$(gettext "%s is not available for the '%s' architecture.")" "$i" "$CARCH" + ret=1 + fi + fi + fi + done + fi + local provides_list=() eval $(awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | \ sed -e "s/provides=/provides_list+=/" -e "s/#.*//" -e 's/\\$//') -- 1.7.6
On Fri, Jul 22, 2011 at 10:02:56PM +1000, Allan McRae wrote:
There is always someone who tries to break things (cough *Dave* cough...)
Just doin' my job. http://knowyourmeme.com/i/000/044/778/original/hatersgonnacat.jpg
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0682e4f..ec5b388 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1438,12 +1438,14 @@ check_sanity() { error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase" ret=1 fi - if [[ $pkgver =~ [:-] ]]; then - error "$(gettext "%s is not allowed to contain colons or hyphens.")" "pkgver" + + if [[ $pkgver =~ [[:space:]:-] ]]; then + error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver" ret=1 fi - if [[ $pkgrel != ${pkgrel//-/} ]]; then - error "$(gettext "%s is not allowed to contain hyphens.")" "pkgrel" + + if [[ $pkgrel =~ [[:space:]-] ]]; then + error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel" ret=1 fi
-- 1.7.6
participants (2)
-
Allan McRae
-
Dave Reisner