summaryrefslogtreecommitdiff
path: root/chkver
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-20 15:09:31 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2016-08-20 15:09:31 +0200
commit143bfc9f801c84428074312d661f8e08803df83b (patch)
tree59a8a447529bd9ce3807aa8bacef861dc5aafd70 /chkver
parent29a7aef998e975b42401cfa96d1b750d91eadf06 (diff)
Imported Upstream version 0.23.5upstream/0.23.5
Diffstat (limited to 'chkver')
-rwxr-xr-xchkver119
1 files changed, 0 insertions, 119 deletions
diff --git a/chkver b/chkver
deleted file mode 100755
index 6e3f921..0000000
--- a/chkver
+++ /dev/null
@@ -1,119 +0,0 @@
-#! /bin/bash
-#
-# Copyright 2016 Software Freedom Conservancy Inc.
-#
-# This software is licensed under the GNU LGPL (version 2.1 or later).
-# See the COPYING file in this distribution.
-#
-# chkver <min | max> <major.minor.revision> <min|max major.minor.revision>
-#
-# Returns 0 if queried version is greater than or equal (for min) or lesser than (for max) the
-# supplied value, or 1 otherwise.
-#
-# Set VERBOSE environment variable for somewhat useful output.
-#
-# NOTE:
-# This is an ultra-naive implementation with just enough error-checking.
-
-usage() {
- echo 'usage: chkver <min | max> <major.minor.revision> <min|max major.minor.revision>'
-}
-
-abort() {
- usage
- exit 1
-}
-
-verify_cardinal() {
- while [ $# != 0 ]
- do
- if [ $1 ] && [ $1 -eq $1 2> /dev/null ] && [ $1 -ge 0 ]
- then
- :
- else
- abort
- fi
-
- shift
- done
-}
-
-# check_min name number min-number
-check_min() {
- if [ $2 -gt $3 ]
- then
- verbose $1 large enough.
- exit 0
- elif [ $2 -lt $3 ]
- then
- verbose $1 not large enough.
- exit 1
- fi
-}
-
-# check_max name number max-number
-check_max() {
- if [ $2 -lt $3 ]
- then
- verbose $1 small enough.
- exit 0
- elif [ $2 -gt $3 ]
- then
- verbose $1 not small enough.
- exit 1
- fi
-}
-
-verbose() {
- if [ $VERBOSE ]
- then
- echo $*
- fi
-}
-
-# Check number of arguments
-if [ $# -lt 3 ]
-then
- abort
-fi
-
-# Parse arguments
-mode=$1
-if [ $mode != "min" ] && [ $mode != "max" ]
-then
- abort
-fi
-
-major=`echo $2 | awk -F. '{print $1}'`
-minor=`echo $2 | awk -F. '{print $2}'`
-revision=`echo $2 | awk -F. '{print $3}'`
-
-min_major=`echo $3 | awk -F. '{print $1}'`
-min_minor=`echo $3 | awk -F. '{print $2}'`
-min_revision=`echo $3 | awk -F. '{print $3}'`
-
-# Verify they're all positive integers
-verify_cardinal "$major" "$minor" "$revision" "$min_major" "$min_minor" "$min_revision"
-
-verbose Comparing $major.$minor.$revision against $mode $min_major.$min_minor.$min_revision
-
-# check version numbers in order of importance
-if [ $mode == "min" ]
-then
- check_min "Major" $major $min_major
- check_min "Minor" $minor $min_minor
- check_min "Revision" $revision $min_revision
-else
- check_max "Major" $major $min_major
- check_max "Minor" $minor $min_minor
- check_max "Revision" $revision $min_revision
-fi
-
-verbose Same version.
-if [ $mode == "min" ]
-then
- exit 0
-else
- exit 1
-fi
-