You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
882 B
Bash
43 lines
882 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# shellcheck disable=SC1091
|
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
|
|
|
APP=protoc
|
|
VERSION=${VERSION:-29.3}
|
|
DEST=${XDG_DATA_HOME}/apps/releases/${APP}
|
|
|
|
main() (
|
|
URL=https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-$(get_os)-$(get_arch).zip
|
|
XDG_INCLUDE_HOME="${XDG_INCLUDE_HOME:=$HOME/.local/include}"
|
|
mkdir_if_missing "${XDG_INCLUDE_HOME}"
|
|
|
|
extract_zip "${URL}" "${DEST}/${VERSION}"
|
|
set_current_link "${DEST}" "${VERSION}"
|
|
set_link "${XDG_BIN_HOME}/${APP}" "${DEST}" "bin/${APP}"
|
|
set_link "${XDG_INCLUDE_HOME}/google" "${DEST}" include/google
|
|
)
|
|
|
|
get_os() (
|
|
case $(uname -s) in
|
|
Linux*) echo linux ;;
|
|
Darwin*) echo osx ;;
|
|
*)
|
|
echo >&2 "unsupported os"
|
|
exit 1
|
|
;;
|
|
esac
|
|
)
|
|
|
|
get_arch() (
|
|
ARCH=$(uname -m)
|
|
if [[ $ARCH == arm64 ]]; then
|
|
ARCH=aarch_64
|
|
fi
|
|
echo "$ARCH"
|
|
)
|
|
|
|
main
|