Files
FrameAssistant/scripts/package-release.sh
T
matzmanandClaude Opus 5.5 0bdcaddcd5 App commands and --ha-remove (iteration 2, step 6)
The platform accepts app commands (D43): flags that get a
QCoreApplication like the manifest commands and run prepare() and then
the new hook runCommand(). The app's --ha-remove clears the device's
retained topics, so HA deletes the device; uninstall.sh runs it after
stopping the app and before unregistering from SteamVR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 16:32:51 +02:00

111 lines
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the dashboard for the Steam Frame (aarch64) and packages it for release:
#
# dist/<executable>-<version>-linux-arm64/ uses SteamOS's Qt (default, ~3 MB)
# dist/<executable>-<version>-linux-arm64-bundled/ Qt bundled (--bundle-qt, ~46 MB)
# (each also as .tar.gz)
#
# The package contains only the dashboard itself plus install.sh,
# uninstall.sh and a README. Installing again over an existing installation updates it.
#
# scripts/package-release.sh [--bundle-qt] [--no-build]
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
build=1 bundle_qt=0
for arg in "$@"; do
case "$arg" in
--no-build) build=0 ;;
--bundle-qt) bundle_qt=1 ;;
*) echo "usage: $0 [--bundle-qt] [--no-build]" >&2; exit 2 ;;
esac
done
if [[ "$(uname -m)" == aarch64 ]]; then mode=native; else mode=cross; fi
if (( bundle_qt )); then
mode+=-bundle
[[ "$mode" == native-bundle ]] && preset=native-bundle || preset=cross-arm64-bundle
else
[[ "$mode" == native ]] && preset=native-systemqt || preset=cross-arm64
fi
(( build )) && "$root/scripts/container-build.sh" "$mode"
cache="$root/build/$preset/CMakeCache.txt"
setting() { sed -n "s/^$1:[A-Z]*=//p" "$cache"; }
exe="$(setting VRDASH_EXECUTABLE_NAME)"
name="$(setting VRDASH_DISPLAY_NAME)"
key="$(setting VRDASH_APP_KEY)"
version="$(setting CMAKE_PROJECT_VERSION)"
project="$(setting CMAKE_PROJECT_NAME)"
stage="$root/build/$preset/stage"
[[ "$(file -b "$stage/bin/$exe")" == *aarch64* ]] || { echo "$stage/bin/$exe is not an aarch64 build" >&2; exit 1; }
package="$exe-$version-linux-arm64"
(( bundle_qt )) && package+=-bundled
out="$root/dist/$package"
rm -rf "$out" "$out.tar.gz"
mkdir -p "$out"
cp -a "$stage/." "$out/"
# Only the dashboard: drop any other executables.
find "$out/bin" -maxdepth 1 -type f -perm -u+x ! -name "$exe" -delete
cp "$root/LICENSE" "$out/"
cat > "$out/install.sh" <<EOF
#!/bin/sh
# Installs or updates $name: registers it with SteamVR (starts automatically with
# SteamVR) and starts it now. SteamVR must be running. Works over SSH.
cd "\$(dirname "\$0")" || exit 1
mkdir -p logs
# An update replaces the files of a running instance: stop it, SteamVR restarts it below.
# (Match the command line: process names are cut to 15 characters.)
pkill -f "/bin/$exe( |\\$)" 2>/dev/null && sleep 1
exec ./bin/$exe --install-manifest --launch --log-file logs/install.log
EOF
cat > "$out/uninstall.sh" <<EOF
#!/bin/sh
# Stops $name, removes its device from Home Assistant (clears its retained MQTT
# topics) and unregisters it from SteamVR. The folder can be deleted afterwards.
cd "\$(dirname "\$0")" || exit 1
mkdir -p logs
# Stopped first, so it can't publish itself again; the broker sends its last will at once.
pkill -f "/bin/$exe( |\\$)" 2>/dev/null && sleep 1
./bin/$exe --ha-remove --log-file logs/install.log ||
echo "Could not remove the device from Home Assistant (see logs/install.log); unregistering anyway." >&2
exec ./bin/$exe --uninstall-manifest --log-file logs/install.log
EOF
chmod +x "$out/install.sh" "$out/uninstall.sh"
{
echo "$name $version (SteamVR dashboard overlay, app key $key)"
echo
if (( bundle_qt )); then
echo "Self-contained build: Qt is included."
else
echo "Uses the system's Qt (SteamOS: Qt 6.8 or newer). If it fails to start after a"
echo "SteamOS update, use the -bundled package instead."
fi
echo
echo "Settings (required before the first start):"
echo " mkdir -p ~/.config/$project"
echo " cp share/$project/config.example.json ~/.config/$project/config.json"
echo " chmod 600 ~/.config/$project/config.json"
echo " then edit it (device name, MQTT broker, Home Assistant URL)."
echo " Without valid settings the app exits; the reason is in"
echo " logs/$exe.log."
echo
echo "Install / update: ./install.sh (SteamVR must be running)"
echo " SteamVR remembers this folder's location: after moving it,"
echo " run ./install.sh again."
echo "Uninstall: ./uninstall.sh (also removes the device from Home Assistant;"
echo " needs the settings file and the MQTT broker)"
echo "Logs: logs/$exe.log (the app), logs/install.log (install.sh);"
echo " run ./bin/$exe --help for options"
echo
echo "License: MIT (LICENSE). Third-party notices: share/doc/$project/."
} > "$out/README.txt"
tar -C "$root/dist" -czf "$out.tar.gz" "$package"
echo "Release folder: $out"
echo "Archive: $out.tar.gz ($(du -h "$out.tar.gz" | cut -f1))"