Add Debian/Ubuntu support via a thin distro dispatch layer
Adds a parallel install path for Debian/Ubuntu hosts alongside the existing
Arch/Omarchy/Hyprland one. The Arch path is untouched at runtime; everything
new is gated on $DISTRO and (for headless) $COMPOSITOR.
Highlights:
- lib/distro.sh: detect_distro + pkg_install/pkg_remove/ca_anchor_path/
ca_update_trust dispatch helpers
- lib/packages.sh: Ubuntu sunshine install pulls LizardByte's official .deb
from GitHub releases (override via SUNSHINE_DEB_URL/SUNSHINE_DEB_VERSION);
GPU encoder packages branch per $DISTRO:$GPU_VENDOR
- bin/sunshine-stream-{do,undo,prestart}-sway.sh + files/sway-headless.*:
swaymsg-based headless capture path for hosts without Hyprland. sway runs
under a systemd-user unit that sunshine.service depends on via drop-in.
- lib/preflight.sh: clearer NVIDIA driver guidance on Ubuntu (we don't install
the driver - too many branch/kernel/Secure-Boot variants); sway-aware
headless preflight
- lib/certs.sh + lib/verify.sh + uninstall.sh: distro-aware CA trust anchor
(Arch: /etc/ca-certificates/trust-source/anchors + update-ca-trust;
Debian: /usr/local/share/ca-certificates + update-ca-certificates)
Verified on Ubuntu 24.04: ./install.sh --doctor --headless loads cleanly,
distro/GPU/compositor detection report the right values, all pre-install
failures correspond to the actual missing pieces.
This commit is contained in:
160
lib/packages.sh
160
lib/packages.sh
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install Sunshine, Moonlight, and GPU-specific hardware-encode dependencies.
|
||||
# Branches by $DISTRO (set by lib/distro.sh).
|
||||
|
||||
# --- Arch defaults --------------------------------------------------------
|
||||
|
||||
# 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
|
||||
@@ -7,7 +10,24 @@
|
||||
: "${SUNSHINE_PKG:=sunshine-bin}"
|
||||
: "${MOONLIGHT_PKG:=moonlight-qt}"
|
||||
|
||||
# --- Debian/Ubuntu defaults ----------------------------------------------
|
||||
|
||||
# LizardByte ships official .deb builds per Ubuntu release on GitHub.
|
||||
# Resolved at runtime by _ubuntu_sunshine_deb_url to match this host.
|
||||
: "${SUNSHINE_DEB_URL:=}"
|
||||
: "${SUNSHINE_DEB_VERSION:=latest}"
|
||||
|
||||
install_sunshine() {
|
||||
case "$DISTRO" in
|
||||
arch) _install_sunshine_arch ;;
|
||||
debian) _install_sunshine_debian ;;
|
||||
*) err "install_sunshine: unsupported distro '$DISTRO'"; return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# --- Arch implementation -------------------------------------------------
|
||||
|
||||
_install_sunshine_arch() {
|
||||
# Ensure runtime deps useful for capture/diagnostics across vendors.
|
||||
yay_install pipewire-pulse vulkan-tools libva-utils jq
|
||||
|
||||
@@ -59,6 +79,71 @@ install_sunshine() {
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Debian/Ubuntu implementation ----------------------------------------
|
||||
|
||||
# LizardByte's sunshine .deb assets are named per Ubuntu codename / version,
|
||||
# e.g. sunshine-ubuntu-24.04-amd64.deb. Resolve the right one for this host.
|
||||
_ubuntu_sunshine_deb_filename() {
|
||||
local arch
|
||||
arch="$(dpkg --print-architecture 2>/dev/null || echo amd64)"
|
||||
local v="${DISTRO_VERSION:-24.04}"
|
||||
echo "sunshine-ubuntu-${v}-${arch}.deb"
|
||||
}
|
||||
|
||||
# Resolve the download URL. If SUNSHINE_DEB_URL is set, honor it (escape hatch
|
||||
# for offline mirrors / version pinning). Otherwise build a GitHub Releases
|
||||
# URL — 'latest' uses the redirecting /latest/download/ alias.
|
||||
_ubuntu_sunshine_deb_url() {
|
||||
if [[ -n "$SUNSHINE_DEB_URL" ]]; then
|
||||
echo "$SUNSHINE_DEB_URL"
|
||||
return 0
|
||||
fi
|
||||
local file
|
||||
file="$(_ubuntu_sunshine_deb_filename)"
|
||||
if [[ "$SUNSHINE_DEB_VERSION" == "latest" ]]; then
|
||||
echo "https://github.com/LizardByte/Sunshine/releases/latest/download/${file}"
|
||||
else
|
||||
echo "https://github.com/LizardByte/Sunshine/releases/download/${SUNSHINE_DEB_VERSION}/${file}"
|
||||
fi
|
||||
}
|
||||
|
||||
_install_sunshine_debian() {
|
||||
# Universal runtime deps. libva-utils gives `vainfo`; jq is used by hooks.
|
||||
# pipewire-pulse is the Ubuntu 24.04+ default audio path; on older releases
|
||||
# `pulseaudio-utils` works too — we don't force the codename split since
|
||||
# sunshine just needs *a* PulseAudio API endpoint.
|
||||
pkg_install jq vulkan-tools libva-utils curl ca-certificates
|
||||
|
||||
if pkg_installed sunshine; then
|
||||
ok "sunshine already installed (dpkg)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local url
|
||||
url="$(_ubuntu_sunshine_deb_url)"
|
||||
local tmpdir deb_path
|
||||
tmpdir="$(mktemp -d /tmp/omarchy-sunshine.XXXXXX)"
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -rf '$tmpdir'" RETURN
|
||||
deb_path="$tmpdir/$(_ubuntu_sunshine_deb_filename)"
|
||||
|
||||
info "Downloading Sunshine .deb: $url"
|
||||
if ! curl -fL --retry 3 -o "$deb_path" "$url"; then
|
||||
err "Failed to download $url"
|
||||
err "If your Ubuntu version doesn't have a prebuilt .deb, set SUNSHINE_DEB_URL"
|
||||
err "or SUNSHINE_DEB_VERSION (e.g. SUNSHINE_DEB_VERSION=v2025.118.84544 ./install.sh)."
|
||||
return 1
|
||||
fi
|
||||
|
||||
deb_install_local "$deb_path"
|
||||
|
||||
if ! command -v sunshine >/dev/null 2>&1; then
|
||||
err "sunshine command not on PATH after install — package layout unexpected."
|
||||
return 1
|
||||
fi
|
||||
ok "Installed sunshine from $(basename "$deb_path")"
|
||||
}
|
||||
|
||||
# True if every shared library sunshine links against resolves on this system.
|
||||
sunshine_runtime_deps_ok() {
|
||||
local bin
|
||||
@@ -68,17 +153,40 @@ sunshine_runtime_deps_ok() {
|
||||
}
|
||||
|
||||
install_moonlight() {
|
||||
yay_install "$MOONLIGHT_PKG"
|
||||
case "$DISTRO" in
|
||||
arch)
|
||||
yay_install "$MOONLIGHT_PKG"
|
||||
;;
|
||||
debian)
|
||||
# moonlight-qt is published as a PPA + flatpak. On a typical Ubuntu host
|
||||
# the flatpak is the lowest-friction install path; falling back to apt
|
||||
# requires adding the cloudsmith PPA. For a headless server (the primary
|
||||
# Ubuntu target here) the client side is almost never wanted — so this
|
||||
# is best-effort.
|
||||
if pkg_installed moonlight-qt; then
|
||||
ok "moonlight-qt already installed"
|
||||
return 0
|
||||
fi
|
||||
if command -v flatpak >/dev/null 2>&1; then
|
||||
info "Installing moonlight-qt via flatpak"
|
||||
as_root flatpak install -y flathub com.moonlight_stream.Moonlight || {
|
||||
warn "flatpak install of Moonlight failed — install it manually if needed."
|
||||
}
|
||||
else
|
||||
warn "moonlight-qt: no apt package in Ubuntu's default repos and no flatpak available."
|
||||
warn " Install flatpak first, or grab the .deb from https://github.com/moonlight-stream/moonlight-qt/releases"
|
||||
warn " Skipping — headless hosts rarely need the client anyway."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
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.
|
||||
case "$DISTRO:$GPU_VENDOR" in
|
||||
arch:nvidia)
|
||||
yay_install nvidia-utils libva-nvidia-driver
|
||||
;;
|
||||
amd)
|
||||
arch: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
|
||||
@@ -86,11 +194,47 @@ install_gpu_encoder_packages() {
|
||||
# `provides=(libva-mesa-driver mesa-vdpau)`.
|
||||
yay_install mesa vulkan-radeon
|
||||
;;
|
||||
intel)
|
||||
arch:intel)
|
||||
yay_install intel-media-driver vulkan-intel
|
||||
;;
|
||||
debian:nvidia)
|
||||
# On Ubuntu, the proprietary driver is usually already installed via
|
||||
# `ubuntu-drivers autoinstall` or the Server install path. Don't force a
|
||||
# specific nvidia-* version — they vary by release / driver branch.
|
||||
# Pull only the userspace VAAPI bridge if available; harmless if missing.
|
||||
pkg_install libnvidia-encode-no-dkms 2>/dev/null \
|
||||
|| pkg_install libnvidia-encode-575 2>/dev/null \
|
||||
|| pkg_install libnvidia-encode-565 2>/dev/null \
|
||||
|| pkg_install libnvidia-encode-560 2>/dev/null \
|
||||
|| info "NVENC userspace library not found via a known package name — relying on the existing driver install."
|
||||
;;
|
||||
debian:amd)
|
||||
pkg_install mesa-va-drivers mesa-vulkan-drivers vainfo
|
||||
;;
|
||||
debian:intel)
|
||||
pkg_install intel-media-va-driver-non-free mesa-vulkan-drivers
|
||||
;;
|
||||
*)
|
||||
info "Unknown GPU vendor; skipping vendor-specific encoder packages."
|
||||
info "Unknown distro/GPU combination ($DISTRO:$GPU_VENDOR); skipping vendor-specific encoder packages."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Install a wlroots-based compositor for headless capture on systems without
|
||||
# Hyprland. Currently means: Sway on Debian/Ubuntu. On Arch the existing
|
||||
# Hyprland flow is the canonical path; we only fall back to Sway if Hyprland
|
||||
# isn't installed (rare on Omarchy).
|
||||
install_headless_compositor() {
|
||||
case "$DISTRO" in
|
||||
debian)
|
||||
pkg_install sway wlr-randr
|
||||
;;
|
||||
arch)
|
||||
# Hyprland is presumed installed on Omarchy. Only act if it's missing.
|
||||
if ! command -v hyprctl >/dev/null 2>&1; then
|
||||
warn "hyprctl not found on Arch — falling back to Sway for headless capture."
|
||||
yay_install sway wlr-randr
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user