Arch names checked (installed on the Plasma 6.8 test desktop; --dry-run there prints them); the Debian, Fedora and openSUSE names are those distros' usual ones, not run.
434 lines
14 KiB
Bash
Executable File
434 lines
14 KiB
Bash
Executable File
#!/bin/sh
|
|
# Summit installer for Linux.
|
|
#
|
|
# curl -fsSL https://git.molberg.cloud/alex/summit/raw/branch/main/install.sh | sh
|
|
#
|
|
# POSIX sh, no bashisms. Detects your distro, GPU vendor and display session,
|
|
# installs the Summit launcher (native package if one exists for a tagged
|
|
# release, otherwise builds from source with cargo) and sets up the engine's
|
|
# Python virtualenv (uv, Python 3.12, CUDA 12.8 torch only if an NVIDIA GPU
|
|
# is present).
|
|
#
|
|
# Flags:
|
|
# --yes, -y don't ask before sudo steps
|
|
# --dry-run print what would happen, change nothing
|
|
# --uninstall remove what this installer installed
|
|
# --help, -h show this message
|
|
#
|
|
# Environment:
|
|
# SUMMIT_PREFIX where to install (default /usr/local)
|
|
# SUMMIT_SRC_DIR build this checkout as it is (no clone, no git pull)
|
|
|
|
set -eu
|
|
|
|
REPO_API="https://git.molberg.cloud/api/v1/repos/alex/summit"
|
|
REPO_GIT="https://git.molberg.cloud/alex/summit.git"
|
|
PREFIX="${SUMMIT_PREFIX:-/usr/local}"
|
|
SHARE_DIR="$PREFIX/share/summit"
|
|
BIN_DIR="$PREFIX/bin"
|
|
SRC_DIR="${SUMMIT_SRC_DIR:-$HOME/.cache/summit/src}"
|
|
APPS_DIR="$PREFIX/share/applications"
|
|
ICON_DIR="$PREFIX/share/icons/hicolor/64x64/apps"
|
|
|
|
ASSUME_YES=0
|
|
DRY_RUN=0
|
|
UNINSTALL=0
|
|
|
|
log() { printf '%s\n' "$*"; }
|
|
step() { printf '\n==> %s\n' "$*"; }
|
|
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
|
|
|
|
run() {
|
|
# Print the command, then execute it unless --dry-run.
|
|
printf ' $ %s\n' "$*"
|
|
if [ "$DRY_RUN" -eq 0 ]; then
|
|
"$@"
|
|
fi
|
|
}
|
|
|
|
run_sudo() {
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
run "$@"
|
|
return
|
|
fi
|
|
if [ "$ASSUME_YES" -eq 0 ] && [ "$DRY_RUN" -eq 0 ]; then
|
|
printf ' needs sudo: %s\n' "$*"
|
|
printf ' proceed? [y/N] '
|
|
read -r reply
|
|
case "$reply" in
|
|
y|Y|yes|YES) ;;
|
|
*) die "aborted before: $*" ;;
|
|
esac
|
|
fi
|
|
run sudo "$@"
|
|
}
|
|
|
|
usage() {
|
|
sed -n '2,20p' "$0" | sed 's/^# \{0,1\}//'
|
|
}
|
|
|
|
# Tools Summit calls at run time. A missing one only disables a feature, so a failure here warns instead of
|
|
# stopping the install: ffmpeg (Enhance reads the game window with it), xrandr (display profiles on X11),
|
|
# xdg-open (Heroic games, the clips folder) and zenity (Change artwork outside KDE; KDE has kdialog).
|
|
RUNTIME_TOOLS="ffmpeg xrandr xdg-open zenity"
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--yes|-y) ASSUME_YES=1 ;;
|
|
--dry-run) DRY_RUN=1 ;;
|
|
--uninstall) UNINSTALL=1 ;;
|
|
--help|-h) usage; exit 0 ;;
|
|
*) die "unknown flag: $arg (see --help)" ;;
|
|
esac
|
|
done
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Detection
|
|
# ---------------------------------------------------------------------------
|
|
|
|
DISTRO_ID=unknown
|
|
DISTRO_FAMILY=unknown # arch, debian, fedora, opensuse
|
|
|
|
detect_distro() {
|
|
if [ -r /etc/os-release ]; then
|
|
# shellcheck disable=SC1091
|
|
. /etc/os-release
|
|
DISTRO_ID="${ID:-unknown}"
|
|
ID_LIKE_VAL="${ID_LIKE:-}"
|
|
else
|
|
DISTRO_ID=unknown
|
|
ID_LIKE_VAL=""
|
|
fi
|
|
|
|
case "$DISTRO_ID $ID_LIKE_VAL" in
|
|
*arch*|*cachyos*|*manjaro*) DISTRO_FAMILY=arch ;;
|
|
*debian*|*ubuntu*|*neon*|*linuxmint*|*mint*) DISTRO_FAMILY=debian ;;
|
|
*fedora*) DISTRO_FAMILY=fedora ;;
|
|
*opensuse*|*suse*) DISTRO_FAMILY=opensuse ;;
|
|
*)
|
|
case "$DISTRO_ID" in
|
|
arch|cachyos|manjaro) DISTRO_FAMILY=arch ;;
|
|
debian|ubuntu|neon|linuxmint) DISTRO_FAMILY=debian ;;
|
|
fedora) DISTRO_FAMILY=fedora ;;
|
|
opensuse*|sles) DISTRO_FAMILY=opensuse ;;
|
|
*) DISTRO_FAMILY=unknown ;;
|
|
esac
|
|
;;
|
|
esac
|
|
}
|
|
|
|
GPU_VENDOR=unknown # nvidia, amd, intel, none
|
|
|
|
detect_gpu() {
|
|
GPU_VENDOR=none
|
|
if ! command -v lspci >/dev/null 2>&1; then
|
|
return
|
|
fi
|
|
pci_vga="$(lspci -nn 2>/dev/null | grep -Ei 'vga|3d controller|display controller' || true)"
|
|
case "$pci_vga" in
|
|
*[Nn][Vv][Ii][Dd][Ii][Aa]*) GPU_VENDOR=nvidia ;;
|
|
*) case "$pci_vga" in
|
|
*[Aa][Mm][Dd]*|*[Aa][Tt][Ii]*|*[Rr]adeon*) GPU_VENDOR=amd ;;
|
|
*) case "$pci_vga" in
|
|
*[Ii]ntel*) GPU_VENDOR=intel ;;
|
|
*) GPU_VENDOR=none ;;
|
|
esac
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
}
|
|
|
|
SESSION_TYPE=unknown # wayland, x11
|
|
|
|
detect_session() {
|
|
if [ -n "${XDG_SESSION_TYPE:-}" ]; then
|
|
SESSION_TYPE="$XDG_SESSION_TYPE"
|
|
elif [ -n "${WAYLAND_DISPLAY:-}" ]; then
|
|
SESSION_TYPE=wayland
|
|
elif [ -n "${DISPLAY:-}" ]; then
|
|
SESSION_TYPE=x11
|
|
else
|
|
SESSION_TYPE=unknown
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Package manager glue
|
|
# ---------------------------------------------------------------------------
|
|
|
|
install_dependencies() {
|
|
step "Installing build and runtime dependencies for $DISTRO_FAMILY"
|
|
case "$DISTRO_FAMILY" in
|
|
arch)
|
|
run_sudo pacman -Sy --needed --noconfirm base-devel git curl pkgconf fontconfig
|
|
runtime="ffmpeg xorg-xrandr xdg-utils zenity"
|
|
;;
|
|
debian)
|
|
run_sudo apt-get update
|
|
run_sudo apt-get install -y build-essential git curl pkg-config libssl-dev libfontconfig1-dev
|
|
runtime="ffmpeg x11-xserver-utils xdg-utils zenity"
|
|
;;
|
|
fedora)
|
|
run_sudo dnf install -y @development-tools git curl pkgconf-pkg-config openssl-devel fontconfig-devel
|
|
# Fedora's own ffmpeg build; RPM Fusion's "ffmpeg" has more encoders if you have that repo.
|
|
runtime="ffmpeg-free xrandr xdg-utils zenity"
|
|
;;
|
|
opensuse)
|
|
run_sudo zypper install -y -t pattern devel_basis
|
|
run_sudo zypper install -y git curl pkg-config libopenssl-devel fontconfig-devel
|
|
runtime="ffmpeg xrandr xdg-utils zenity"
|
|
;;
|
|
*)
|
|
log " unrecognized distro family ($DISTRO_ID) — skipping package manager, assuming build tools are present"
|
|
runtime=""
|
|
;;
|
|
esac
|
|
# Wayland: native Wayland games reach the engine through the ScreenCast portal and GStreamer's PipeWire plugin
|
|
# (gst-launch-1.0 pipewiresrc). Package names checked on Arch only; the others are each distro's usual names.
|
|
if [ "$SESSION_TYPE" = wayland ] && [ -n "$runtime" ]; then
|
|
case "$DISTRO_FAMILY" in
|
|
arch) runtime="$runtime gstreamer gst-plugins-base gst-plugin-pipewire" ;;
|
|
debian) runtime="$runtime gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-pipewire" ;;
|
|
fedora) runtime="$runtime gstreamer1 gstreamer1-plugins-base pipewire-gstreamer" ;;
|
|
opensuse) runtime="$runtime gstreamer-utils gstreamer-plugins-base gstreamer-plugin-pipewire" ;;
|
|
esac
|
|
fi
|
|
if [ -n "$runtime" ]; then
|
|
step "Installing the tools Summit runs (a failure here only disables a feature)"
|
|
# shellcheck disable=SC2086
|
|
case "$DISTRO_FAMILY" in
|
|
arch) run_sudo pacman -S --needed --noconfirm $runtime || log " warning: could not install: $runtime" ;;
|
|
debian) run_sudo apt-get install -y $runtime || log " warning: could not install: $runtime" ;;
|
|
fedora) run_sudo dnf install -y $runtime || log " warning: could not install: $runtime" ;;
|
|
opensuse) run_sudo zypper install -y $runtime || log " warning: could not install: $runtime" ;;
|
|
esac
|
|
fi
|
|
}
|
|
|
|
check_runtime_tools() {
|
|
missing=""
|
|
for t in $RUNTIME_TOOLS; do
|
|
command -v "$t" >/dev/null 2>&1 || missing="$missing $t"
|
|
done
|
|
if [ -n "$missing" ]; then
|
|
log " missing :$missing (see 'summit doctor' for what each one is for)"
|
|
fi
|
|
}
|
|
|
|
ensure_rust() {
|
|
if command -v cargo >/dev/null 2>&1; then
|
|
return
|
|
fi
|
|
step "Rust toolchain not found, installing with rustup"
|
|
run sh -c 'curl -fsSL https://sh.rustup.rs | sh -s -- -y'
|
|
RUSTUP_ENV="$HOME/.cargo/env"
|
|
if [ -r "$RUSTUP_ENV" ]; then
|
|
# shellcheck disable=SC1090
|
|
. "$RUSTUP_ENV"
|
|
fi
|
|
# `curl | sh` succeeds when curl fails (sh just reads nothing), so check the result instead.
|
|
if [ "$DRY_RUN" -eq 0 ] && ! command -v cargo >/dev/null 2>&1; then
|
|
die "rustup did not install cargo (no internet?). Install Rust from https://rustup.rs and run this again"
|
|
fi
|
|
}
|
|
|
|
ensure_uv() {
|
|
if command -v uv >/dev/null 2>&1; then
|
|
return
|
|
fi
|
|
step "uv (Python package manager) not found, installing"
|
|
run sh -c 'curl -fsSL https://astral.sh/uv/install.sh | sh'
|
|
if [ -r "$HOME/.local/bin/env" ]; then
|
|
# shellcheck disable=SC1090,SC1091
|
|
. "$HOME/.local/bin/env"
|
|
fi
|
|
PATH="$HOME/.local/bin:$PATH"
|
|
export PATH
|
|
if [ "$DRY_RUN" -eq 0 ] && ! command -v uv >/dev/null 2>&1; then
|
|
die "uv did not install (no internet?). Install it from https://docs.astral.sh/uv/ and run this again"
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Install / uninstall
|
|
# ---------------------------------------------------------------------------
|
|
|
|
release_asset_url() {
|
|
# Prints a matching release asset URL for this distro family, or nothing.
|
|
if ! command -v curl >/dev/null 2>&1; then
|
|
return
|
|
fi
|
|
case "$DISTRO_FAMILY" in
|
|
arch) want="*.pkg.tar.zst" ;;
|
|
debian) want="*.deb" ;;
|
|
*) return ;;
|
|
esac
|
|
latest_json="$(curl -fsSL "$REPO_API/releases/latest" 2>/dev/null || true)"
|
|
[ -n "$latest_json" ] || return
|
|
printf '%s' "$latest_json" | grep -o '"browser_download_url":"[^"]*"' \
|
|
| sed 's/"browser_download_url":"//; s/"$//' \
|
|
| while IFS= read -r url; do
|
|
# shellcheck disable=SC2254
|
|
case "$url" in
|
|
$want) printf '%s\n' "$url"; return ;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
install_native_package() {
|
|
asset_url="$1"
|
|
asset_file="/tmp/$(basename "$asset_url")"
|
|
step "Downloading release asset: $asset_url"
|
|
run curl -fsSL -o "$asset_file" "$asset_url"
|
|
case "$DISTRO_FAMILY" in
|
|
arch) run_sudo pacman -U --noconfirm "$asset_file" ;;
|
|
debian) run_sudo apt-get install -y "$asset_file" ;;
|
|
esac
|
|
}
|
|
|
|
build_from_source() {
|
|
step "No usable release package found, building from source"
|
|
ensure_rust
|
|
if [ -n "${SUMMIT_SRC_DIR:-}" ]; then
|
|
[ -f "$SRC_DIR/Cargo.toml" ] || die "SUMMIT_SRC_DIR=$SRC_DIR is not a Summit checkout (no Cargo.toml)"
|
|
log " building the checkout in SUMMIT_SRC_DIR as it is: $SRC_DIR"
|
|
elif [ -d "$SRC_DIR/.git" ]; then
|
|
run git -C "$SRC_DIR" fetch --tags
|
|
run git -C "$SRC_DIR" checkout main
|
|
run git -C "$SRC_DIR" pull --ff-only
|
|
else
|
|
run mkdir -p "$(dirname "$SRC_DIR")"
|
|
run git clone "$REPO_GIT" "$SRC_DIR"
|
|
fi
|
|
run cargo build --release --manifest-path "$SRC_DIR/Cargo.toml" -p summit -p summit-gui
|
|
run_sudo install -Dm755 "$SRC_DIR/target/release/summit" "$BIN_DIR/summit"
|
|
run_sudo install -Dm755 "$SRC_DIR/target/release/summit-gui" "$BIN_DIR/summit-gui"
|
|
run_sudo mkdir -p "$SHARE_DIR/engine"
|
|
run_sudo cp -r "$SRC_DIR/engine/." "$SHARE_DIR/engine/"
|
|
install_desktop_entry "$SRC_DIR/packaging"
|
|
# The engine's venv is made in there next, without sudo (uv and the Python it downloads live in the user's home),
|
|
# so the folder has to belong to the user who runs Summit.
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
run_sudo chown -R "$(id -u):$(id -g)" "$SHARE_DIR/engine"
|
|
fi
|
|
}
|
|
|
|
install_desktop_entry() {
|
|
# The app menu entry, pointing at the installed binary by its full path (a custom SUMMIT_PREFIX is often not
|
|
# on the menu's PATH).
|
|
pkg="$1"
|
|
run_sudo install -Dm644 "$pkg/icons/summit.png" "$ICON_DIR/summit.png"
|
|
desktop_tmp="$(mktemp)"
|
|
sed "s|^Exec=summit-gui|Exec=$BIN_DIR/summit-gui|" "$pkg/summit.desktop" > "$desktop_tmp"
|
|
run_sudo install -Dm644 "$desktop_tmp" "$APPS_DIR/summit.desktop"
|
|
rm -f "$desktop_tmp"
|
|
if command -v update-desktop-database >/dev/null 2>&1; then
|
|
run_sudo update-desktop-database "$APPS_DIR" || true
|
|
fi
|
|
}
|
|
|
|
fetch_default_model() {
|
|
# RIFE's default weights (4.22.lite), so the first Play with Enhance does not stop to download them, and so a
|
|
# root-owned engine folder (installed as root) still has them. Other models download on first use.
|
|
engine_dir="$1"
|
|
model="$engine_dir/models/flownet_v4.22.lite.pkl"
|
|
if [ -f "$model" ]; then
|
|
return
|
|
fi
|
|
step "Downloading the default RIFE model (about 20 MB)"
|
|
run mkdir -p "$engine_dir/models"
|
|
if run curl -fsSL -o "$model.part" "https://github.com/HolyWu/vs-rife/releases/download/model/flownet_v4.22.lite.pkl"; then
|
|
run mv "$model.part" "$model"
|
|
else
|
|
run rm -f "$model.part"
|
|
log " warning: download failed; the engine will try again the first time Enhance runs"
|
|
fi
|
|
}
|
|
|
|
setup_engine_venv() {
|
|
step "Setting up the engine's Python environment (uv, Python 3.12)"
|
|
ensure_uv
|
|
engine_dir="$SHARE_DIR/engine"
|
|
if [ ! -d "$engine_dir" ]; then
|
|
engine_dir="$SRC_DIR/engine"
|
|
fi
|
|
if [ ! -d "$engine_dir" ]; then
|
|
log " engine sources not found, skipping venv setup"
|
|
return
|
|
fi
|
|
run uv venv --python 3.12 "$engine_dir/.venv"
|
|
if [ "$GPU_VENDOR" = "nvidia" ]; then
|
|
# torch first: requirements.txt only says torch>=2.6, and PyPI's default wheel is built for a newer CUDA than
|
|
# many installed drivers support (seen: torch 2.15+cu132 on a driver that stops at CUDA 13.0).
|
|
step "NVIDIA GPU detected: installing CUDA 12.8 torch build"
|
|
run uv pip install --python "$engine_dir/.venv" torch --index-url https://download.pytorch.org/whl/cu128
|
|
else
|
|
log " no NVIDIA GPU detected, skipping CUDA torch (engine will run CPU-only or be unavailable)"
|
|
fi
|
|
run uv pip install --python "$engine_dir/.venv" -r "$engine_dir/requirements.txt"
|
|
fetch_default_model "$engine_dir"
|
|
}
|
|
|
|
do_install() {
|
|
step "Plan"
|
|
log " distro family : $DISTRO_FAMILY (ID=$DISTRO_ID)"
|
|
log " GPU vendor : $GPU_VENDOR"
|
|
log " session type : $SESSION_TYPE"
|
|
log " will install : summit, summit-gui into $BIN_DIR"
|
|
log " engine : $SHARE_DIR/engine with its own venv"
|
|
if [ "$DRY_RUN" -eq 1 ]; then
|
|
log " (--dry-run: no changes will be made)"
|
|
fi
|
|
|
|
if [ "$ASSUME_YES" -eq 0 ] && [ "$DRY_RUN" -eq 0 ]; then
|
|
printf '\nProceed? [y/N] '
|
|
read -r reply
|
|
case "$reply" in
|
|
y|Y|yes|YES) ;;
|
|
*) die "aborted" ;;
|
|
esac
|
|
fi
|
|
|
|
install_dependencies
|
|
|
|
asset_url="$(release_asset_url || true)"
|
|
if [ -n "$asset_url" ]; then
|
|
install_native_package "$asset_url"
|
|
else
|
|
build_from_source
|
|
fi
|
|
|
|
setup_engine_venv
|
|
|
|
step "Done"
|
|
log " summit -> $BIN_DIR/summit"
|
|
log " summit-gui -> $BIN_DIR/summit-gui"
|
|
log " engine -> $SHARE_DIR/engine (venv at $SHARE_DIR/engine/.venv)"
|
|
log " app menu -> $APPS_DIR/summit.desktop"
|
|
check_runtime_tools
|
|
log ""
|
|
log " Next: 'summit doctor' checks what Enhance needs; 'summit-gui' (or Summit in the app menu) starts the launcher."
|
|
}
|
|
|
|
do_uninstall() {
|
|
step "Uninstalling Summit"
|
|
run_sudo rm -f "$BIN_DIR/summit" "$BIN_DIR/summit-gui" "$APPS_DIR/summit.desktop" "$ICON_DIR/summit.png"
|
|
run_sudo rm -rf "$SHARE_DIR"
|
|
log "Left in place: $SRC_DIR (build cache), ~/.config/summit, ~/.local/share/summit (your data)"
|
|
}
|
|
|
|
main() {
|
|
detect_distro
|
|
detect_gpu
|
|
detect_session
|
|
|
|
if [ "$UNINSTALL" -eq 1 ]; then
|
|
do_uninstall
|
|
else
|
|
do_install
|
|
fi
|
|
}
|
|
|
|
main "$@"
|