check_version.sh 930 Bytes
Newer Older
alain viari's avatar
alain viari committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#!/bin/csh -f
#
# check (gnu) software version
#
# usage: check_version.sh cmd version
#
#
set HERE = `dirname $0`
set ORG_HOME = $HERE/../..
set ORG_PORTNAME = `$ORG_HOME/config/guess_port`

set path = ($path $ORG_HOME/ports/$ORG_PORTNAME/bin)

if ($#argv != 2) then
  egrep "^# *usage:" $0 | sed -e 's/^# *//1'
  exit 1
endif

set name = `echo "$1" | awk '{print $1}'`

echo -n "+ checking $name"

set ok = `which $name`

if ($status != 0) then
  echo ""
  echo "* $name : command not found"
  echo "* please consider installing $name from src/_unix_tools_"
  exit 1
endif

set num = `eval "$1" | tr -d -C '[0-9].'`

echo -n " version $num"

awk -v NUM=$num -v REF=$2 -f $HERE/version.awk

if ($status != 0) then
  echo ""
  echo "* $name version $num (should be >= $2)"
  echo "* please consider installing $name from src/_unix_tools_"
  exit 2
endif

echo " (>= $2) OK"

exit 0