From e9ad5d2cf449d893f61db1cc042bf939e0d878cb Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Fri, 4 Jun 2021 20:25:42 -0700 Subject: [PATCH] Add install shellcheck script --- .../.local/bin/install-shellcheck-home | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 install-scripts/.local/bin/install-shellcheck-home diff --git a/install-scripts/.local/bin/install-shellcheck-home b/install-scripts/.local/bin/install-shellcheck-home new file mode 100755 index 0000000..46e5688 --- /dev/null +++ b/install-scripts/.local/bin/install-shellcheck-home @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# shellcheck disable=SC1090 +source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" + +function get_os () { + case $(uname -s) in + Linux*) echo linux;; + Darwin*) echo darwin;; + *) >&2 echo "unsupported os: $(uname -s)"; exit 1;; + esac +} + +function get_arch () { + case $(uname -m) in + amd64*|x86_64*) echo x86_64;; + arm|armv7*|armv6*) echo armv6hf;; + aarch64*|armv8*) echo aarch64;; + *) >&2 echo "unsupported architecture: $(uname -m)"; exit 1;; + esac +} + +APP=shellcheck +DEST="${XDG_DATA_HOME}/apps/releases/${APP}" +CURRENT="${DEST}/current" +VERSION=${VERSION:-0.7.2} +URL=https://github.com/koalaman/shellcheck/releases/download/v${VERSION}/shellcheck-v${VERSION}.$(get_os).$(get_arch).tar.xz + +extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-components 1" +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}" "${CURRENT}/${APP}")" "${APP}" +cd - &> /dev/null || exit 1