97 lines
3.8 KiB
Bash
97 lines
3.8 KiB
Bash
#!/usr/bin/env bash
|
|
# Install Sunshine, Moonlight, and GPU-specific hardware-encode dependencies.
|
|
|
|
# Default to the precompiled AUR build for a fast install (~seconds instead of
|
|
# the ~10 minute source compile). Override with SUNSHINE_PKG=sunshine to build
|
|
# from source.
|
|
: "${SUNSHINE_PKG:=sunshine-bin}"
|
|
: "${MOONLIGHT_PKG:=moonlight-qt}"
|
|
|
|
install_sunshine() {
|
|
# Ensure runtime deps useful for capture/diagnostics across vendors.
|
|
yay_install pipewire-pulse vulkan-tools libva-utils jq
|
|
|
|
# If a working sunshine (source build) is already installed, don't touch it.
|
|
# Otherwise re-running install.sh would replace the source build with
|
|
# sunshine-bin (the default $SUNSHINE_PKG), trip the ldd check, then rebuild
|
|
# from source — a redundant ~10 minute compile on every re-run.
|
|
if pkg_installed sunshine && sunshine_runtime_deps_ok; then
|
|
ok "sunshine (source build) already installed with all shared libs resolved"
|
|
return 0
|
|
fi
|
|
# Same idempotency for sunshine-bin when it happens to be working.
|
|
if pkg_installed sunshine-bin && sunshine_runtime_deps_ok; then
|
|
ok "sunshine-bin already installed and runtime deps resolved"
|
|
return 0
|
|
fi
|
|
|
|
yay_install "$SUNSHINE_PKG"
|
|
|
|
# sunshine-bin is a precompiled AUR package; it breaks whenever Arch bumps a
|
|
# major shared library (most commonly ICU). Detect that and fall back to the
|
|
# source build, which links against whatever's currently installed.
|
|
if ! sunshine_runtime_deps_ok; then
|
|
if [[ "$SUNSHINE_PKG" == "sunshine-bin" ]]; then
|
|
warn "sunshine-bin has unresolved shared library deps (rolling-Arch library drift)."
|
|
warn "Falling back to the source build (AUR 'sunshine'). This takes ~5-10 minutes."
|
|
ldd "$(command -v sunshine)" 2>/dev/null | grep 'not found' | sed 's/^/ /' >&2 || true
|
|
# Remove both sunshine-bin AND its sibling sunshine-bin-debug, otherwise
|
|
# the source build's sunshine-debug package collides on
|
|
# /usr/lib/debug/usr/bin/sunshine.debug.
|
|
for stale in sunshine-bin-debug sunshine-bin; do
|
|
if pacman -Qi "$stale" >/dev/null 2>&1; then
|
|
as_root pacman -Rns --noconfirm "$stale"
|
|
fi
|
|
done
|
|
SUNSHINE_PKG="sunshine"
|
|
yay_install sunshine
|
|
if ! sunshine_runtime_deps_ok; then
|
|
err "Source build also reports unresolved deps. Inspect: ldd \$(command -v sunshine)"
|
|
return 1
|
|
fi
|
|
ok "Recovered with source build"
|
|
else
|
|
err "sunshine binary has unresolved shared library deps:"
|
|
ldd "$(command -v sunshine)" 2>/dev/null | grep 'not found' | sed 's/^/ /' >&2 || true
|
|
err "Try: SUNSHINE_PKG=sunshine ./install.sh"
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# True if every shared library sunshine links against resolves on this system.
|
|
sunshine_runtime_deps_ok() {
|
|
local bin
|
|
bin="$(command -v sunshine 2>/dev/null || true)"
|
|
[[ -n "$bin" ]] || return 1
|
|
! ldd "$bin" 2>/dev/null | grep -q 'not found'
|
|
}
|
|
|
|
install_moonlight() {
|
|
yay_install "$MOONLIGHT_PKG"
|
|
}
|
|
|
|
install_gpu_encoder_packages() {
|
|
case "$GPU_VENDOR" in
|
|
nvidia)
|
|
# NVENC works through the proprietary driver. libva-nvidia-driver lets some
|
|
# apps use VAAPI on NVIDIA; not strictly required for Sunshine NVENC but useful.
|
|
yay_install nvidia-utils libva-nvidia-driver
|
|
;;
|
|
amd)
|
|
# VAAPI (mesa) + Vulkan for AMD hardware encode paths.
|
|
# libva-mesa-driver is now provided by mesa (merged upstream); mesa-vdpau
|
|
# was removed from official repos. Naming them here makes yay fall back to
|
|
# AUR and pull in random forks like mesa-rk35xx-git that advertise
|
|
# `provides=(libva-mesa-driver mesa-vdpau)`.
|
|
yay_install mesa vulkan-radeon
|
|
;;
|
|
intel)
|
|
yay_install intel-media-driver vulkan-intel
|
|
;;
|
|
*)
|
|
info "Unknown GPU vendor; skipping vendor-specific encoder packages."
|
|
;;
|
|
esac
|
|
}
|