From b2e3d1b5400f659da69cfddddbf6136acbabff60 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Tue, 21 Jul 2026 22:39:52 +0200 Subject: [PATCH] fix(steamdeck/install): add cmake dep + acquire sudo in preflight MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pyrowave-sys's build.rs runs cmake to build the vendored PyroWave C library, but cmake wasn't in the distrobox apt list — so `cargo build -p punktfunk-host` dies on every SteamOS host with "is cmake not installed?". Add it. Also move sudo acquisition from step 4 (after the ~15-min build) into preflight and keep the timestamp warm across the build. Before, a non-interactive run (`ssh host 'bash install.sh'`) silently skipped the UDP-buffer/udev/vhci-hcd/ input-group tuning AND enable-linger — a "successful" host with no gamepad passthrough, lossy streaming, and no headless persistence (dies on logout). Now sudo is prompted once up front (authorize and walk away), and a no-TTY / no-password run fails loudly before the build instead of silently at the end. Validated end-to-end on SteamOS 3.8 in a VM with Radeon 780M passthrough: full host + web build, all planes listening, VAAPI render node, headless auto-start via linger. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/steamdeck/install.sh | 43 ++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/scripts/steamdeck/install.sh b/scripts/steamdeck/install.sh index f1544042..633c4d6c 100755 --- a/scripts/steamdeck/install.sh +++ b/scripts/steamdeck/install.sh @@ -69,6 +69,33 @@ fi DISTROBOX="$(command -v distrobox)" # baked into the web unit (may be /usr/bin or ~/.local/bin) ok "distrobox: $DISTROBOX" +# --- acquire sudo up front (before the ~15-min build) ---------------------- +# Steps 4-5 (UDP buffers, gamepad udev rule, vhci-hcd, input group, linger) need root. Prompt NOW, +# not after the build — so you authorize once and walk away, and a non-interactive run fails LOUDLY +# here instead of silently skipping the tuning at the very end. A stock SteamOS 'deck' has no +# password, so sudo can't work until you set one. +SUDO_OK=0 +if sudo -n true 2>/dev/null; then + SUDO_OK=1 +elif [ -t 0 ]; then + warn "sudo is needed once (UDP buffers, gamepad udev rule, vhci-hcd, input group, linger):" + if sudo -v; then + SUDO_OK=1 + # keep the sudo timestamp warm across the long build so steps 4-5 don't re-prompt / expire + ( while sudo -n -v 2>/dev/null; do sleep 50; done ) & + _pf_sudo_keepalive=$! + trap '[ -n "${_pf_sudo_keepalive:-}" ] && kill "$_pf_sudo_keepalive" 2>/dev/null || true' EXIT + fi +fi +if [ "$SUDO_OK" != 1 ]; then + if [ -t 0 ]; then + warn "No sudo — a stock SteamOS 'deck' account has no password. Set one and re-run: passwd" + else + warn "No TTY for the sudo prompt (non-interactive run) — system tuning + linger will be SKIPPED." + warn "Run in Konsole or an interactive 'ssh -t' session (or pre-authorize sudo) to enable them." + fi +fi + # --- 1. build container + toolchain --------------------------------------- log "Build container '$BOX' ($BOX_IMAGE)" if distrobox list 2>/dev/null | awk -F'|' '{gsub(/ /,"",$2); print $2}' | grep -qx "$BOX"; then @@ -87,7 +114,7 @@ set -e export DEBIAN_FRONTEND=noninteractive sudo apt-get update -qq sudo apt-get install -y -qq --no-install-recommends \ - build-essential pkg-config clang curl git ca-certificates \ + build-essential pkg-config clang cmake curl git ca-certificates \ libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libswscale-dev libavdevice-dev \ libpipewire-0.3-dev libspa-0.2-dev \ libgbm-dev libegl-dev libgl-dev libdrm-dev libva-dev \ @@ -190,17 +217,9 @@ else fi # --- 4. system tuning (needs sudo: UDP buffers + gamepad udev rule + vhci-hcd + input group) -------- -log "System tuning (UDP buffers + gamepad rules + vhci-hcd + input group) — needs sudo" -# Acquire sudo. A stock Steam Deck requires a sudo PASSWORD, so `sudo -n` (non-interactive) fails — -# we must PROMPT on a TTY, not silently skip. Skipping here is exactly what leaves gamepad passthrough -# dead (no udev rule / input group / vhci-hcd) and streaming lossy (stock 416 KB UDP buffers). -SUDO_OK=0 -if sudo -n true 2>/dev/null; then - SUDO_OK=1 -elif [ -t 0 ]; then - warn "sudo needs your password to set up the gamepad udev rule, vhci-hcd, the input group, and UDP buffers:" - sudo -v && SUDO_OK=1 || true -fi +log "System tuning (UDP buffers + gamepad rules + vhci-hcd + input group)" +# sudo was acquired up front in preflight (SUDO_OK) so this never stalls behind the long build; a +# skip here (no password / no TTY) was already reported loudly there. if [ "$SUDO_OK" = 1 ]; then printf 'net.core.wmem_max=33554432\nnet.core.rmem_max=33554432\n' \ | sudo tee /etc/sysctl.d/99-punktfunk-net.conf >/dev/null