95 lines
1.8 KiB
Bash
95 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# user/id-mrjk ellipsis package
|
|
|
|
|
|
ELLIPSIS_SHELL_BIN="$HOME/.local/bin"
|
|
ELLIPSIS_SHELL_=
|
|
|
|
detect_platform() {
|
|
local kernel= machine=
|
|
|
|
kernel=$(uname -s | tr "[:upper:]" "[:lower:]")
|
|
case "${kernel}" in
|
|
mingw*)
|
|
kernel=windows
|
|
;;
|
|
esac
|
|
case "$(uname -m)" in
|
|
x86_64)
|
|
machine=amd64
|
|
;;
|
|
i686 | i386)
|
|
machine=386
|
|
;;
|
|
aarch64 | arm64)
|
|
machine=arm64
|
|
;;
|
|
*)
|
|
>&2 echo "Machine $(uname -m) not supported by the installer.\n" \
|
|
"Go to https://direnv for alternate installation methods."
|
|
return 1
|
|
;;
|
|
esac
|
|
|
|
echo "machine='$machine'; kernel='$kernel';"
|
|
}
|
|
|
|
get_github_release () {
|
|
local repo=$1
|
|
local pattern=$2
|
|
local version=${3:-latest}
|
|
|
|
if [[ -n "${version:-}" ]]; then
|
|
gh_url_suffix="tags/${version}"
|
|
else
|
|
gh_url_suffix="latest"
|
|
fi
|
|
|
|
download_url=$(
|
|
curl -fL "https://api.github.com/repos/direnv/direnv/releases/$gh_url_suffix" \
|
|
| grep browser_download_url \
|
|
| cut -d '"' -f 4 \
|
|
| grep "$pattern"
|
|
)
|
|
|
|
}
|
|
|
|
# The following hooks can be defined to customize behavior of your package:
|
|
pkg.install() {
|
|
fs.link_files $PKG_PATH
|
|
|
|
eval "$(detect_platform)"
|
|
download_url=$(get_github_release direnv/direnv "direnv.$kernel.$machine" latest)
|
|
|
|
#download_url=$(
|
|
# curl -fL "https://api.github.com/repos/direnv/direnv/releases/$gh_url_suffix" \
|
|
# | grep browser_download_url \
|
|
# | cut -d '"' -f 4 \
|
|
# | grep "direnv.$kernel.$machine"
|
|
#)
|
|
|
|
mkdir -p "$ELLIPSIS_SHELL_BIN"
|
|
curl -o "$ELLIPSIS_SHELL_BIN/direnv" -fL "$download_url"
|
|
chmod a+x "$ELLIPSIS_SHELL_BIN/direnv"
|
|
set +x
|
|
|
|
}
|
|
|
|
# pkg.push() {
|
|
# git.push
|
|
# }
|
|
|
|
# pkg.pull() {
|
|
# git.pull
|
|
# }
|
|
|
|
# pkg.installed() {
|
|
# git.status
|
|
# }
|
|
#
|
|
# pkg.status() {
|
|
# git.diffstat
|
|
# }
|
|
|