Add install protoc home script and update utils for os x support
This commit is contained in:
parent
e2b639cc86
commit
2ed020fed3
@ -46,10 +46,11 @@ set_current_link () {
|
|||||||
version="${2}"
|
version="${2}"
|
||||||
sudo="${3}"
|
sudo="${3}"
|
||||||
current="${prefix}/current"
|
current="${prefix}/current"
|
||||||
if [ -s "${current}" ] ; then
|
if [ -L "${current}" ] ; then
|
||||||
$sudo unlink "${current}"
|
$sudo unlink "${current}"
|
||||||
fi
|
fi
|
||||||
$sudo ln --symbolic --relative "${prefix}/${version}" "${current}"
|
rel="$(relative_path "${prefix}" "${prefix}/${version}")"
|
||||||
|
$sudo ln -s "$rel" "${current}"
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_tarball () {
|
extract_tarball () {
|
||||||
|
|||||||
48
install-scripts/.local/bin/install-protoc-home
Executable file
48
install-scripts/.local/bin/install-protoc-home
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
||||||
|
|
||||||
|
VERSION=${VERSION:-3.15.6}
|
||||||
|
APP=protoc
|
||||||
|
APPS_DIR=${XDG_DATA_HOME}/buddy-up/apps/${APP}
|
||||||
|
VER_DIR=${APPS_DIR}/${VERSION}
|
||||||
|
|
||||||
|
OS=$(get_os)
|
||||||
|
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)
|
||||||
|
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}"
|
||||||
|
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 -perm +111 -type f -exec basename {} \;)
|
||||||
|
cd "${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
|
||||||
Loading…
Reference in New Issue
Block a user