veilid/scripts/earthly/install_protoc.sh

38 lines
1.1 KiB
Bash
Raw Normal View History

2022-11-03 00:42:07 +00:00
#!/bin/bash
2023-09-15 15:45:12 +00:00
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PROTOC_VERSION=$(cat "$SCRIPTDIR/../../.protoc_version")
UNAME_M=$(uname -m)
if [[ "$UNAME_M" == "x86_64" ]]; then
PROTOC_ARCH=x86_64
elif [[ "$UNAME_M" == "aarch64" ]]; then
PROTOC_ARCH=aarch_64
else
echo Unsupported build architecture
exit 1
fi
2022-11-03 00:42:07 +00:00
mkdir /tmp/protoc-install
pushd /tmp/protoc-install
2023-09-15 15:45:12 +00:00
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-$PROTOC_ARCH.zip
unzip protoc-$PROTOC_VERSION-linux-$PROTOC_ARCH.zip
2022-11-03 00:42:07 +00:00
if [ "$EUID" -ne 0 ]; then
if command -v checkinstall &> /dev/null; then
2023-09-15 15:45:12 +00:00
sudo checkinstall --pkgversion=$PROTOC_VERSION -y cp -r bin include /usr/local/
2022-11-03 00:42:07 +00:00
cp *.deb ~
else
sudo cp -r bin include /usr/local/
2022-11-03 00:42:07 +00:00
fi
popd
sudo rm -rf /tmp/protoc-install
else
if command -v checkinstall &> /dev/null; then
2023-09-15 15:45:12 +00:00
checkinstall --pkgversion=$PROTOC_VERSION -y cp -r bin include /usr/local/
2022-11-03 00:42:07 +00:00
cp *.deb ~
else
cp -r bin include /usr/local/
2022-11-03 00:42:07 +00:00
fi
popd
rm -rf /tmp/protoc-install
fi