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.
37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
4 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
|
# shellcheck disable=SC1090
|
||
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
||
|
|
||
|
APP=helm
|
||
2 years ago
|
VERSION=${VERSION:-3.11.1}
|
||
4 years ago
|
DEST="${XDG_DATA_HOME}/apps/releases/${APP}"
|
||
|
|
||
|
if [[ ! -d "${DEST}/${VERSION}" ]]; then
|
||
|
DL_DIR="$(mktemp -d)"
|
||
|
SHA_PATH=${DL_DIR}/helm.tar.gz.sha256
|
||
|
TAR_PATH=${DL_DIR}/helm.tar.gz
|
||
|
|
||
4 years ago
|
URL_SHA=https://get.helm.sh/helm-v${VERSION}-$(get_os)-$(get_arch).tar.gz.sha256
|
||
|
URL_TAR=https://get.helm.sh/helm-v${VERSION}-$(get_os)-$(get_arch).tar.gz
|
||
4 years ago
|
curl --silent --location --output "${SHA_PATH}" "${URL_SHA}"
|
||
|
curl --silent --location --output "${TAR_PATH}" "${URL_TAR}"
|
||
|
|
||
|
if [[ $(cat "${SHA_PATH}") != $(openssl dgst -sha256 "${TAR_PATH}" | sed -e 's/^.* //') ]]; then
|
||
|
echo 'checksum does not match'
|
||
|
rm -rf "${DL_DIR}"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
mkdir_if_missing "${DEST}/${VERSION}"
|
||
|
tar xzf "${TAR_PATH}" --directory "${DEST}/${VERSION}" --strip-component 1
|
||
|
rm -rf "${DL_DIR}"
|
||
|
fi
|
||
|
|
||
|
set_current_link "${DEST}" "${VERSION}"
|
||
|
unlink_if_set "$XDG_BIN_HOME/${APP}"
|
||
|
|
||
|
cd "$XDG_BIN_HOME" || exit 1
|
||
|
ln -s "$(relative_path "${XDG_BIN_HOME}" "${DEST}/current/${APP}")" ${APP}
|
||
|
cd - >/dev/null || exit 1
|