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 )"
|
2023-09-15 18:04:20 +00:00
|
|
|
if [ -f ".protoc_version" ]; then
|
|
|
|
PROTOC_VERSION=$(cat ".protoc_version")
|
|
|
|
else
|
|
|
|
PROTOC_VERSION=$(cat "$SCRIPTDIR/../../.protoc_version")
|
|
|
|
fi
|
2023-09-15 15:45:12 +00: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-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
|
2023-08-13 17:25:15 +00:00
|
|
|
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
|
2023-08-13 17:25:15 +00:00
|
|
|
cp -r bin include /usr/local/
|
2022-11-03 00:42:07 +00:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
rm -rf /tmp/protoc-install
|
|
|
|
fi
|