Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Aug 2016 13:27:47 +0000 (UTC)
From:      Mathieu Arnold <mat@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r419519 - head/Tools/scripts
Message-ID:  <201608031327.u73DRlST095050@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mat
Date: Wed Aug  3 13:27:47 2016
New Revision: 419519
URL: https://svnweb.freebsd.org/changeset/ports/419519

Log:
  fixup last updates, and try to be better with slave ports.
  
  the case $? needs to have the exit status of the grep, not the awk line,
  so remove the awk line, it was not really helpful anyway.
  
  Also, with slave ports, most of the time, they don't have
  (PORT|DIST)VERSION,  try to use CATEGORIES, PKGNAMEPREFIX or
  PKGNAMESUFFIX.
  
  PR:		211243
  Submitted by:	mat
  Approved by:	maintainer timeout
  Sponsored by:	Absolight

Modified:
  head/Tools/scripts/bump-revision.sh

Modified: head/Tools/scripts/bump-revision.sh
==============================================================================
--- head/Tools/scripts/bump-revision.sh	Wed Aug  3 13:01:15 2016	(r419518)
+++ head/Tools/scripts/bump-revision.sh	Wed Aug  3 13:27:47 2016	(r419519)
@@ -51,7 +51,6 @@ do
         # 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)
@@ -65,7 +64,7 @@ do
                         ;;
                     (*)
                         # If the value of PORTREVISION is an integer, increase it by 1
-                        printc "INFO: $1 PORTREVISION= $revision_num found, bumping it by 1." "green"
+                        printc "INFO: $1 $revision_str 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"
@@ -80,8 +79,19 @@ do
             # 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"
+            && cat $tempfile > "$1/Makefile"
+            # If there is not PORTREVISION line, maybe it is a slave port, try
+            # to add it before a CATEGORIES, PKGNAMESUFFIX or PKGNAMEPREFIX line:
+            for line in CATEGORIES PKGNAMEPREFIX PKGNAMESUFFIX; do
+                    if ! grep -q "^PORTREVISION?\?=" $1/Makefile; then
+                            rm -f $tempfile && awk '/^'${line}'\??=\t/{ print "PORTREVISION=\t1"; print; next } { print }' "$1/Makefile" > $tempfile \
+                                    && cat $tempfile > "$1/Makefile"
+                    fi
+            done
+            # If it still is not there, bail out
+            if ! grep -q "^PORTREVISION?\?=" $1/Makefile; then
+                    printc "ERROR: $1 PORTREVISION not found and failed to add it!" "red"
+            fi
             ;;
         *)
             printc "ERROR: PORTREVISION grep for $1 exited with error!" "red"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608031327.u73DRlST095050>