#WEBI_LTS=
#WEBI_CHANNEL=
#WEBI_EXT=
+#WEBI_FORMATS=
#WEBI_PKG_URL=
#WEBI_PKG_FILE=
WEBI_UA="$(uname -a)"
export WEBI_WGET="$(command -v wget)"
set -e
+
+# get the special formatted version (i.e. "go is go1.14" while node is "node v12.10.8")
my_versioned_name=""
_webi_canonical_name() {
if [ -n "$my_versioned_name" ]; then
echo "$my_versioned_name"
}
+# update symlinks according to $HOME/.local/opt and $HOME/.local/bin install paths.
webi_link() {
if [ -n "$(command -v pkg_link)" ]; then
pkg_link
fi
if [ -n "$WEBI_SINGLE" ] || [ "single" == "${1:-}" ]; then
- if [ -d "$pkg_dst_cmd" ]; then
- rm -rf -i "$pkg_dst_cmd"
- else
+ if [ -L "$pkg_dst_cmd" ]; then
rm -f "$pkg_dst_cmd"
+ elif [ -e "$pkg_dst_cmd" ]; then
+ echo "remove $pkg_dst_cmd?"
+ rm -rf -i "$pkg_dst_cmd"
fi
ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
else
# 'pkg_dst' will default to $HOME/.local/opt/node
# 'pkg_src' will be the installed version, such as to $HOME/.local/opt/node-v12.8.0
- if [ -d "$pkg_dst" ]; then
- rm -rf -i "$pkg_dst"
- else
+ if [ -L "$pkg_dst" ]; then
rm -f "$pkg_dst"
+ elif [ -e "$pkg_dst" ]; then
+ echo "remove $pkg_dst?"
+ rm -rf -i "$pkg_dst"
fi
ln -s "$pkg_src" "$pkg_dst"
fi
}
+# detect if this program is already installed or if an installed version may cause conflict
webi_check() {
# Test for existing version
set +e
fi
}
+# detect if file is downloaded, and how to download it
webi_download() {
if [ -n "${1:-}" ]; then
my_url="$1"
# TODO pass back requested OS / Arch / Version
echo "Error: no '$WEBI_NAME' release found for the given OS and architecture by that tag or version"
echo " (check that the package name and version are correct)"
+ echo "See $WEBI_RELEASES"
+ echo " WEBI_PKG=$WEBI_PKG"
+ echo " WEBI_NAME=$WEBI_NAME"
+ echo " WEBI_VERSION=$WEBI_VERSION"
+ echo " WEBI_EXT=$WEBI_EXT"
+ echo " WEBI_FORMATS=$WEBI_FORMATS"
exit 1
fi
my_url="$WEBI_PKG_URL"
mv "$my_dl.part" "$my_dl"
}
+# detect which archives can be used
webi_extract() {
pushd "$WEBI_TMP" 2>&1 >/dev/null
if [ "tar" == "$WEBI_EXT" ]; then
popd 2>&1 >/dev/null
}
+# use 'pathman' to update $HOME/.config/envman/PATH.env
webi_path_add() {
# make sure that we don't recursively install pathman with webi
my_path="$PATH"
"$HOME/.local/bin/pathman" add "$1"
}
+# group common pre-install tasks as default
webi_pre_install() {
webi_check
webi_download
webi_extract
}
+# move commands from the extracted archive directory to $HOME/.local/opt or $HOME/.local/bin
webi_install() {
if [ -n "$WEBI_SINGLE" ] || [ "single" == "${1:-}" ]; then
mkdir -p "$(dirname $pkg_src_cmd)"
chmod a+x "$pkg_src_cmd"
else
mkdir -p "$(dirname $pkg_src)"
- if [ -d "$pkg_src" ]; then
- rm -rf -i "$pkg_src"
- else
+ if [ -L "$pkg_src" ]; then
rm -f "$pkg_src"
+ elif [ -e "$pkg_src" ]; then
+ echo "remove $pkg_src?"
+ rm -rf -i "$pkg_src"
fi
mv ./"$pkg_cmd_name"* "$pkg_src"
fi
}
+# run post-install functions - just updating PATH by default
webi_post_install() {
webi_path_add "$pkg_dst_bin"
}
+# a friendly message when all is well, showing the final install path in $HOME/.local
_webi_done_message() {
echo "Installed $(_webi_canonical_name) as $pkg_dst_cmd"
}
##
##
-## BEGIN user-submited script
+## BEGIN custom override functions from <package>/install.sh
##
##
##
##
-## END user-submitted script
+## END custom override functions
##
##
+# run everything with defaults or overrides as needed
if [ -n "$(command -v pkg_get_current_version)" ]; then
pkg_cmd_name="${pkg_cmd_name:-$WEBI_NAME}"
echo ""
fi
+# cleanup the temp directory
rm -rf "$WEBI_TMP"
+# See? No magic. Just downloading and moving files.
+
}