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.
67 lines
1.4 KiB
Plaintext
67 lines
1.4 KiB
Plaintext
4 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
2 years ago
|
set -euo pipefail
|
||
4 years ago
|
|
||
2 years ago
|
# shellcheck disable=SC1091
|
||
4 years ago
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
||
|
|
||
2 years ago
|
VERSION=${VERSION:-23.1}
|
||
|
APP=protoc
|
||
|
APPS_DIR=${XDG_DATA_HOME}/apps/releases/${APP}
|
||
|
VER_DIR=${APPS_DIR}/${VERSION}
|
||
|
|
||
|
main() (
|
||
|
ZIP=protoc-${VERSION}-$(get_os)-$(get_arch).zip
|
||
|
TMP_DIR=$(mktemp -d)
|
||
|
DEST_FILE=$TMP_DIR/$ZIP
|
||
|
URL=https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/${ZIP}
|
||
|
|
||
|
if [[ ! -d ${VER_DIR} ]]; then
|
||
|
curl --output "${DEST_FILE}" --location "${URL}"
|
||
|
mkdir -p "${VER_DIR}"
|
||
|
unzip -o "${DEST_FILE}" -d "${VER_DIR}"
|
||
|
find "${VER_DIR}" -type f -exec chmod 644 {} \;
|
||
|
find "${VER_DIR}" -type d -exec chmod 755 {} \;
|
||
|
find "${VER_DIR}/bin" -type f -exec chmod 755 {} \;
|
||
|
fi
|
||
|
rm -rfv "$TMP_DIR"
|
||
|
|
||
|
set_current_link "${APPS_DIR}" "${VERSION}"
|
||
|
|
||
|
apps=$(find "${APPS_DIR}/current/bin" -maxdepth 1 -type f -exec basename {} \;)
|
||
|
pushd "${XDG_BIN_HOME}"
|
||
|
for bin in $apps; do
|
||
|
if [[ ! -s $bin ]]; then
|
||
|
ln -s \
|
||
|
"$(relative_path "${XDG_BIN_HOME}" "${APPS_DIR}/current/bin/${bin}")" \
|
||
|
"${bin}"
|
||
|
fi
|
||
|
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
|
||
3 years ago
|
)
|
||
4 years ago
|
|
||
2 years ago
|
get_os() (
|
||
|
case $(uname -s) in
|
||
|
Linux*) echo linux ;;
|
||
|
Darwin*) echo osx ;;
|
||
|
*)
|
||
|
echo >&2 "unsupported os"
|
||
|
return
|
||
|
;;
|
||
|
esac
|
||
3 years ago
|
)
|
||
4 years ago
|
|
||
2 years ago
|
get_arch() (
|
||
|
uname -m
|
||
|
)
|
||
4 years ago
|
|
||
2 years ago
|
main "${@}"
|