[beast] mkrelease.sh: implemented 'shellvar' command to extract configure.in versions



commit 412822f0a1bc4b1dd5f6ff1760eb227f49184171
Author: Tim Janik <timj gtk org>
Date:   Tue Aug 31 23:59:00 2010 +0200

    mkrelease.sh: implemented 'shellvar' command to extract configure.in versions

 mkrelease.sh |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/mkrelease.sh b/mkrelease.sh
index 96d3baf..0fa2a04 100755
--- a/mkrelease.sh
+++ b/mkrelease.sh
@@ -3,7 +3,8 @@
 #
 ## This work is provided "as is"; see: http://rapicorn.org/LICENSE-AS-IS
 
-MYVERSION="mkrelease.sh version 20100827"
+MYVERSION="mkrelease.sh version 20100831"
+# 20100831: implemented 'shellvar' command
 # 20100827: implemented 'news' command
 # 20100421: added tagging, even revision checking and revision bumping
 # 20100420: implemented rsync based 'upload' for release tarballs
@@ -34,10 +35,12 @@ usage() {
 	  ChangeLog		generate ChangeLog from git history
 	  news			list commits since last release tag
 	  upload		check and upload release tarball
+	  shellvar <FILE:VAR>	shell-eval VAR variable assignment in FILE
 	Options:
 	  -h, --help		usage help
 	  -v, --version		issue version and brief history
-	  -E <revisionvar>	variable to increment (e.g. configure.ac:MICRO)
+	  -E <FILE:VAR>         revision variable to increment during "upload"
+	                        (e.g. configure.ac:MICRO)
 	  -R <revision>		revision range for "ChangeLog" generation
 	                        last release revision for "news" (auto)
 	  -T <disttarball>	name of distribution tarball (from Makefile)
@@ -64,7 +67,13 @@ while test $# -ne 0 -a $parse_options = 1; do
     -V)		VERSION="$2" ; shift ;;
     -v|--version) echo "$MYVERSION" ; exit 0 ;;
     --)		parse_options=0 ;;
-    *)		[ -z "$COMMAND" ] || usage 1 ; COMMAND="$1" ;;
+    *)		[ -z "$COMMAND" ] || usage 1
+		COMMAND="$1"
+		[ "$COMMAND" = shellvar ] && {
+		  shift
+		  [ $# -ge 1 ] || usage 1
+		  SHELLVAR="$1"
+		} ;;
   esac
   shift
 done
@@ -280,5 +289,24 @@ done
   exit
 }
 
+# === shellvar ===
+[ "$COMMAND" = "shellvar" ] && {
+  ECHO_N=echo\ -n
+  test -t 1 && ECHO_N=echo # include trailing newline on terminals
+  # extract file from SHELLVAR
+  SHELLVAR_FILE=`printf "%s" "$SHELLVAR" | sed -e 's/:.*//'`
+  SHELLVAR_NAME=`printf "%s" "$SHELLVAR" | sed -ne '/:/ { s/[^:]*:// ; p ; q }'`
+  [ -z "$SHELLVAR_FILE" ] && die 3 "Failed to extract file from: $SHELLVAR"
+  [ -z "$SHELLVAR_NAME" ] && die 3 "Failed to extract variable from: $SHELLVAR"
+  [ -r "$SHELLVAR_FILE" ] || die 3 "Failed to read file: $SHELLVAR_FILE"
+  sed -n "/^\s*$SHELLVAR_NAME=/{p;q}" "$SHELLVAR_FILE" | grep -q . \
+    || die 3 "$SHELLVAR_FILE: Failed to detect variable assignment: $SHELLVAR_NAME="
+  ( echo "set -e"
+    sed -n "/^\s*[A-Za-z][A-Za-z0-9_]\+=/p; /^\s*$SHELLVAR_NAME=/q" "$SHELLVAR_FILE" \
+    && echo $ECHO_N \"\$"$SHELLVAR_NAME"\" ) | "$SHELL" \
+      || die 3 "$SHELLVAR_FILE: Error while evaluating variable assignments for: $SHELLVAR_NAME="
+  exit
+}
+
 # === missing command ===
 usage 1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]