From owner-svn-ports-all@FreeBSD.ORG Thu Jun 26 17:15:39 2014 Return-Path: Delivered-To: svn-ports-all@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 C0F88915; Thu, 26 Jun 2014 17:15:39 +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 9426F235F; Thu, 26 Jun 2014 17:15:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5QHFdi8003697; Thu, 26 Jun 2014 17:15:39 GMT (envelope-from robak@svn.freebsd.org) Received: (from robak@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5QHFdIJ003696; Thu, 26 Jun 2014 17:15:39 GMT (envelope-from robak@svn.freebsd.org) Message-Id: <201406261715.s5QHFdIJ003696@svn.freebsd.org> From: Bartek Rutkowski Date: Thu, 26 Jun 2014 17:15:39 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r359402 - 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-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2014 17:15:39 -0000 Author: robak Date: Thu Jun 26 17:15:39 2014 New Revision: 359402 URL: http://svnweb.freebsd.org/changeset/ports/359402 QAT: https://qat.redports.org/buildarchive/r359402/ Log: New script: Tools/scripts/bump-revision.sh This script, requested by bapt@, is a pure sh tool to increase one or more ports PORTREVISION value or to add one, if the port havent had one already. Approved by: swills (mentor), bapt Added: head/Tools/scripts/bump-revision.sh (contents, props changed) Added: head/Tools/scripts/bump-revision.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/Tools/scripts/bump-revision.sh Thu Jun 26 17:15:39 2014 (r359402) @@ -0,0 +1,66 @@ +#!/bin/sh + +# +# bump-revision.sh category/portname category/portname ... +# Bump PORTREVISION if it exists or create it with number 1 if it does not +# +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp): +# Bartek Rutkowski wrote this file. As long as you retain +# this notice you can do whatever you want with this stuff. If we meet some +# day, and you think this stuff is worth it, you can buy me a beer in return. +# +# Bartek Rutkowski +# ---------------------------------------------------------------------------- +# +# $FreeBSD$ +# +# MAINTAINER= robak@FreeBSD.org + +# +# functions +# + +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 + echo -e "\033[1;31m$1\033[m" + elif [ $2 == "green" ]; then + echo -e "\033[1;32m$1\033[m" + else + echo "$1" + fi + fi + else + echo $1 + fi +} + +# +# main loop +# + +tempfile=$(mktemp) +trap "rm -f $tempfile" 0 1 2 3 15 + +while [ $# -gt 0 ] +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 + else + printc "$1: might not be a port directory as $1/Makefile is missing!" "red" + fi + shift +done