mirror of
https://github.com/warpdotdev/warp.git
synced 2026-05-07 07:38:59 +08:00
51 lines
1.8 KiB
Bash
Executable File
51 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
# Ensure the ~/.local/bin directory exists so we can download things into it.
|
|
LOCAL_BIN="$HOME/.local/bin"
|
|
mkdir -p "$LOCAL_BIN"
|
|
|
|
# A helper function to download an architecture-dependent AppImage and install
|
|
# it in ~/.local/bin.
|
|
#
|
|
# Usage:
|
|
# download_appimage $BINARY_NAME $DOWNLOAD_URL_BASE
|
|
#
|
|
# Args:
|
|
# BINARY_NAME: The name of the AppImage-bundled binary we want to
|
|
# download, e.g.: "appimagetool".
|
|
# DOWNLOAD_URL_BASE: The URL to the directory containing the architecture-
|
|
# specific AppImages.
|
|
download_appimage() {
|
|
BINARY_NAME="$1"
|
|
DOWNLOAD_URL_BASE="$2"
|
|
|
|
APPIMAGE_NAME="$BINARY_NAME-$(uname -m).AppImage"
|
|
|
|
if [ -x "$(which "$BINARY_NAME")" ]; then
|
|
echo "✅ Found $BINARY_NAME on your PATH."
|
|
elif [ -x "$(which "$APPIMAGE_NAME")" ]; then
|
|
APPIMAGE_PATH="$(which "$APPIMAGE_NAME")"
|
|
APPIMAGE_PARENT_DIR="$(dirname "$APPIMAGE_PATH")"
|
|
# Create a symlink so we can invoke it like a normal binary.
|
|
ln -s "$APPIMAGE_PATH" "$APPIMAGE_PARENT_DIR/$BINARY_NAME"
|
|
echo "✅ Found $APPIMAGE_NAME on your PATH; added $BINARY_NAME symlink."
|
|
else
|
|
echo "⬇️ Downloading $APPIMAGE_NAME..."
|
|
APPIMAGE_PATH="$LOCAL_BIN/$APPIMAGE_NAME"
|
|
curl -fL "$DOWNLOAD_URL_BASE/$APPIMAGE_NAME" --output "$APPIMAGE_PATH"
|
|
chmod +x "$APPIMAGE_PATH"
|
|
# Create a symlink so we can invoke it like a normal binary.
|
|
ln -s "$APPIMAGE_PATH" "$LOCAL_BIN/$BINARY_NAME"
|
|
fi
|
|
}
|
|
|
|
# Install linuxdeploy, a helper for constructing an AppDir (and then invoking
|
|
# appimagetool).
|
|
download_appimage "linuxdeploy" "https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20240109-1/"
|
|
|
|
if [ ! -x "$(which linuxdeploy)" ]; then
|
|
echo -e "⚠️ ${red}Please make sure that \"$LOCAL_BIN\" is on your PATH, otherwise some scripts may not work.${reset}"
|
|
fi
|