29 lines
1.4 KiB
Bash
Raw Normal View History

get_protobuf_tag() {
if [ "$protobuf_tag" = "latest" ]; then
2022-05-26 10:21:36 +05:30
protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "tag/(v[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
else
2020-11-11 02:23:45 +05:30
status_code=$(get -v -n /tmp/protobuf.tmp "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
if [ "$status_code" = "200" ]; then
protobuf_tag="v$protobuf_tag"
else
2022-05-26 10:21:36 +05:30
protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "tag/(v[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
fi
fi
}
add_protoc() {
protobuf_tag=$1
get_protobuf_tag
(
platform='linux'
[ "$(uname -s)" = "Darwin" ] && platform='osx'
2020-11-11 02:23:45 +05:30
get -q -n /tmp/protobuf.zip "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-x86_64.zip"
sudo unzip /tmp/protobuf.zip -d /usr/local/
2021-05-31 07:19:10 +05:30
sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
) >/dev/null 2>&1
2020-09-28 10:58:02 +05:30
add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
echo "$END_GROUP"
}