github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/protos/depcheck.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  
     5  readonly PROTOCMINVER="3.6.1"
     6  
     7  which protoc &>/dev/null || (echo "Error: protoc not found" ; exit 1)
     8  
     9  PROTOCVER=`protoc --version | awk '{printf $2}'`
    10  
    11  # CompareSemVer compares the minimum version minver against another version curver.
    12  # If the version is below our min it will exit with non-zero to trigger error in make.
    13  function CompareSemVer() {
    14  	local minver=(${1//./ })
    15  	local curver=(${2//./ })
    16  
    17  	echo "Checking for semantic version $1 or newer"
    18  
    19  	for i in 0 1 2; do
    20  		if [ ${minver[$i]} -gt ${curver[$i]} ]; then
    21  			echo "Error: version $2 is lower than the required version $1"
    22  			exit 1
    23  		elif [ ${curver[$i]} -gt ${minver[$i]} ]; then
    24  			break
    25  		fi
    26  	done
    27  }
    28  
    29  CompareSemVer $PROTOCMINVER $PROTOCVER
    30  
    31  # TODO: check proto api versions
    32  
    33  echo "OK"
    34  
    35  exit 0