...
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#
21set -eu -o pipefail
22
23PROTOBUF_VERSION=3.20.1
24GOARCH=$(go env GOARCH)
25GOOS=$(go env GOOS)
26PROTOBUF_DIR=$(mktemp -d)
27
28case $GOARCH in
29
30arm64)
31 wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-aarch64.zip"
32 unzip "$PROTOBUF_DIR/protobuf" -d /usr/local
33 ;;
34
35amd64|386)
36 if [ "$GOOS" = windows ]; then
37 wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/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/protocolbuffers/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
44ppc64le)
45 wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/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/protocolbuffers/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 ;;
59esac
60rm -rf "$PROTOBUF_DIR"
View as plain text