From owner-svn-ports-head@FreeBSD.ORG Fri Aug 22 07:13:51 2014 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B3DA1852; Fri, 22 Aug 2014 07:13:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85B253D97; Fri, 22 Aug 2014 07:13:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7M7DpTO067460; Fri, 22 Aug 2014 07:13:51 GMT (envelope-from mandree@FreeBSD.org) Received: (from mandree@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7M7DpaG067459; Fri, 22 Aug 2014 07:13:51 GMT (envelope-from mandree@FreeBSD.org) Message-Id: <201408220713.s7M7DpaG067459@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mandree set sender to mandree@FreeBSD.org using -f From: Matthias Andree Date: Fri, 22 Aug 2014 07:13:51 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r365612 - head/Tools/scripts X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2014 07:13:51 -0000 Author: mandree Date: Fri Aug 22 07:13:51 2014 New Revision: 365612 URL: http://svnweb.freebsd.org/changeset/ports/365612 QAT: https://qat.redports.org/buildarchive/r365612/ Log: Catch and report substitution failure on lines such as PORTREVISION=${SOME_VAR}. Modified: head/Tools/scripts/bump-revision.sh Modified: head/Tools/scripts/bump-revision.sh ============================================================================== --- head/Tools/scripts/bump-revision.sh Fri Aug 22 06:56:48 2014 (r365611) +++ head/Tools/scripts/bump-revision.sh Fri Aug 22 07:13:51 2014 (r365612) @@ -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