- 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>
108 lines
5.5 KiB
Bash
108 lines
5.5 KiB
Bash
#!/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"
|