Fennec OS 0.3.2: one app at a time, Raspberry Pi shell packages

- sf-core: only one app runs. Home, another app or a cast closes the app
  on screen (after the switch animation) instead of freezing it in the
  background. A frozen app that held a sound stream stalled PipeWire, so
  the next app could not play at all ("Failed to connect stream: No such
  entity" in Netflex after YouTube was sent home mid-video). The
  background limit and the low-memory watcher go with the freezing.
- Raspberry Pi: image/pi (installer on Raspberry Pi OS), aarch64 shell
  packages (sf-shell-<v>-aarch64, arch in pkg.toml, sf-update installs only
  its own architecture), CI builds the aarch64 shell too.
- sf-compositor: volume OSD, screencopy for remote view, blank cursor.
- SDK v0.1.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tamas Csikel
2026-11-02 19:38:09 +01:00
parent 54cdaf5e35
commit 9c710bedb9
33 changed files with 1329 additions and 319 deletions

107
image/pi/build.sh Normal file
View File

@@ -0,0 +1,107 @@
#!/usr/bin/env bash
# Builds Fennec OS for the Raspberry Pi (4 and 5; 64-bit Raspberry Pi OS or
# Debian trixie, arm64): a tarball that installs on top of the Pi's system.
# Cross-compiles in WSL Debian (or any Debian trixie host), as root:
# sudo bash /mnt/g/source/smartfox/image/pi/build.sh
# Writes image/out/fennec-os-pi-<version>-aarch64.tar.gz. On the Pi:
# tar xf fennec-os-pi-*.tar.gz && sudo fennec-os-pi/install.sh
set -euo pipefail
SRC="$(cd "$(dirname "$0")/../.." && pwd)"
WORK="${SMARTFOX_PI_WORK:-/root/fennec-pi}"
TARGET=aarch64-unknown-linux-gnu
OUT_DIR="$SRC/image/out"
echo "== toolchain"
if ! dpkg --print-foreign-architectures | grep -qx arm64; then
dpkg --add-architecture arm64
fi
need=(gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross pkg-config rsync
libfontconfig1-dev:arm64 libfreetype-dev:arm64 libxkbcommon-dev:arm64 libdbus-1-dev:arm64
libudev-dev:arm64 libinput-dev:arm64 libgbm-dev:arm64 libseat-dev:arm64 libdrm-dev:arm64 libegl-dev:arm64)
missing=()
for p in "${need[@]}"; do dpkg-query -W -f='${Status}' "$p" 2>/dev/null | grep -q 'ok installed' || missing+=("$p"); done
if [ ${#missing[@]} -gt 0 ]; then
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends "${missing[@]}"
fi
if ! command -v cargo >/dev/null; then
[ -x "$HOME/.cargo/bin/cargo" ] || curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
export PATH="$HOME/.cargo/bin:$PATH"
fi
rustup target list --installed | grep -qx "$TARGET" || rustup target add "$TARGET"
echo "== sync $SRC -> $WORK/src"
mkdir -p "$WORK"
# Store apps checked out for development (apps/<id>/.git) and the local SDK
# patch (.cargo) stay out: the build uses the SDK tag, like CI.
rsync -a --delete --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r \
--exclude /target --exclude '*/target' --exclude /.cargo --exclude /image/mkosi.output --exclude /image/mkosi.cache \
--exclude /image/stage --exclude /image/out --exclude /image/iso --exclude /image/installer/mkosi.output \
--exclude /image/installer/mkosi.cache --exclude /image/ovmf-vars.fd \
"$SRC/" "$WORK/src/"
for d in "$WORK"/src/apps/*/; do [ -e "$d/.git" ] && rm -rf "$d"; done
cd "$WORK/src"
echo "== cargo build ($TARGET)"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
export PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG_SYSROOT_DIR=/ PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig
export CARGO_TARGET_DIR="$WORK/target"
BINS=(sf-launcher sf-remote sf-update sf-core sf-miracast sf-compositor)
args=()
for b in "${BINS[@]}"; do args+=(-p "$b"); done
cargo build --release --locked --target "$TARGET" "${args[@]}"
BIN_DIR="$CARGO_TARGET_DIR/$TARGET/release"
echo "== stage"
VERSION=$(sed -n '/^\[workspace.package\]/,/^\[/ s/^version *= *"\(.*\)"/\1/p' Cargo.toml)
PKG="$WORK/stage/fennec-os-pi"
R="$PKG/root"
X=image/mkosi.extra
rm -rf "$WORK/stage"
mkdir -p "$R"
for b in "${BINS[@]}"; do install -Dm755 "$BIN_DIR/$b" "$R/usr/bin/$b"; done
install -Dm755 tools/siri-remote/fastpair.py "$R/usr/bin/sf-pair"
# The TV's session scripts as they are. Not taken: sf-remote-debug (it turns
# ssh off at boot), fstab, systemd-networkd/iwd, sshd and apt settings: the
# Pi keeps its own system, network and ssh.
for f in sf-session sf-launcher-start sf-shell-exec sf-diag; do install -Dm755 "$X/usr/bin/$f" "$R/usr/bin/$f"; done
for u in sf-remote.service sf-update-apply.service sf-update-auto.service sf-update-auto.timer \
sf-update-requests.path sf-update-requests.service; do
install -Dm644 "$X/usr/lib/systemd/system/$u" "$R/usr/lib/systemd/system/$u"
done
install -Dm644 "$X/usr/lib/tmpfiles.d/smartfox.conf" "$R/usr/lib/tmpfiles.d/smartfox.conf"
install -Dm644 "$X/usr/lib/smartfox/blank-cursor.py" "$R/usr/lib/smartfox/blank-cursor.py"
install -Dm644 "$X/etc/systemd/system/bluetooth.service.d/smartfox.conf" "$R/etc/systemd/system/bluetooth.service.d/smartfox.conf"
# No data partition on the Pi: /var is part of the root file system.
install -d "$R/etc/systemd/system/sf-update-apply.service.d"
printf '# Fennec OS on Raspberry Pi OS: /var is not a separate partition.\n[Unit]\nConditionPathIsMountPoint=\n' \
>"$R/etc/systemd/system/sf-update-apply.service.d/fennec-pi.conf"
for f in settings.toml update.toml; do install -Dm644 "$X/usr/share/smartfox/$f" "$R/usr/share/smartfox/$f"; done
install -Dm644 image/pi/factory-store.toml "$R/usr/share/smartfox/factory-store.toml"
if [ -f image/secrets/update-token ]; then
install -Dm600 image/secrets/update-token "$R/usr/share/smartfox/update-token"
else
echo "warning: image/secrets/update-token is missing, sf-update will log in anonymously"
fi
mkdir -p "$R/usr/share/smartfox/apps"
for d in apps/*/; do cp -r "$d" "$R/usr/share/smartfox/apps/"; done
chmod -R u=rwX,go=rX "$R/usr/share/smartfox/apps"
{
echo "sf-shell = \"$VERSION\""
for d in "$R"/usr/share/smartfox/apps/*/; do
v=$(sed -n 's/^version *= *"\(.*\)".*/\1/p' "$d/app.toml" | head -1)
[ -n "$v" ] && echo "sf-app-$(basename "$d") = \"$v\""
done
} >"$R/usr/share/smartfox/factory-versions.toml"
mkdir -p "$R/usr/share/doc/smartfox"
cp docs/updates.md docs/store.md "$R/usr/share/doc/smartfox/"
install -m755 image/pi/install.sh "$PKG/install.sh"
echo "Fennec OS $VERSION · aarch64 · $(date +%Y-%m-%d)" >"$PKG/VERSION"
echo "== tarball"
mkdir -p "$OUT_DIR"
TAR="$OUT_DIR/fennec-os-pi-$VERSION-aarch64.tar.gz"
tar --owner=0 --group=0 --numeric-owner -C "$WORK/stage" -czf "$TAR" fennec-os-pi
ls -lh "$TAR"

View File

@@ -0,0 +1,12 @@
# store.toml of a new Raspberry Pi install (docs/store.md). Same catalog as
# the TV. Steam is left out: Valve's client is x86-64 only. Netflex installs
# once its release has an aarch64 package (until then sf-update skips it).
sources = ["https://gitea.bluefox.support/fennec/store"]
[apps."support.bluefox.netflex"]
source = "https://gitea.bluefox.support/fennec/netflex"
permissions = ["network", "gpu", "audio"]
[apps."support.bluefox.youtube"]
source = "https://gitea.bluefox.support/fennec/youtube"
permissions = ["network", "gpu", "audio", "dial"]

163
image/pi/install.sh Normal file
View File

@@ -0,0 +1,163 @@
#!/bin/sh
# Installs Fennec OS on a Raspberry Pi (4 or 5) running 64-bit Raspberry Pi OS
# (Debian trixie). The Pi keeps its own system, network (NetworkManager) and
# ssh; Fennec OS takes over the screen: user tv logs in on tty1 and starts
# the TV session instead of the desktop.
#
# sudo ./install.sh install or update, then reboot
# sudo ./install.sh --no-session install, but keep booting to the desktop
# sudo ./install.sh --uninstall back to the desktop (keeps user tv and its data)
# sudo ./install.sh --purge uninstall and delete user tv and all Fennec OS data
#
# Built by image/pi/build.sh.
set -eu
HERE=$(cd "$(dirname "$0")" && pwd)
STATE=/var/lib/smartfox/pi
FILES=$STATE/files
AUTOLOGIN=/etc/systemd/system/getty@tty1.service.d/smartfox-autologin.conf
UNITS="sf-remote.service sf-update-apply.service sf-update-requests.path sf-update-auto.timer"
# Runtime dependencies (the TV image's list, without its kernel, firmware,
# iwd/networkd and Steam parts). Most are already on Raspberry Pi OS.
PACKAGES="cage wlr-randr chromium fonts-noto-core fonts-dejavu-core libgl1-mesa-dri libegl1 libgles2
libgbm1 libfontconfig1 libfreetype6 libxkbcommon0 libwayland-client0 libwayland-egl1 pipewire pipewire-pulse
wireplumber libspa-0.2-bluetooth pulseaudio-utils avahi-daemon uxplay dbus-user-session libpam-systemd libseat1
libinput10 gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
gstreamer1.0-libav gstreamer1.0-pipewire glib-networking bubblewrap bluez python3 python3-dbus python3-gi wayvnc"
say() { printf '== %s\n' "$*"; }
die() { printf 'install.sh: %s\n' "$*" >&2; exit 1; }
[ "$(id -u)" = 0 ] || die "run it as root: sudo $0 $*"
uninstall() {
purge=$1
say "Fennec OS: uninstalling"
systemctl disable --now $UNITS 2>/dev/null || true
rm -f "$AUTOLOGIN"
rmdir /etc/systemd/system/getty@tty1.service.d 2>/dev/null || true
if [ -f "$FILES" ]; then
while IFS= read -r f; do rm -f "/$f"; done <"$FILES"
fi
rm -rf /usr/share/smartfox /usr/lib/smartfox /usr/share/icons/smartfox-blank /usr/share/doc/smartfox
rmdir /etc/systemd/system/sf-update-apply.service.d /etc/systemd/system/bluetooth.service.d 2>/dev/null || true
if [ -f "$STATE/icon-theme" ]; then
cp "$STATE/icon-theme" /usr/share/icons/default/index.theme
else
rm -f /usr/share/icons/default/index.theme
fi
target=$(cat "$STATE/default-target" 2>/dev/null || echo graphical.target)
systemctl set-default "$target"
systemctl daemon-reload
systemctl try-restart bluetooth.service || true
rm -rf "$STATE"
if [ "$purge" = 1 ]; then
say "deleting user tv and the Fennec OS data"
pkill -u tv 2>/dev/null || true
sleep 1
userdel -r tv 2>/dev/null || true
rm -rf /var/lib/smartfox /var/lib/sf-pkg
fi
say "done; reboot to get the desktop back (or: systemctl isolate $target)"
}
session=1
case "${1:-}" in
--uninstall) uninstall 0; exit 0 ;;
--purge) uninstall 1; exit 0 ;;
--no-session) session=0 ;;
"") ;;
*) die "unknown option: $1" ;;
esac
[ "$(uname -m)" = aarch64 ] || die "this build is for 64-bit ARM (aarch64), this is $(uname -m)"
[ -d "$HERE/root" ] || die "$HERE/root is missing (unpack the whole tarball)"
say "installing $(cat "$HERE/VERSION" 2>/dev/null || echo 'Fennec OS')"
say "packages"
missing=""
for p in $PACKAGES; do
dpkg-query -W -f='${Status}' "$p" 2>/dev/null | grep -q 'ok installed' || missing="$missing $p"
done
if [ -n "$missing" ]; then
apt-get update -q
# shellcheck disable=SC2086
DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends $missing
fi
say "files"
mkdir -p "$STATE"
# What was here before Fennec OS, for --uninstall (only the first time).
[ -f "$STATE/default-target" ] || systemctl get-default >"$STATE/default-target"
if [ ! -f "$STATE/icon-theme" ] && [ -f /usr/share/icons/default/index.theme ] && ! grep -q smartfox-blank /usr/share/icons/default/index.theme; then
cp /usr/share/icons/default/index.theme "$STATE/icon-theme"
fi
# Files of the previous version that are gone in this one.
new_files=$(cd "$HERE/root" && find . -type f | sed 's#^\./##' | sort)
if [ -f "$FILES" ]; then
printf '%s\n' "$new_files" | comm -23 "$FILES" - | while IFS= read -r f; do rm -f "/$f"; done
fi
rm -rf /usr/share/smartfox/apps
cd "$HERE/root"
printf '%s\n' "$new_files" | while IFS= read -r f; do
mode=$(stat -c %a "$f")
install -D -o root -g root -m "$mode" "$f" "/$f"
done
cd /
printf '%s\n' "$new_files" >"$FILES"
python3 /usr/lib/smartfox/blank-cursor.py
say "user tv"
if ! id tv >/dev/null 2>&1; then
useradd -m -s /bin/bash tv
fi
for g in video render input audio bluetooth netdev; do
getent group "$g" >/dev/null && usermod -aG "$g" tv
done
TV_UID=$(id -u tv)
TV_HOME=$(getent passwd tv | cut -d: -f6)
# The TV image's tv is uid 1000; here 1000 is usually the Pi's own user.
sed -i "s#/run/user/1000#/run/user/$TV_UID#g" /usr/lib/systemd/system/sf-remote.service /usr/bin/sf-diag
cat >"$TV_HOME/.bash_profile" <<'EOF'
# Start the Fennec OS session on the first console (image/pi/install.sh).
if [ "$(tty)" = "/dev/tty1" ]; then
exec /usr/bin/sf-session
fi
EOF
chown tv:tv "$TV_HOME/.bash_profile"
say "services"
systemd-tmpfiles --create /usr/lib/tmpfiles.d/smartfox.conf
[ -f /var/lib/smartfox/store.toml ] || install -o tv -g tv -m644 /usr/share/smartfox/factory-store.toml /var/lib/smartfox/store.toml
systemctl daemon-reload
# shellcheck disable=SC2086
systemctl enable $UNITS
systemctl enable bluetooth.service avahi-daemon.service
# The Siri Remote needs Bluetooth: lift a soft block (Raspberry Pi OS keeps the
# desktop's Bluetooth switch there; systemd-rfkill saves the new state).
for r in /sys/class/rfkill/rfkill*; do
[ "$(cat "$r/type" 2>/dev/null)" = bluetooth ] && echo 0 >"$r/soft"
done
# bluetoothd without its input/HoG plugins: sf-remote reads the Siri Remote itself.
systemctl restart bluetooth.service || true
systemctl restart sf-remote.service || true
say "store apps"
sf-update store || echo "warning: the store apps could not be installed now; the Pi installs them once online" >&2
if [ "$session" = 1 ]; then
say "session: tv on tty1, no desktop"
mkdir -p "$(dirname "$AUTOLOGIN")"
# After the Pi's own autologin.conf (raspi-config), so this one wins.
cat >"$AUTOLOGIN" <<'EOF'
# Fennec OS (image/pi/install.sh --uninstall removes it)
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin tv --noclear --skip-login --nonewline --noissue %I $TERM
EOF
systemctl daemon-reload
systemctl set-default multi-user.target
say "done; reboot to start Fennec OS (or now: systemctl isolate multi-user.target && systemctl restart getty@tty1)"
else
say "done; the Pi still boots to its desktop (start Fennec OS: sudo $0)"
fi