From e54315b4bfe62ae54eb8ce80d0f8e8f2c374c9f0 Mon Sep 17 00:00:00 2001 From: Buddy Date: Tue, 14 Jan 2025 10:05:19 -0800 Subject: [PATCH] Update and refactory protoc --- dot_local/bin/executable_install-protoc-home | 58 ++++++-------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/dot_local/bin/executable_install-protoc-home b/dot_local/bin/executable_install-protoc-home index bb9445c..b7d4823 100755 --- a/dot_local/bin/executable_install-protoc-home +++ b/dot_local/bin/executable_install-protoc-home @@ -5,47 +5,19 @@ set -euo pipefail # shellcheck disable=SC1091 source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" -VERSION=${VERSION:-29.2} APP=protoc -APPS_DIR=${XDG_DATA_HOME}/apps/releases/${APP} -VER_DIR=${APPS_DIR}/${VERSION} +VERSION=${VERSION:-29.3} +DEST=${XDG_DATA_HOME}/apps/releases/${APP} 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 + 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() ( @@ -54,13 +26,17 @@ get_os() ( Darwin*) echo osx ;; *) echo >&2 "unsupported os" - return + exit 1 ;; esac ) get_arch() ( - uname -m + ARCH=$(uname -m) + if [[ $ARCH == arm64 ]]; then + ARCH=aarch_64 + fi + echo "$ARCH" ) -main "${@}" +main