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.

49 lines
1.5 KiB
Plaintext

#!/usr/bin/env bash
set -e
# shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
get_arch () {
case $(uname -m) in
x86_64*) echo x64;;
amd64*) echo x64;;
arm) echo armv7l;;
armv7*) echo armv7l;;
armv6*) echo armv7l;;
armv8*) echo arm64;;
aarch64*) echo arm64;;
*) >&2 echo "unsupported architecture: $(uname -m)"; exit 1;;
esac
}
VERSION=${VERSION:-v14.17.3}
DEST="${XDG_DATA_HOME}/apps/releases/node"
CURRENT="${DEST}/current"
URL=https://nodejs.org/dist/${VERSION}/node-${VERSION}-$(get_os)-$(get_arch).tar.xz
extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1"
set_current_link "${DEST}" "${VERSION}"
set_symlink () {
local src="$1"
local dest="$2"
dest_dir=$(dirname "${dest}")
mkdir_if_missing "${dest_dir}"
pushd "${dest_dir}" > /dev/null || exit 1
unlink_if_set "${dest}"
ln -s "$(relative_path "${dest_dir}" "${src}")" "$(basename "${dest}")"
popd > /dev/null || exit 1
}
for app in "${CURRENT}"/bin/*; do
set_symlink "${CURRENT}/bin/${app}" "${XDG_BIN_HOME}/${app}"
done
set_symlink "${CURRENT}/include/node" "${XDG_INCLUDE_HOME}/node"
set_symlink "${CURRENT}/share/doc/node" "${XDG_DATA_HOME}/doc/node"
set_symlink "${CURRENT}/share/man/man1/node.1" "${MAN_DIR}/node.1"
set_symlink "${CURRENT}/share/systemtap/tapset/node.stp" "${XDG_DATA_HOME}/systemtap/tapset/node.stp"