github.com/containerd/containerd@v22.0.0-20200918172823-438c87b8e050+incompatible/script/setup/install-protobuf (about)

     1  #!/usr/bin/env bash
     2  
     3  #   Copyright The containerd Authors.
     4  
     5  #   Licensed under the Apache License, Version 2.0 (the "License");
     6  #   you may not use this file except in compliance with the License.
     7  #   You may obtain a copy of the License at
     8  
     9  #       http://www.apache.org/licenses/LICENSE-2.0
    10  
    11  #   Unless required by applicable law or agreed to in writing, software
    12  #   distributed under the License is distributed on an "AS IS" BASIS,
    13  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  #   See the License for the specific language governing permissions and
    15  #   limitations under the License.
    16  
    17  
    18  #
    19  # Downloads and installs protobuf
    20  #
    21  set -eu -o pipefail
    22  
    23  PROTOBUF_VERSION=3.11.4
    24  GOARCH=$(go env GOARCH)
    25  GOOS=$(go env GOOS)
    26  PROTOBUF_DIR=$(mktemp -d)
    27  
    28  case $GOARCH in
    29  
    30  arm64)
    31  	wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-aarch64.zip"
    32  	unzip $PROTOBUF_DIR/protobuf -d /usr/local
    33  	;;
    34  
    35  amd64|386)
    36  	if [ "$GOOS" = windows ]; then
    37  		wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-win32.zip"
    38  	elif [ "$GOOS" = linux ]; then
    39  		wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip"
    40  	fi
    41  	unzip $PROTOBUF_DIR/protobuf -d /usr/local
    42  	;;
    43  
    44  ppc64le)
    45  	wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-ppcle_64.zip"
    46  	unzip $PROTOBUF_DIR/protobuf -d /usr/local
    47  	;;
    48  *)
    49  	wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-cpp-$PROTOBUF_VERSION.zip"
    50  	unzip $PROTOBUF_DIR/protobuf -d /usr/src/protobuf
    51  	cd /usr/src/protobuf/protobuf-$PROTOBUF_VERSION
    52  	./autogen.sh
    53  	./configure --disable-shared
    54  	make
    55  	make check
    56  	make install
    57  	ldconfig
    58  	;;
    59  esac
    60  rm -rf $PROTOBUF_DIR