source: common/func_check_version.sh@ 0167dd8

experimental
Last change on this file since 0167dd8 was c88d594, checked in by George Boudreau <georgeb@…>, 18 years ago

Remove some dead code

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[1b9148c]1# $Id$
2
3check_version() {
4: <<inline_doc
5 Tests for a minimum version level. Compares to version numbers and forces an
6 exit if minimum level not met.
7 NOTE: This test will fail on versions containing alpha chars. ie. jpeg 6b
8
9 usage: check_version "2.6.2" "`uname -r`" "KERNEL"
10 check_version "3.0" "$BASH_VERSION" "BASH"
11 check_version "3.0" "`gcc -dumpversion`" "GCC"
12
13 input vars: $1=min acceptable version
14 $2=version to check
15 $3=app name
16 externals: --
17 modifies: --
18 returns: nothing
19 on error: write text to console and dies
20 on success: write text to console and returns
21inline_doc
22
23 declare -i major minor revision change
24 declare -i ref_major ref_minor ref_revision ref_change
25
26 ref_version=$1
27 tst_version=$2
28 TXT=$3
29
[12a5707]30 # This saves us the save/restore hassle of the system IFS value
31 local IFS
32
[1b9148c]33 write_error_and_die() {
34 echo -e "\n\t\t$TXT version -->${tst_version}<-- is too old.
35 This script requires ${ref_version} or greater\n"
36 exit 1
37 }
[e1edff3]38
39 echo -ne "$TXT:\t${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
[c88d594]40 IFS=".-(p" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
[1b9148c]41 set -- $ref_version # set postional parameters to minimum ver values
42 ref_major=$1; ref_minor=$2; ref_revision=$3
43 #
44 set -- $tst_version # Set postional parameters to test version values
45 major=$1; minor=$2; revision=$3
46 #
47 # Compare against minimum acceptable version..
48 (( major > ref_major )) && echo " ..OK" && return
49 (( major < ref_major )) && write_error_and_die
50 # major=ref_major
51 (( minor < ref_minor )) && write_error_and_die
52 (( minor > ref_minor )) && echo " ..OK" && return
53 # minor=ref_minor
54 (( revision >= ref_revision )) && echo " ..OK" && return
55
56 # oops.. write error msg and die
57 write_error_and_die
58}
59
Note: See TracBrowser for help on using the repository browser.