1#!/usr/bin/env bash 2# Copyright 2015 The TensorFlow Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================== 16 17# Install protobuf3. 18 19# Select protobuf version. 20PROTOBUF_VERSION="3.6.1" 21protobuf_ver_flat=$(echo $PROTOBUF_VERSION | sed 's/\.//g' | sed 's/^0*//g') 22local_protobuf_ver=$(protoc --version) 23local_protobuf_ver_flat=$(echo $local_protobuf_ver | sed 's/\.//g' | sed 's/^0*//g') 24if [[ -z $local_protobuf_ver_flat ]]; then 25 local_protobuf_ver_flat=0 26fi 27if (( $local_protobuf_ver_flat < $protobuf_ver_flat )); then 28 set -e 29 PROTOBUF_URL="https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" 30 PROTOBUF_ZIP=$(basename "${PROTOBUF_URL}") 31 UNZIP_DEST="google-protobuf" 32 33 wget "${PROTOBUF_URL}" 34 unzip "${PROTOBUF_ZIP}" -d "${UNZIP_DEST}" 35 cp "${UNZIP_DEST}/bin/protoc" /usr/local/bin/ 36 37 rm -f "${PROTOBUF_ZIP}" 38 rm -rf "${UNZIP_DEST}" 39fi 40