From owner-svn-ports-head@FreeBSD.ORG Wed Mar 4 23:22:00 2015 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.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2777F2FD; Wed, 4 Mar 2015 23:22:00 +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 084AC279; Wed, 4 Mar 2015 23:22:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t24NLxWc049643; Wed, 4 Mar 2015 23:21:59 GMT (envelope-from robak@FreeBSD.org) Received: (from robak@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t24NLx42049642; Wed, 4 Mar 2015 23:21:59 GMT (envelope-from robak@FreeBSD.org) Message-Id: <201503042321.t24NLx42049642@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: robak set sender to robak@FreeBSD.org using -f From: Bartek Rutkowski Date: Wed, 4 Mar 2015 23:21:59 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r380455 - 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: Wed, 04 Mar 2015 23:22:00 -0000 Author: robak Date: Wed Mar 4 23:21:59 2015 New Revision: 380455 URL: https://svnweb.freebsd.org/changeset/ports/380455 QAT: https://qat.redports.org/buildarchive/r380455/ Log: Tools/scripts/bump-revision.sh: fix regression introduced in r380431 - Fix regression mistakenly introduced in r380431 - Handle multiple tabs in PORTREVISION - Handle PORTREVISION being a variable name - Handle multiple PORTREVISION values - Get rid of bash-like syntax - Grammar corrections PR: 192910 Reviewed by: danfe, mandree, mat Modified: head/Tools/scripts/bump-revision.sh Modified: head/Tools/scripts/bump-revision.sh ============================================================================== --- head/Tools/scripts/bump-revision.sh Wed Mar 4 23:20:47 2015 (r380454) +++ head/Tools/scripts/bump-revision.sh Wed Mar 4 23:21:59 2015 (r380455) @@ -25,9 +25,9 @@ printc () { # $1 - msg is obligatory, $2 - color (red/green)of the message, default if not passed if [ -t 1 ]; then if [ $# -eq 2 ]; then - if [ $2 == "red" ]; then + if [ $2 = "red" ]; then echo -e "\033[1;31m$1\033[m" - elif [ $2 == "green" ]; then + elif [ $2 = "green" ]; then echo -e "\033[1;32m$1\033[m" else echo "$1" @@ -48,40 +48,49 @@ trap "rm -f $tempfile" 0 1 2 3 15 while [ $# -gt 0 ] do if [ -f "$1/Makefile" ]; then - # If the Makefile exists, continue and empty the tempfile - echo -n > $tempfile - revision=`grep "^PORTREVISION?\?=" "$1/Makefile"` - if [ $? == 0 ]; then + # If the Makefile exists, continue and empty the tempfile, set up variables + echo -n > $tempfile + revision_str=`grep "^PORTREVISION?\?=" "$1/Makefile"` + revision_num=`echo "$revision_str" | awk -F "\t+" '{ print $2 }'` + + case $? in + 0) # If the exit code is 0, then PORTREVISION line was found - if [ `echo "$revision" | wc -l` == 1 ]; then - # If the $revision variable has only 1 line, then proceed with processing it - case `echo "$revision" | awk -F "\t+" '{ print $2}'` in + if [ `echo "$revision_str" | wc -l` = 1 ]; then + # If the $revision_str variable has only 1 line, then proceed with processing it + case `echo "$revision_str" | awk -F "\t+" '{ print $2 }'` in (*[^0-9]*|'') - # If the value of PORTREVISION is not an integer, we cant bump its value + # If the value of PORTREVISION is not an integer, we can't bump its value printc "ERROR: $1 PORTREVISION value is not a number, unable to solve!" "red" ;; (*) # If the value of PORTREVISION is an integer, increase it by 1 - printc "INFO: $1 $revision found, bumping it by 1." "green" - awk -F "\t+" '/^PORTREVISION\??=/{ gsub ($2,$2+1) };{ print }' "$1/Makefile" > $tempfile \ + printc "INFO: $1 PORTREVISION= $revision_num found, bumping it by 1." "green" + rm -f $tempfile && awk -F "\t+" '/^PORTREVISION\??=/{ gsub ($2, $2+1) }; { print }' "$1/Makefile" > $tempfile \ && cat $tempfile > "$1/Makefile" \ || printc "ERROR: $1 PORTREVISION found but failed to bump it!" "red" ;; esac else - # If the $revision variable had more than 1 line, we cant bump its value reliably - printc "ERROR: $1 PORTREVISION found more than once, unable to solve!" "red" + # If the $revision_str variable had more than 1 line, we can't bump its value safely + printc "ERROR: $1 PORTREVISION found more than once, unable to bump it reliably!" "red" fi - else - # There was no PORTREVISION line, so we need to add one with value of 1 - printc "INFO: $1 PORTREVISION not found, adding PORTREVISION=1" "green" - awk '/^(PORT|DIST)VERSION\??=\t/{print;print "PORTREVISION=\t1";next} {print}' "$1/Makefile" > $tempfile \ + ;; + 1) + # If the exit code is 1 then PORTREVISION wasn't found, so we need to add one with value of 1 + printc "INFO: $1 PORTREVISION not found, adding PORTREVISION= 1" "green" + rm -f $tempfile && awk '/^(PORT|DIST)VERSION\??=\t/{ print; print "PORTREVISION=\t1"; next } { print }' "$1/Makefile" > $tempfile \ && cat $tempfile > "$1/Makefile" \ || printc "ERROR: $1 PORTREVISION found but failed to bump it!" "red" - fi + ;; + *) + printc "ERROR: PORTREVISION grep for $1 exited with error!" "red" + ;; + esac else # The directory specified had no Makefile, so it seems like a mistake - printc "ERROR: $1 might not be a port directory as $1/Makefile is missing!" "red" + printc "ERROR: $1 might not be a port directory because $1/Makefile is missing!" "red" fi shift done +