aboutsummaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authormandree <mandree@FreeBSD.org>2014-08-22 15:13:51 +0800
committermandree <mandree@FreeBSD.org>2014-08-22 15:13:51 +0800
commit223dad2c273e331e92c59a3e8fc11113486f40e3 (patch)
tree2ffc6edafcc3745479145fbd7c03067646f2f4c8 /Tools
parent3b1f983597188b6a162a88df610d4ec709dc409a (diff)
downloadfreebsd-ports-gnome-223dad2c273e331e92c59a3e8fc11113486f40e3.tar.gz
freebsd-ports-gnome-223dad2c273e331e92c59a3e8fc11113486f40e3.tar.zst
freebsd-ports-gnome-223dad2c273e331e92c59a3e8fc11113486f40e3.zip
Catch and report substitution failure on lines such as PORTREVISION=${SOME_VAR}.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/bump-revision.sh31
1 files changed, 22 insertions, 9 deletions
diff --git a/Tools/scripts/bump-revision.sh b/Tools/scripts/bump-revision.sh
index 3b22b8863e56..ed18d2bcbf45 100755
--- a/Tools/scripts/bump-revision.sh
+++ b/Tools/scripts/bump-revision.sh
@@ -43,6 +43,7 @@ printc () {
#
tempfile=$(mktemp)
+rm -f $tempfile
trap "rm -f $tempfile" 0 1 2 3 15
while [ $# -gt 0 ]
@@ -50,15 +51,27 @@ do
if [ -f "$1/Makefile" ]; then
echo -n > $tempfile
revision=`grep "^PORTREVISION?\?=" "$1/Makefile"`
- if [ $? == 0 ]; then
- printc "$1: $revision found, bumping it by 1." "green"
- awk -F "\t" '/^PORTREVISION\??=/{ gsub ($2,$2+1) };{ print }' "$1/Makefile" > $tempfile
- cat $tempfile > "$1/Makefile"
- else
- printc "$1: PORTREVISION not found, adding PORTREVISION=1" "red"
- awk '/^PORTVERSION\??=\t/{print;print "PORTREVISION=\t1";next}1' "$1/Makefile" > $tempfile
- cat $tempfile > "$1/Makefile"
- fi
+ case $? in
+ 0)
+ # fixme: gsub fails massively if there are any special
+ # characters inside PORTREVISION. For now, we will only
+ # catch this bug by checking the replace count, and if not
+ # 1, bail out and complain.
+ # The proper fix is to do a stricter check that PORTREVISION
+ # is an integer.
+ awk -F "\t" '/^PORTREVISION\??=/{ rplc = gsub ($2,$2+1); if (rplc != 1) { exit 1 } };{ print }' "$1/Makefile" > $tempfile \
+ && { cat $tempfile > "$1/Makefile" ; printc "$1: $revision found, bumping it by 1." "green" ; } \
+ || printc "$1: FAILED TO BUMP PORTREVISION" red
+ ;;
+ 1)
+ awk '/^PORTVERSION\??=\t/{print;print "PORTREVISION=\t1";next}' "$1/Makefile" > $tempfile \
+ && { cat $tempfile > "$1/Makefile" ;printc "$1: PORTREVISION not found, adding PORTREVISION=1" "green" ; } \
+ || printc "$1: FAILED TO BUMP PORTREVISION" red
+ ;;
+ *)
+ printc "$1: grepping $1/Makefile failed!" red
+ ;;
+ esac
else
printc "$1: might not be a port directory as $1/Makefile is missing!" "red"
fi