From 622a8d725626f60ea97e8915277fdc81d46a0e89 Mon Sep 17 00:00:00 2001 From: Ding Xiang Fei Date: Wed, 23 May 2018 15:32:57 +0800 Subject: [PATCH] pin protoc to 3.5.1 --- install_protobuf.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/install_protobuf.sh b/install_protobuf.sh index 5491ce8..0a1432a 100644 --- a/install_protobuf.sh +++ b/install_protobuf.sh @@ -1,8 +1,22 @@ #!/usr/bin/bash set -e -if [ ! -d "$HOME/protobuf/lib" ]; then - wget https://github.com/google/protobuf/archive/v3.5.1.tar.gz - tar -xzvf v3.5.1.tar.gz - cd protobuf-3.5.1 && ./autogen.sh && ./configure --prefix=$HOME/protobuf && make && make install +check_protoc_version () { + version="libprotoc $1" + PROTOC="$HOME/protobuf/bin/protoc" + if [ -f $PROTOC ]; then + this_version=`$PROTOC --version` + return `[ "$version" = "$this_version" ]` + else + return 1 + fi +} + +if check_protoc_version '3.5.1'; then + echo protoc version 3.5.1 detected. + exit fi + +wget https://github.com/google/protobuf/archive/v3.5.1.tar.gz +tar -xzvf v3.5.1.tar.gz +cd protobuf-3.5.1 && ./autogen.sh && ./configure --prefix=$HOME/protobuf && make && make install