tv-anarchy/tools/platform.sh
Natalie 4a2ceb9781 feat(offline): inline star-to-keep and trash-to-cull on cache rows
Surface the existing pin (keep-from-cull) and per-file delete actions as
visible inline buttons on each offline cache row instead of context-menu-only:
a star toggles protection from auto-cull (and restore-if-missing), a trash
culls that file early. Aligns wording/icons to the star metaphor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 00:12:41 -04:00

68 lines
3.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# The SINGLE SOURCE OF TRUTH for TVAnarchy's per-OS platform logic: which OS
# this node is, where the app installs, and which release asset it consumes.
# Sourced by build-install.sh, tools/release.sh and tools/update.sh — update.sh
# fetches this file from the forge when run standalone (curl-piped), so the
# logic is never duplicated. Functions only; no side effects on source.
# The fleet OS this node is: mac | linux | windows | android | unsupported.
# Termux is checked BEFORE generic Linux — its uname says Linux, but Android
# apps are APKs handed to the package installer, not folder installs.
tva_os() {
if [ -n "${TERMUX_VERSION:-}" ] || [ -d /data/data/com.termux ]; then echo android; return; fi
case "$(uname -s)" in
Darwin) echo mac ;;
Linux) echo linux ;;
MINGW*|MSYS*|CYGWIN*) echo windows ;;
*) echo unsupported ;;
esac
}
# True on image-based (ostree/bootc) Linux — Bluefin, Silverblue, etc. Their
# /usr is read-only and /opt is machine-local; user-scope installs are the norm.
tva_is_immutable_linux() { [ -e /run/ostree-booted ] || [ -e /usr/lib/bootc ]; }
# Where TVAnarchy installs on this node ($1 = os from tva_os):
# TVANARCHY_DEST env → explicit override, used verbatim
# mac → /Applications when writable (the standard location — Finder's
# "Applications", admin group, no sudo), else ~/Applications
# (Apple's per-user location for non-admin accounts)
# linux → /opt/tv-anarchy on classic distros when /opt is writable, else
# ~/.local/opt/tv-anarchy (always on immutable/ostree systems)
# windows → %LOCALAPPDATA%/Programs/TVAnarchy (per-user, no elevation)
# android → a DOWNLOAD dir, not an install dir (~/storage/downloads when the
# Termux storage bridge is up, else $HOME) — the APK is handed to
# the system package installer from there
tva_resolve_dest() {
if [ -n "${TVANARCHY_DEST:-}" ]; then printf '%s\n' "$TVANARCHY_DEST"; return; fi
case "$1" in
mac)
if [ -w /Applications ]; then printf '/Applications/TVAnarchy.app\n'
else printf '%s/Applications/TVAnarchy.app\n' "$HOME"; fi ;;
linux)
if ! tva_is_immutable_linux && [ -w /opt ]; then printf '/opt/tv-anarchy\n'
else printf '%s/.local/opt/tv-anarchy\n' "$HOME"; fi ;;
windows)
printf '%s/Programs/TVAnarchy\n' "${LOCALAPPDATA:-$HOME/AppData/Local}" ;;
android)
if [ -d "$HOME/storage/downloads" ]; then printf '%s/storage/downloads\n' "$HOME"
else printf '%s\n' "$HOME"; fi ;;
*) return 1 ;;
esac
}
# The release asset this platform consumes ($1 = os, $2 = tag). The Android APK
# carries all ABIs, so no arch suffix there.
tva_asset_name() {
case "$1" in
mac) printf 'TVAnarchy-%s.zip\n' "$2" ;;
linux) printf 'TVAnarchy-%s-linux-%s.tar.gz\n' "$2" "$(uname -m)" ;;
windows) printf 'TVAnarchy-%s-windows-%s.zip\n' "$2" "$(uname -m)" ;;
android) printf 'TVAnarchy-%s-android.apk\n' "$2" ;;
# Device-specific / optimized targets (planned; see v2/pillars/devices.md)
roku) printf 'TVAnarchy-%s-roku.zip\n' "$2" ;; # BrightScript channel sideload
rpi) printf 'TVAnarchy-%s-linux-arm64.tar.gz\n' "$2" ;; # optimized for Raspberry Pi / embedded ARM (aarch64 primary)
web) printf 'TVAnarchy-%s-web.tar.gz\n' "$2" ;; # thin PWA / universal client bundle
*) return 1 ;;
esac
}