aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/check-version
diff options
context:
space:
mode:
authorGravatar Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>2013-05-09 00:55:44 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-09 08:19:58 -0700
commitde101410cff3ecf1421c691799b8ad26e6bbff97 (patch)
tree91895f7e0003e52dc6a612cbc136608073626982 /scripts/check-version
parenta5b868700326a81bcb26d38cdc5e2b63cc445672 (diff)
downloadsubsurface-de101410cff3ecf1421c691799b8ad26e6bbff97.tar.gz
A lame start for a `make release' helper.
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'scripts/check-version')
-rwxr-xr-xscripts/check-version77
1 files changed, 77 insertions, 0 deletions
diff --git a/scripts/check-version b/scripts/check-version
new file mode 100755
index 000000000..82d2f3498
--- /dev/null
+++ b/scripts/check-version
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+# $1 - version string
+# options:
+# -c colored grep
+# -d debug
+# -r release (exit status error; when called from Makefile)
+
+set -eu
+#set -x
+
+files="Documentation/user-manual.txt Makefile README ReleaseNotes.txt"
+
+whine() {
+ echo "$0: $*" >&2
+}
+
+croak() {
+ whine "$*"
+ exit 1
+}
+
+color=n
+debug=n
+release=n
+while getopts cdr opt; do
+ case $opt in
+ c)
+ color=y
+ ;;
+ d)
+ debug=y
+ ;;
+ r)
+ release=y
+ ;;
+ *)
+ croak "invalid option"
+ ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+if [ $debug = y ]; then
+ opts=-n
+else
+ opts=-q
+fi
+[ $color = n ] || opts="${opts:+ }--color"
+
+v=${1:-}
+case $v in
+ *-*)
+ # Ignore development versions
+ if [ $release = y ]; then
+ croak "'$v' not a release tag"
+ else
+ exit 0
+ fi
+ ;;
+ ''|*[!.0-9]*)
+ croak "invalid version string '$v'"
+ ;;
+esac
+
+sts=0
+whine "checking for version $v"
+for f in $files; do
+ grep $opts -EHio "(VERSION=|subsurface[[:blank:]]+)?\<v?$v\>" $f || {
+ msg="'$f' may need updating"
+ if [ $release = y ]; then
+ croak "$msg"
+ else
+ whine "$msg"
+ fi
+ }
+done