#!/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