veilid/scripts/earthly/install_protoc.sh

42 lines
1.2 KiB
Bash
Raw Normal View History

2022-11-02 20:42:07 -04:00
#!/bin/bash
2023-09-15 11:45:12 -04:00
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2023-09-15 14:04:20 -04:00
if [ -f ".protoc_version" ]; then
PROTOC_VERSION=$(cat ".protoc_version")
else
PROTOC_VERSION=$(cat "$SCRIPTDIR/../../.protoc_version")
fi
2023-09-15 11:45:12 -04:00
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-02 20:42:07 -04:00
mkdir /tmp/protoc-install
pushd /tmp/protoc-install
2023-09-15 11:45:12 -04: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-02 20:42:07 -04:00
if [ "$EUID" -ne 0 ]; then
if command -v checkinstall &> /dev/null; then
2023-09-15 11:45:12 -04:00
sudo checkinstall --pkgversion=$PROTOC_VERSION -y cp -r bin include /usr/local/
2022-11-02 20:42:07 -04:00
cp *.deb ~
else
sudo cp -r bin include /usr/local/
2022-11-02 20:42:07 -04:00
fi
popd
sudo rm -rf /tmp/protoc-install
else
if command -v checkinstall &> /dev/null; then
2023-09-15 11:45:12 -04:00
checkinstall --pkgversion=$PROTOC_VERSION -y cp -r bin include /usr/local/
2022-11-02 20:42:07 -04:00
cp *.deb ~
else
cp -r bin include /usr/local/
2022-11-02 20:42:07 -04:00
fi
popd
rm -rf /tmp/protoc-install
fi