#PKG_FORMATS=
WEBI_UA="$(uname -a)"
WEBI_PKG_DOWNLOAD=""
+ WEBI_PKG_PATH="${HOME}/Downloads/webi/${PKG_NAME:-error}/${WEBI_VERSION:-latest}"
export WEBI_HOST
##
WEBI_TMP=${WEBI_TMP:-"$(mktemp -d -t webinstall-"${WEBI_PKG:-}".XXXXXXXX)"}
export _webi_tmp="${_webi_tmp:-"$HOME/.local/opt/webi-tmp.d"}"
- mkdir -p "$HOME/Downloads/webi"
+ mkdir -p "${WEBI_PKG_PATH}"
mkdir -p "$HOME/.local/bin"
mkdir -p "$HOME/.local/opt"
my_current_cmd="$(command -v "$pkg_cmd_name")"
set -e
if [ -n "$my_current_cmd" ]; then
- pkg_current_version="$(pkg_get_current_version 2> /dev/null | head -n 1)"
+ # TODO get version from symlink?
+ pkg_current_version=""
+ if [ -n "$(command -v pkg_get_current_version)" ]; then
+ pkg_current_version="$(
+ pkg_get_current_version 2> /dev/null |
+ head -n 1
+ )"
+ fi
# remove trailing '.0's for golang's sake
my_current_version="$(echo "$pkg_current_version" | sed 's:\.0::g')"
my_src_version="$(echo "$WEBI_VERSION" | sed 's:\.0::g')"
if [ -n "${2:-}" ]; then
my_dl="$2"
else
- my_dl="$HOME/Downloads/webi/$WEBI_PKG_FILE"
+ my_dl="${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
fi
WEBI_PKG_DOWNLOAD="${my_dl}"
webi_extract() {
pushd "$WEBI_TMP" > /dev/null 2>&1
if [ "tar" == "$WEBI_EXT" ]; then
- echo "Extracting $HOME/Downloads/webi/$WEBI_PKG_FILE"
- tar xf "$HOME/Downloads/webi/$WEBI_PKG_FILE"
+ echo "Extracting ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
+ tar xf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
elif [ "zip" == "$WEBI_EXT" ]; then
- echo "Extracting $HOME/Downloads/webi/$WEBI_PKG_FILE"
- unzip "$HOME/Downloads/webi/$WEBI_PKG_FILE" > __unzip__.log
+ echo "Extracting ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
+ unzip "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > __unzip__.log
elif [ "exe" == "$WEBI_EXT" ]; then
- echo "Moving $HOME/Downloads/webi/$WEBI_PKG_FILE"
- mv "$HOME/Downloads/webi/$WEBI_PKG_FILE" .
+ echo "Moving ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
+ mv "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" .
elif [ "xz" == "$WEBI_EXT" ]; then
- echo "Inflating $HOME/Downloads/webi/$WEBI_PKG_FILE"
- unxz -c "$HOME/Downloads/webi/$WEBI_PKG_FILE" > "$(basename "$WEBI_PKG_FILE")"
+ echo "Inflating ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
+ unxz -c "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > "$(basename "$WEBI_PKG_FILE")"
else
# do nothing
- echo "Failed to extract $HOME/Downloads/webi/$WEBI_PKG_FILE"
+ echo "Failed to extract ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
exit 1
fi
popd > /dev/null 2>&1