From 77482a0064919677e5e948e6c00666d0fffe7486 Mon Sep 17 00:00:00 2001 From: Phillip Smith Date: Mon, 12 May 2014 14:00:51 +1000 Subject: [PATCH] strip comments early when evaluating provides/backups/optdepends/options stripping the comments as the first step avoids errors when these arrays contain multiple lines with comments on each line where the comment contains a round-bracket eg: options=( '!strip' '!makeflags' # issues with concurrency (`-j2', etc.) ) --- scripts/makepkg.sh.in | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d8cdc88..08d19ca 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -2189,8 +2189,9 @@ check_sanity() { fi local provides_list=() - eval $(awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | \ - sed -e "s/provides=/provides_list+=/" -e "s/#.*//" -e 's/\\$//') + eval $(sed -e "s/[[:space:]]*#.*//" "$BUILDFILE" | \ + awk '/^[[:space:]]*provides=/,/\)/' | \ + sed -e "s/provides=/provides_list+=/" -e 's/\\$//') for i in ${provides_list[@]}; do if [[ $i == *['<>']* ]]; then error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides" @@ -2199,8 +2200,9 @@ check_sanity() { done local backup_list=() - eval $(awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | \ - sed -e "s/backup=/backup_list+=/" -e "s/#.*//" -e 's/\\$//') + eval $(sed -e "s/[[:space:]]*#.*//" "$BUILDFILE" | \ + awk '/^[[:space:]]*backup=/,/\)/' | \ + sed -e "s/backup=/backup_list+=/" -e 's/\\$//') for i in "${backup_list[@]}"; do if [[ ${i:0:1} = "/" ]]; then error "$(gettext "%s entry should not contain leading slash : %s")" "backup" "$i" @@ -2209,8 +2211,9 @@ check_sanity() { done local optdepends_list=() - eval $(awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(#.*)?$/' "$BUILDFILE" | \ - sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//') + eval $(sed -e "s/[[:space:]]*#.*//" "$BUILDFILE" | \ + awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(#.*)?$/' | \ + sed -e "s/optdepends=/optdepends_list+=/" -e 's/\\$//') for i in "${optdepends_list[@]}"; do local pkg=${i%%:[[:space:]]*} # the '-' character _must_ be first or last in the character range @@ -2234,8 +2237,9 @@ check_sanity() { local valid_options=1 local known kopt options_list - eval $(awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | \ - sed -e "s/options=/options_list+=/" -e "s/#.*//" -e 's/\\$//') + eval $(sed -e "s/[[:space:]]*#.*//" "$BUILDFILE" | \ + awk '/^[[:space:]]*options=/,/\)/' | \ + sed -e "s/options=/options_list+=/" -e 's/\\$//') for i in ${options_list[@]}; do known=0 # check if option matches a known option or its inverse -- 1.9.2