Update protoc version

This commit is contained in:
Buddy Sandidge 2022-02-15 16:08:35 -08:00
parent ccee6c82e4
commit 404e3f71bd

View File

@ -1,33 +1,35 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -x
set -e set -e
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
VERSION=${VERSION:-3.15.6} get_os () (
case $(uname -s) in
Linux*) echo linux;;
Darwin*) echo osx;;
*) >&2 echo "unsupported os"; return;
esac
)
get_arch () (
uname -m
)
VERSION=${VERSION:-3.19.4}
APP=protoc APP=protoc
APPS_DIR=${XDG_DATA_HOME}/buddy-up/apps/${APP} APPS_DIR=${XDG_DATA_HOME}/apps/releases/${APP}
VER_DIR=${APPS_DIR}/${VERSION} VER_DIR=${APPS_DIR}/${VERSION}
OS=$(get_os) ZIP=protoc-${VERSION}-$(get_os)-$(get_arch).zip
if [[ $OS == darwin ]]; then
OS=osx
fi
ARCH=$(get_arch)
if [[ $ARCH == amd64 ]]; then
ARCH=x86_64
fi
ZIP=protoc-${VERSION}-${OS}-${ARCH}.zip
TMP_DIR=$(mktemp -d) TMP_DIR=$(mktemp -d)
DEST_FILE=$TMP_DIR/$ZIP DEST_FILE=$TMP_DIR/$ZIP
URL=https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/${ZIP} URL=https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/${ZIP}
if [[ ! -d "${VER_DIR}" ]]; then if [[ ! -d "${VER_DIR}" ]]; then
curl --output "${DEST_FILE}" --location "${URL}" curl --output "${DEST_FILE}" --location "${URL}"
mkdir -p "${VER_DIR}"
unzip -o "${DEST_FILE}" -d "${VER_DIR}" unzip -o "${DEST_FILE}" -d "${VER_DIR}"
find "${VER_DIR}" -type f -exec chmod 644 {} \; find "${VER_DIR}" -type f -exec chmod 644 {} \;
find "${VER_DIR}" -type d -exec chmod 755 {} \; find "${VER_DIR}" -type d -exec chmod 755 {} \;
@ -38,7 +40,7 @@ rm -rfv "$TMP_DIR"
set_current_link "${APPS_DIR}" "${VERSION}" set_current_link "${APPS_DIR}" "${VERSION}"
apps=$(find "${APPS_DIR}/current/bin" -maxdepth 1 -perm +111 -type f -exec basename {} \;) apps=$(find "${APPS_DIR}/current/bin" -maxdepth 1 -perm +111 -type f -exec basename {} \;)
cd "${XDG_BIN_HOME}" pushd "${XDG_BIN_HOME}"
for bin in $apps; do for bin in $apps; do
if [[ ! -s $bin ]]; then if [[ ! -s $bin ]]; then
ln -s \ ln -s \
@ -46,3 +48,12 @@ for bin in $apps; do
"${bin}" "${bin}"
fi fi
done done
popd
pushd "${XDG_INCLUDE_HOME}"
if [[ ! -s google ]]; then
ln -s \
"$(relative_path "${XDG_INCLUDE_HOME}" "${APPS_DIR}/current/include/google")" \
google
fi
popd