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.
57 lines
1.5 KiB
Bash
57 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# shellcheck disable=SC1090
|
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
|
|
|
VERSION=${VERSION:-v1.26.1}
|
|
DEST=${XDG_DATA_HOME}/apps/releases/buf
|
|
CURRENT=${DEST}/current
|
|
URL=https://github.com/bufbuild/buf/releases/download/${VERSION}/buf-$(uname)-$(uname -m).tar.gz
|
|
|
|
main () (
|
|
extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1"
|
|
set_current_link "${DEST}" "${VERSION}"
|
|
|
|
symlink_apps
|
|
symlink_man_pages
|
|
|
|
set_symlink \
|
|
"${XDG_CONFIG_HOME}/bash/bashrc.d" buf.sh \
|
|
"${CURRENT}/etc/bash_completion.d" buf
|
|
set_symlink "${XDG_DATA_HOME}/zsh/site-functions" _buf \
|
|
"${CURRENT}/share/zsh/site-functions" _buf
|
|
set_symlink "${XDG_DATA_HOME}/fish/vendor_completions.d" buf.fish \
|
|
"${CURRENT}/share/fish/vendor_completions.d" buf.fish
|
|
)
|
|
|
|
symlink_apps () (
|
|
APPS=$(find "${DEST}/${VERSION}/bin" -type f -exec basename {} ';')
|
|
for APP in ${APPS}; do
|
|
set_symlink "${XDG_BIN_HOME}" "${APP}" "${CURRENT}/bin" "${APP}"
|
|
done
|
|
)
|
|
|
|
symlink_man_pages () (
|
|
MANS=$(find "${DEST}/${VERSION}/share/man/man1" -type f -exec basename {} ';')
|
|
for SHARE in ${MANS}; do
|
|
set_symlink "${MAN_DIR}" "${SHARE}" "${CURRENT}/share/man/man1" "${SHARE}"
|
|
done
|
|
)
|
|
|
|
set_symlink () (
|
|
dest_dir=$1
|
|
dest_file=$2
|
|
src_dir=$3
|
|
src_file=$4
|
|
|
|
mkdir_if_missing "${dest_dir}"
|
|
cd "${dest_dir}" || exit 1
|
|
unlink_if_set "${dest_dir}/${dest_file}"
|
|
ln -s "$(relative_path "${dest_dir}" "${src_dir}/${src_file}")" "${dest_file}"
|
|
cd - > /dev/null || exit 1
|
|
)
|
|
|
|
main "$@"
|